public PlayPluginConfigurations(ConfigurationContainer configurations, DependencyHandler dependencyHandler) { this.configurations = configurations; this.dependencyHandler = dependencyHandler; Configuration playPlatform = configurations.create(PLATFORM_CONFIGURATION); Configuration playCompile = configurations.create(COMPILE_CONFIGURATION); playCompile.extendsFrom(playPlatform); Configuration playRun = configurations.create(RUN_CONFIGURATION); playRun.extendsFrom(playCompile); Configuration playTestCompile = configurations.create(TEST_COMPILE_CONFIGURATION); playTestCompile.extendsFrom(playCompile); configurations.maybeCreate(Dependency.DEFAULT_CONFIGURATION).extendsFrom(playCompile); }
private static void addStandardJavaTestDependencies(Project project) { Configuration testConfiguration = project.getPlugins().hasPlugin(JavaLibraryPlugin.class) ? project .getConfigurations() .getByName(JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME) : project.getConfigurations().getByName(JavaPlugin.TEST_COMPILE_CONFIGURATION_NAME); DependencyHandler dependencies = project.getDependencies(); dependencies.add(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME, "com.google.code.findbugs:jsr305"); dependencies.add(testConfiguration.getName(), "org.curioswitch.curiostack:curio-testing-framework"); dependencies.add(testConfiguration.getName(), "org.assertj:assertj-core"); dependencies.add(testConfiguration.getName(), "org.awaitility:awaitility"); dependencies.add(testConfiguration.getName(), "junit:junit"); dependencies.add(testConfiguration.getName(), "org.mockito:mockito-core"); dependencies.add(testConfiguration.getName(), "info.solidsoft.mockito:mockito-java8"); }
/** * @see me.seeber.gradle.plugin.AbstractProjectConfigPlugin#initialize() */ @Override protected void initialize() { getProject().getPluginManager().apply(GroovyPlugin.class); getProject().getPluginManager().apply(JavaConfigPlugin.class); DependencyHandler dependencies = getProject().getDependencies(); ExternalDependency spock = (ExternalDependency) dependencies.add("testCompile", ImmutableMap.of("group", "org.spockframework", "name", "spock-core", "version", "1.0-groovy-2.4")); spock.exclude(ImmutableMap.of("group", "org.codehaus.groovy", "module", "groovy-all")); String name = Validate.notNull(getProject().getName()); Configuration archives = getProject().getConfigurations().getByName("archives"); Jar groovydocJar = getProject().getTasks().create("groovydocJar", Jar.class); PublishArtifact groovydocArtifact = Projects.createJarPublishArtifact(getProject(), name, "groovydoc", "jar", "jar", groovydocJar); archives.getArtifacts().add(groovydocArtifact); }
@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" ))); }
private void addConfiguration(final Project project, final SonarRunnerRootExtension rootExtension) { final Configuration configuration = project.getConfigurations().create(SonarRunnerExtension.SONAR_RUNNER_CONFIGURATION_NAME); configuration .setVisible(false) .setTransitive(false) .setDescription("The SonarRunner configuration to use to run analysis") .getIncoming() .beforeResolve(new Action<ResolvableDependencies>() { public void execute(ResolvableDependencies resolvableDependencies) { DependencySet dependencies = resolvableDependencies.getDependencies(); if (dependencies.isEmpty()) { String toolVersion = rootExtension.getToolVersion(); DependencyHandler dependencyHandler = project.getDependencies(); Dependency dependency = dependencyHandler.create("org.codehaus.sonar.runner:sonar-runner-dist:" + toolVersion); configuration.getDependencies().add(dependency); } } }); }
public Collection<IdeExtendedRepoFileDependency> extractRepoFileDependencies(DependencyHandler dependencyHandler, Collection<Configuration> plusConfigurations, Collection<Configuration> minusConfigurations, boolean downloadSources, boolean downloadJavadoc) { // can have multiple IDE dependencies with same component identifier (see GRADLE-1622) Multimap<ComponentIdentifier, IdeExtendedRepoFileDependency> resolvedDependenciesComponentMap = LinkedHashMultimap.create(); for (IdeExtendedRepoFileDependency dep : resolvedExternalDependencies(plusConfigurations, minusConfigurations)) { resolvedDependenciesComponentMap.put(toComponentIdentifier(dep.getId()), dep); } List<Class<? extends Artifact>> artifactTypes = new ArrayList<Class<? extends Artifact>>(2); if (downloadSources) { artifactTypes.add(SourcesArtifact.class); } if (downloadJavadoc) { artifactTypes.add(JavadocArtifact.class); } downloadAuxiliaryArtifacts(dependencyHandler, resolvedDependenciesComponentMap, artifactTypes); Collection<UnresolvedIdeRepoFileDependency> unresolvedDependencies = unresolvedExternalDependencies(plusConfigurations, minusConfigurations); Collection<IdeExtendedRepoFileDependency> resolvedDependencies = resolvedDependenciesComponentMap.values(); Collection<IdeExtendedRepoFileDependency> resolvedAndUnresolved = new ArrayList<IdeExtendedRepoFileDependency>(unresolvedDependencies.size() + resolvedDependencies.size()); resolvedAndUnresolved.addAll(resolvedDependencies); resolvedAndUnresolved.addAll(unresolvedDependencies); return resolvedAndUnresolved; }
@SuppressWarnings("ResultOfMethodCallIgnored") public static void setupKotlinHome(Project project, String kotlinVersion) { Configuration kotlinConfig = project.getConfigurations().maybeCreate(KOTLIN_DEPS_CONFIG); DependencyHandler handler = project.getDependencies(); handler.add(KOTLIN_DEPS_CONFIG, String.format("%s:%s:%s", KOTLIN_GROUP, KOTLIN_COMPILER_MODULE, kotlinVersion)); handler.add(KOTLIN_DEPS_CONFIG, String.format("%s:%s:%s", KOTLIN_GROUP, KOTLIN_STDLIB_MODULE, kotlinVersion)); handler.add(KOTLIN_DEPS_CONFIG, String.format("%s:%s:%s", KOTLIN_GROUP, KOTLIN_ANDROID_EXTENSIONS_MODULE, kotlinVersion)); handler.add(KOTLIN_DEPS_CONFIG, String.format("%s:%s:%s", KOTLIN_GROUP, KOTLIN_REFLECT_MODULE, kotlinVersion)); handler.add(KOTLIN_DEPS_CONFIG, String.format("%s:%s:%s", KOTLIN_GROUP, KOTLIN_SCRIPT_RUNTIME_MODULE, kotlinVersion)); handler.add(KOTLIN_DEPS_CONFIG, String.format("%s:%s:%s", KOTLIN_GROUP, KOTLIN_ANNOTATION_PROCESSING_MODULE, kotlinVersion)); new DependencyCache(project, DependencyUtils.createCacheDir(project, KOTLIN_LIBRARIES_LOCATION)).build(kotlinConfig); Path kotlinLibraries = project.file(KOTLIN_LIBRARIES_LOCATION).toPath(); removeVersions(kotlinLibraries, KOTLIN_COMPILER_MODULE, "kotlin-compiler"); removeVersions(kotlinLibraries, KOTLIN_STDLIB_MODULE); removeVersions(kotlinLibraries, KOTLIN_ANDROID_EXTENSIONS_MODULE); removeVersions(kotlinLibraries, KOTLIN_REFLECT_MODULE); removeVersions(kotlinLibraries, KOTLIN_SCRIPT_RUNTIME_MODULE); removeVersions(kotlinLibraries, KOTLIN_ANNOTATION_PROCESSING_MODULE); }
public void configureDefaultRhinoDependency(Configuration configuration, final DependencyHandler dependencyHandler, final RhinoExtension extension) { configuration.defaultDependencies(new Action<DependencySet>() { public void execute(DependencySet dependencies) { Dependency dependency = dependencyHandler.create(RhinoExtension.DEFAULT_RHINO_DEPENDENCY_GROUP + ":" + RhinoExtension.DEFAULT_RHINO_DEPENDENCY_MODULE + ":" + extension.getVersion()); dependencies.add(dependency); } }); }
public Configuration addConfiguration(ConfigurationContainer configurations, final DependencyHandler dependencies, final JsHintExtension extension) { Configuration configuration = configurations.create(JsHintExtension.CONFIGURATION_NAME); configuration.defaultDependencies(new Action<DependencySet>() { @Override public void execute(DependencySet configDependencies) { String notation = JsHintExtension.DEFAULT_DEPENDENCY_GROUP + ":" + JsHintExtension.DEFAULT_DEPENDENCY_MODULE + ":" + extension.getVersion() + "@js"; Dependency dependency = dependencies.create(notation); configDependencies.add(dependency); } }); return configuration; }
public Configuration addConfiguration(ConfigurationContainer configurations, final DependencyHandler dependencies, final EnvJsExtension extension) { Configuration configuration = configurations.create(EnvJsExtension.CONFIGURATION_NAME); configuration.defaultDependencies(new Action<DependencySet>() { @Override public void execute(DependencySet configDependencies) { String notation = EnvJsExtension.DEFAULT_DEPENDENCY_GROUP + ":" + EnvJsExtension.DEFAULT_DEPENDENCY_MODULE + ":" + extension.getVersion() + "@js"; Dependency dependency = dependencies.create(notation); configDependencies.add(dependency); } }); return configuration; }
private Configuration addJsConfiguration(ConfigurationContainer configurations, final DependencyHandler dependencies, final CoffeeScriptExtension extension) { Configuration configuration = configurations.create(CoffeeScriptExtension.JS_CONFIGURATION_NAME); configuration.defaultDependencies(new Action<DependencySet>() { @Override public void execute(DependencySet configDependencies) { String notation = CoffeeScriptExtension.DEFAULT_JS_DEPENDENCY_GROUP + ":" + CoffeeScriptExtension.DEFAULT_JS_DEPENDENCY_MODULE + ":" + extension.getVersion() + "@js"; Dependency dependency = dependencies.create(notation); configDependencies.add(dependency); } }); return configuration; }
DependencyHandler createDependencyHandler(Instantiator instantiator, ConfigurationContainerInternal configurationContainer, DependencyFactory dependencyFactory, ProjectFinder projectFinder, ComponentMetadataHandler componentMetadataHandler, ComponentModuleMetadataHandler componentModuleMetadataHandler, ArtifactResolutionQueryFactory resolutionQueryFactory) { return instantiator.newInstance(DefaultDependencyHandler.class, configurationContainer, dependencyFactory, projectFinder, componentMetadataHandler, componentModuleMetadataHandler, resolutionQueryFactory); }
@Override public void execute(Project project) { DependencyHandler dependencies = project.getDependencies(); Set<SourceSet> testSourceSets = extension.getTestSourceSets(); for (SourceSet testSourceSet : testSourceSets) { String compileConfigurationName = testSourceSet.getCompileConfigurationName(); dependencies.add(compileConfigurationName, dependencies.gradleTestKit()); String runtimeConfigurationName = testSourceSet.getRuntimeConfigurationName(); dependencies.add(runtimeConfigurationName, project.files(pluginClasspathTask)); } }
public DownloadingScalaToolChain(File gradleUserHomeDir, File rootProjectDir, WorkerDaemonManager compilerDaemonManager, ConfigurationContainer configurationContainer, DependencyHandler dependencyHandler) { this.gradleUserHomeDir = gradleUserHomeDir; this.rootProjectDir = rootProjectDir; this.compilerDaemonManager = compilerDaemonManager; this.configurationContainer = configurationContainer; this.dependencyHandler = dependencyHandler; this.javaVersion = JavaVersion.current(); }
private static void downloadAuxiliaryArtifacts(DependencyHandler dependencyHandler, Multimap<ComponentIdentifier, IdeExtendedRepoFileDependency> dependencies, List<Class<? extends Artifact>> artifactTypes) { if (artifactTypes.isEmpty()) { return; } ArtifactResolutionQuery query = dependencyHandler.createArtifactResolutionQuery(); query.forComponents(dependencies.keySet()); @SuppressWarnings("unchecked") Class<? extends Artifact>[] artifactTypesArray = (Class<? extends Artifact>[]) artifactTypes.toArray(new Class<?>[0]); query.withArtifacts(JvmLibrary.class, artifactTypesArray); Set<ComponentArtifactsResult> componentResults = query.execute().getResolvedComponents(); for (ComponentArtifactsResult componentResult : componentResults) { for (IdeExtendedRepoFileDependency dependency : dependencies.get(componentResult.getId())) { for (ArtifactResult sourcesResult : componentResult.getArtifacts(SourcesArtifact.class)) { if (sourcesResult instanceof ResolvedArtifactResult) { dependency.addSourceFile(((ResolvedArtifactResult) sourcesResult).getFile()); } } for (ArtifactResult javadocResult : componentResult.getArtifacts(JavadocArtifact.class)) { if (javadocResult instanceof ResolvedArtifactResult) { dependency.addJavadocFile(((ResolvedArtifactResult) javadocResult).getFile()); } } } } }
@Override public DependencyHandler getDependencies() { defineConfiguration(); if (dependencyHandler == null) { dependencyHandler = dependencyResolutionServices.getDependencyHandler(); } return dependencyHandler; }
public DefaultPlayToolChain(FileResolver fileResolver, WorkerDaemonManager compilerDaemonManager, ConfigurationContainer configurationContainer, DependencyHandler dependencyHandler, WorkerProcessFactory workerProcessBuilderFactory) { this.fileResolver = fileResolver; this.compilerDaemonManager = compilerDaemonManager; this.configurationContainer = configurationContainer; this.dependencyHandler = dependencyHandler; this.workerProcessBuilderFactory = workerProcessBuilderFactory; }
/** * @see me.seeber.gradle.plugin.AbstractProjectConfigPlugin#initialize() */ @Override public void initialize() { getProject().getPluginManager().apply(ProjectConfigPlugin.class); getProject().getPluginManager().apply(JavaConfigPlugin.class); getProject().getPluginManager().apply(GroovyConfigPlugin.class); getProject().getPluginManager().apply(JavaGradlePluginPlugin.class); DependencyHandler dependencies = getProject().getDependencies(); dependencies.add("compile", dependencies.gradleApi()); dependencies.add("compile", dependencies.localGroovy()); dependencies.add("testCompile", dependencies.gradleTestKit()); dependencies.add("testCompile", "me.seeber.gradle:gradle-test-kit:1.1.1"); }
@Test public void testSimplePluginApply() { Project project = ProjectBuilder.builder().build(); DependencyHandler dependencyHandler = project.getDependencies(); Dependency pluginDependency = dependencyHandler.create("de.dynamicfiles.projects.gradle.plugins:javafx-gradle-plugin:+"); project.getBuildscript().getDependencies().add("classpath", pluginDependency); assertFalse(project.getPlugins().hasPlugin("java")); project.getPluginManager().apply("java"); assertTrue(project.getPlugins().hasPlugin("java")); assertFalse(project.getPlugins().hasPlugin("javafx-gradle-plugin")); project.getPluginManager().apply("javafx-gradle-plugin"); assertTrue(project.getPlugins().hasPlugin("javafx-gradle-plugin")); }
@Test(expectedExceptions = org.gradle.api.GradleException.class) public void testSimplePluginApply_missingJavaPlugin() { Project project = ProjectBuilder.builder().build(); DependencyHandler dependencyHandler = project.getDependencies(); Dependency pluginDependency = dependencyHandler.create("de.dynamicfiles.projects.gradle.plugins:javafx-gradle-plugin:+"); project.getBuildscript().getDependencies().add("classpath", pluginDependency); assertFalse(project.getPlugins().hasPlugin("java")); assertFalse(project.getPlugins().hasPlugin("javafx-gradle-plugin")); project.getPluginManager().apply("javafx-gradle-plugin"); }
private static void downloadAuxiliaryArtifacts(DependencyHandler dependencyHandler, Multimap<ComponentIdentifier, IdeExtendedRepoFileDependency> dependencies, List<Class<? extends Artifact>> artifactTypes) { if (artifactTypes.isEmpty()) { return; } ArtifactResolutionQuery query = dependencyHandler.createArtifactResolutionQuery(); query.forComponents(dependencies.keySet()); @SuppressWarnings("unchecked") Class<? extends Artifact>[] artifactTypesArray = (Class<? extends Artifact>[]) new Class<?>[artifactTypes.size()]; query.withArtifacts(JvmLibrary.class, artifactTypes.toArray(artifactTypesArray)); Set<ComponentArtifactsResult> componentResults = query.execute().getResolvedComponents(); for (ComponentArtifactsResult componentResult : componentResults) { for (IdeExtendedRepoFileDependency dependency : dependencies.get(componentResult.getId())) { for (ArtifactResult sourcesResult : componentResult.getArtifacts(SourcesArtifact.class)) { if (sourcesResult instanceof ResolvedArtifactResult) { dependency.setSourceFile(((ResolvedArtifactResult) sourcesResult).getFile()); } } for (ArtifactResult javadocResult : componentResult.getArtifacts(JavadocArtifact.class)) { if (javadocResult instanceof ResolvedArtifactResult) { dependency.setJavadocFile(((ResolvedArtifactResult) javadocResult).getFile()); } } } } }
public ScriptHandler create(ScriptSource scriptSource, ClassLoaderScope classLoaderScope, DomainObjectContext context) { DependencyResolutionServices services = dependencyManagementServices.create(fileResolver, dependencyMetaDataProvider, projectFinder, context); RepositoryHandler repositoryHandler = services.getResolveRepositoryHandler(); ConfigurationContainer configurationContainer = services.getConfigurationContainer(); DependencyHandler dependencyHandler = services.getDependencyHandler(); return new DefaultScriptHandler(scriptSource, repositoryHandler, dependencyHandler, configurationContainer, new ScriptHandlerClassLoaderFactory(scriptSource, classLoaderScope)); }
public DefaultScriptHandler( ScriptSource scriptSource, RepositoryHandler repositoryHandler, DependencyHandler dependencyHandler, ConfigurationContainer configContainer, Factory<ClassLoader> classLoaderFactory ) { this.repositoryHandler = repositoryHandler; this.dependencyHandler = dependencyHandler; this.scriptSource = scriptSource; this.configContainer = configContainer; this.classLoaderFactory = classLoaderFactory; classpathConfiguration = configContainer.create(CLASSPATH_CONFIGURATION); }
public AbstractScriptHandler(RepositoryHandler repositoryHandler, DependencyHandler dependencyHandler, ScriptSource scriptSource, ConfigurationContainer configContainer) { this.repositoryHandler = repositoryHandler; this.dependencyHandler = dependencyHandler; this.scriptSource = scriptSource; this.configContainer = configContainer; classpathConfiguration = configContainer.create(CLASSPATH_CONFIGURATION); }
DependencyHandler createDependencyHandler(Instantiator instantiator, ConfigurationContainerInternal configurationContainer, DependencyFactory dependencyFactory, ProjectFinder projectFinder, ComponentMetadataHandler componentMetadataHandler, ArtifactResolutionQueryFactory resolutionQueryFactory) { return instantiator.newInstance(DefaultDependencyHandler.class, configurationContainer, dependencyFactory, projectFinder, componentMetadataHandler, resolutionQueryFactory); }
public Dependency map(final PluginRequest request, DependencyHandler dependencyHandler) { final String pluginId = request.getId(); String systemId = cacheSupplier.supplyTo(new Transformer<String, PersistentIndexedCache<PluginRequest, String>>() { public String transform(PersistentIndexedCache<PluginRequest, String> cache) { return doCacheAwareSearch(request, pluginId, cache); } }); if (systemId.equals(NOT_FOUND)) { return null; } else { return dependencyHandler.create(systemId + ":" + request.getVersion()); } }
public GracljInternal(ConfigurationContainer configurations, DependencyHandler dependencies) { this.configurations = configurations; this.dependencies = dependencies; Properties props = new Properties(); try (InputStream stream = this.getClass().getResourceAsStream("/org/graclj/version.properties")) { props.load(stream); } catch (IOException e) { throw new UncheckedIOException(e); } gracljVersion = props.get("version").toString(); }
public DependencyHandler getDependencyHandler() { return services.get(DependencyHandler.class); }
private void applyDependencies(Project project) { DependencyHandler dependencies = project.getDependencies(); dependencies.add(COMPILE_CONFIGURATION, dependencies.gradleApi()); }
ScalaToolChainInternal createScalaToolChain(GradleInternal gradle, WorkerDaemonManager compilerDaemonManager, ConfigurationContainer configurationContainer, DependencyHandler dependencyHandler) { return new DownloadingScalaToolChain(gradle.getGradleUserHomeDir(), gradle.getRootProject().getProjectDir(), compilerDaemonManager, configurationContainer, dependencyHandler); }
public DependencyHandler getDependencies() { if (dependencyHandler == null) { dependencyHandler = services.get(DependencyHandler.class); } return dependencyHandler; }
public void setDependencyHandler(DependencyHandler dependencyHandler) { this.dependencyHandler = dependencyHandler; }
PlayToolChainInternal createPlayToolChain(FileResolver fileResolver, WorkerDaemonManager compilerDaemonManager, ConfigurationContainer configurationContainer, DependencyHandler dependencyHandler, WorkerProcessFactory workerProcessBuilderFactory) { return new DefaultPlayToolChain(fileResolver, compilerDaemonManager, configurationContainer, dependencyHandler, workerProcessBuilderFactory); }
/** * @see me.seeber.gradle.plugin.AbstractProjectConfigPlugin#initialize() */ @Override protected void initialize() { getProject().getPluginManager().apply(TestingModelBasePlugin.class); getProject().getPluginManager().apply(JUnitTestSuitePlugin.class); getProject().getPluginManager().apply(JavaLanguagePlugin.class); getProject().getPluginManager().apply(JavaPlugin.class); getProject().getPluginManager().apply(ProjectConfigPlugin.class); getProject().getPluginManager().apply(JacocoPlugin.class); DependencyHandler dependencies = getProject().getDependencies(); getProject().getConfigurations().create(ECLIPSE_JAVA_COMPILER_CONFIGURATION, c -> { c.setDescription("Eclipse Java Compiler"); c.setVisible(false); c.setTransitive(true); }); dependencies.add(ECLIPSE_JAVA_COMPILER_CONFIGURATION, "org.eclipse.jdt.core.compiler:ecj:4.6.1"); getProject().getConfigurations().create(ANNOTATIONS_CONFIGURATION, c -> { c.setDescription("Eclipse external annotation archives"); c.setVisible(false); c.setTransitive(true); }); JacocoPluginExtension jacoco = getProject().getExtensions().getByType(JacocoPluginExtension.class); jacoco.setToolVersion(JACOCO_VERSION); for (String configurationName : ImmutableList.of("compileOnly", "testCompileOnly")) { dependencies.add(configurationName, "org.eclipse.jdt:org.eclipse.jdt.annotation:2.0.0"); } // Add published JARs to archives configuration String name = Validate.notNull(getProject().getName()); Configuration archives = getProject().getConfigurations().getByName("archives"); Jar sourcesJar = getProject().getTasks().create("sourcesJar", Jar.class); PublishArtifact sourcesArtifact = Projects.createJarPublishArtifact(getProject(), name, "sources", "jar", "jar", sourcesJar); archives.getArtifacts().add(sourcesArtifact); Jar javadocJar = getProject().getTasks().create("javadocJar", Jar.class); PublishArtifact javadocArtifact = Projects.createJarPublishArtifact(getProject(), name, "javadoc", "jar", "jar", javadocJar); archives.getArtifacts().add(javadocArtifact); // Create configuration for test archives String testName = name + "-test"; Configuration testArchives = getProject().getConfigurations().create("testArchives"); Configuration testRuntime = getProject().getConfigurations().getByName("testRuntime"); Jar testJar = getProject().getTasks().create("testJar", Jar.class); testJar.setBaseName(testName); PublishArtifact testArtifact = Projects.createJarPublishArtifact(getProject(), testName, null, "jar", "jar", testJar); testArchives.getArtifacts().add(testArtifact); testRuntime.getArtifacts().add(testArtifact); configureIntegrationTests(); }
private void addDependencies() { final DependencyHandler handler = this.project.getDependencies(); handler.add( "compile", this.ext.dependency( "boot" ) ); handler.add( "testCompile", this.ext.dependency( "testing" ) ); }