/** * <p>Locates a project dependency by notation. If the path is relative, it is interpreted relative to this project. * This is to be used from the {@code dependencies { ... }} block.</p> * * @param notation A map containing the parameters to create the projet. * @return The project with the given path. Never returns null. * @throws org.gradle.api.UnknownProjectException If no project with the given path exists. */ public ProjectDependency relativeProject(Map<String, ?> notation) { return (ProjectDependency) project.getDependencies().project(resolveProjectPath(project, notation)); }
/** * <p>Locates a project dependency by notation. If the path is relative, it is interpreted relative to this project. * This is to be used from the {@code dependencies { ... }} block.</p> * * @param notation A map containing the parameters to create the projet. * @return The project with the given path. Never returns null. * @throws org.gradle.api.UnknownProjectException If no project with the given path exists. */ public ProjectDependency relativeProject(Map<String, ?> notation) { return (ProjectDependency) project.getDependencies().project(resolveProjectPath(project, notation)); }
@Override public void preVariantWork(final Project project) { final TestAndroidConfig testExtension = (TestAndroidConfig) extension; String path = testExtension.getTargetProjectPath(); if (path == null) { throw new GradleException( "targetProjectPath cannot be null in test project " + project.getName()); } if (testExtension.getTargetVariant() == null) { throw new GradleException( "targetVariant cannot be null in test project " + project.getName()); } DependencyHandler handler = project.getDependencies(); handler.add("provided", handler.project(ImmutableMap.of( "path", path, "configuration", testExtension.getTargetVariant() + "-classes" ))); }
@Override public void preVariantWork(final Project project) { final TestAndroidConfig testExtension = (TestAndroidConfig) extension; String path = testExtension.getTargetProjectPath(); if (path == null) { throw new GradleException( "targetProjectPath cannot be null in test project " + project.getName()); } if (testExtension.getTargetVariant() == null) { throw new GradleException( "targetVariant cannot be null in test project " + project.getName()); } // While we want this to be provided only, we're still going to set this as compile // (and therefore show up on the apk scope). This is because this can bring in // aar dependencies and this would trigger errors as aars are not supported as // provided dependencies. // Instead we'll automatically detect that these dependencies are coming from the tested // app module and we'll skip them automatically (in the apk scope) DependencyHandler handler = project.getDependencies(); Map<String, String> projectNotation = ImmutableMap.of( "path", path, "configuration", testExtension.getTargetVariant() + VariantDependencies.CONFIGURATION_CLASSES); handler.add("compile", handler.project(projectNotation)); }
/** Creates the test target configuration that depends on the supplied target configuration */ @NonNull private Configuration getTestTargetConfiguration(@NonNull String targetConfigurationName){ String testTargetConfigurationName = TEST_CONFIGURATION_PREFIX; if (!targetConfigurationName.isEmpty()){ testTargetConfigurationName += StringHelper.capitalize(targetConfigurationName); } Configuration testTargetConfiguration = project.getConfigurations() .create(testTargetConfigurationName); DependencyHandler dependencyHandler = project.getDependencies(); TestAndroidConfig testExtension = (TestAndroidConfig) extension; dependencyHandler.add(testTargetConfigurationName, dependencyHandler.project( ImmutableMap.of( "path", testExtension.getTargetProjectPath(), "configuration", testExtension.getTargetVariant() + targetConfigurationName))); return testTargetConfiguration; } }
Dependency projectDependency = project.getDependencies().project(info.getProperties());
Configuration testTargetMapping = project.getConfigurations().create("testTargetMapping"); dependencyHandler.add("testTargetMapping", dependencyHandler.project( ImmutableMap.of( "path", testExtension.getTargetProjectPath(), dependencyHandler.add("testTargetClasses", dependencyHandler.project( ImmutableMap.of( "path", testExtension.getTargetProjectPath(),
TestAndroidConfig testExtension = (TestAndroidConfig) extension; dependencyHandler.add("testTarget", dependencyHandler.project( ImmutableMap.of( "path", testExtension.getTargetProjectPath(), dependencyHandler.add("testTargetMetadata", dependencyHandler.project( ImmutableMap.of( "path", testExtension.getTargetProjectPath(),