org.gradle.api.artifacts.dsl.DependencyHandler Java Examples
The following examples show how to use
org.gradle.api.artifacts.dsl.DependencyHandler.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IdeDependenciesExtractor.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
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; }
Example #2
Source File: SonarRunnerPlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
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); } } }); }
Example #3
Source File: CuriostackRootPlugin.java From curiostack with MIT License | 6 votes |
private static void addStandardJavaTestDependencies(Project project) { DependencyHandler dependencies = project.getDependencies(); dependencies.add(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME, "com.google.code.findbugs:jsr305"); dependencies.add( JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME, "org.curioswitch.curiostack:curio-testing-framework"); dependencies.add(JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME, "org.assertj:assertj-core"); dependencies.add( JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME, "org.awaitility:awaitility"); dependencies.add(JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME, "junit:junit"); dependencies.add(JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME, "org.mockito:mockito-core"); dependencies.add( JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME, "org.mockito:mockito-junit-jupiter"); dependencies.add( JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME, "info.solidsoft.mockito:mockito-java8"); dependencies.add( JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME, "org.junit.jupiter:junit-jupiter-api"); dependencies.add( JavaPlugin.TEST_RUNTIME_ONLY_CONFIGURATION_NAME, "org.junit.jupiter:junit-jupiter-engine"); dependencies.add( JavaPlugin.TEST_RUNTIME_ONLY_CONFIGURATION_NAME, "org.junit.vintage:junit-vintage-engine"); }
Example #4
Source File: PlayApplicationPlugin.java From playframework with Apache License 2.0 | 6 votes |
private void addAutomaticDependencies(DependencyHandler dependencies, PlayPlatform playPlatform) { dependencies.add(PLATFORM_CONFIGURATION, playPlatform.getDependencyNotation("play").get()); dependencies.add(TEST_IMPLEMENTATION_CONFIGURATION_NAME, playPlatform.getDependencyNotation("play-test").get()); dependencies.add(RUNTIME_CLASSPATH_CONFIGURATION_NAME, playPlatform.getDependencyNotation("play-docs").get()); PlayMajorVersion playMajorVersion = PlayMajorVersion.forPlatform(playPlatform); switch (playMajorVersion) { // This has the downside of adding play-java-forms for all kind of play projects // including Scala based projects. Still, users can exclude the dependency if they // want/need. Maybe in the future we can enable users to have some flag to specify // if the project is Java or Scala based. case PLAY_2_6_X: case PLAY_2_7_X: dependencies.add(PLATFORM_CONFIGURATION, playPlatform.getDependencyNotation("play-java-forms").get()); } }
Example #5
Source File: GradleProjectTest.java From jig with Apache License 2.0 | 6 votes |
private static Project _3階層構造でimplementation依存Javaプロジェクトが2つあるJavaプロジェクト(Path tempDir) { Project root = javaProjectOf("3階層構造でimplementation依存Javaプロジェクトが2つあるJavaプロジェクト", tempDir); DependencyHandler dependencies = root.getDependencies(); ProjectInternal javaChild = javaProjectOf("javaChild", tempDir); Stream<ProjectInternal> children = Stream.of( projectOf("nonJavaChild", tempDir), javaChild ); children .map(GradleProjectTest::dependencyOf) .forEach(dependency -> dependencies.add("implementation", dependency)); DependencyHandler javaChildDependencies = javaChild.getDependencies(); Stream<ProjectInternal> grandsons = Stream.of( projectOf("nonJavaGrandson", tempDir), javaProjectOf("javaGrandson", tempDir) ); grandsons .map(GradleProjectTest::dependencyOf) .forEach(dependency -> javaChildDependencies.add("implementation", dependency)); return root; }
Example #6
Source File: GradleProjectTest.java From jig with Apache License 2.0 | 6 votes |
private static Project _3階層構造でcompile依存Javaプロジェクトが2つあるJavaプロジェクト(Path tempDir) { Project root = javaProjectOf("3階層構造でcompile依存Javaプロジェクトが2つあるJavaプロジェクト", tempDir); DependencyHandler dependencies = root.getDependencies(); ProjectInternal javaChild = javaProjectOf("javaChild", tempDir); Stream<ProjectInternal> children = Stream.of( projectOf("nonJavaChild", tempDir), javaChild ); children .map(GradleProjectTest::dependencyOf) .forEach(dependency -> dependencies.add("compile", dependency)); DependencyHandler javaChildDependencies = javaChild.getDependencies(); Stream<ProjectInternal> grandsons = Stream.of( projectOf("nonJavaGrandson", tempDir), javaProjectOf("javaGrandson", tempDir) ); grandsons .map(GradleProjectTest::dependencyOf) .forEach(dependency -> javaChildDependencies.add("compile", dependency)); return root; }
Example #7
Source File: SonarRunnerPlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
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); } } }); }
Example #8
Source File: IdeDependenciesExtractor.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
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; }
Example #9
Source File: AbstractScriptHandler.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
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); }
Example #10
Source File: JCenterPluginMapper.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
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()); } }
Example #11
Source File: DefaultScriptHandler.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
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); }
Example #12
Source File: DefaultScriptHandlerFactory.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
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)); }
Example #13
Source File: DefaultDependencyManagementServices.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
DependencyHandler createDependencyHandler(Instantiator instantiator, ConfigurationContainerInternal configurationContainer, DependencyFactory dependencyFactory, ProjectFinder projectFinder, ComponentMetadataHandler componentMetadataHandler, ArtifactResolutionQueryFactory resolutionQueryFactory) { return instantiator.newInstance(DefaultDependencyHandler.class, configurationContainer, dependencyFactory, projectFinder, componentMetadataHandler, resolutionQueryFactory); }
Example #14
Source File: DefaultScriptHandler.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
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); }
Example #15
Source File: DefaultScriptHandler.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
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); }
Example #16
Source File: AbstractScriptHandler.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
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); }
Example #17
Source File: DefaultScriptHandlerFactory.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
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)); }
Example #18
Source File: DefaultDependencyManagementServices.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
DependencyHandler createDependencyHandler(Instantiator instantiator, ConfigurationContainerInternal configurationContainer, DependencyFactory dependencyFactory, ProjectFinder projectFinder, ComponentMetadataHandler componentMetadataHandler, ArtifactResolutionQueryFactory resolutionQueryFactory) { return instantiator.newInstance(DefaultDependencyHandler.class, configurationContainer, dependencyFactory, projectFinder, componentMetadataHandler, resolutionQueryFactory); }
Example #19
Source File: JCenterPluginMapper.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
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()); } }
Example #20
Source File: AbstractScriptHandler.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
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); }
Example #21
Source File: DefaultScriptHandler.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
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); }
Example #22
Source File: AbstractScriptHandler.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
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); }
Example #23
Source File: JapicmpTask.java From japicmp-gradle-plugin with Apache License 2.0 | 5 votes |
private Configuration resolveJaxb() { Project project = getProject(); DependencyHandler dependencies = project.getDependencies(); return project.getConfigurations().detachedConfiguration( dependencies.create("javax.xml.bind:jaxb-api:2.3.0"), dependencies.create("com.sun.xml.bind:jaxb-core:2.3.0.1"), dependencies.create("com.sun.xml.bind:jaxb-impl:2.3.0.1"), dependencies.create("javax.activation:activation:1.1.1") ); }
Example #24
Source File: DefaultScriptHandlerFactory.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
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)); }
Example #25
Source File: AtlasDependencyGraph.java From atlas with Apache License 2.0 | 5 votes |
private static void handleSources( @NonNull Project project, @NonNull Set<ComponentIdentifier> artifacts, @NonNull Consumer<SyncIssue> failureConsumer) { final DependencyHandler dependencies = project.getDependencies(); try { ArtifactResolutionQuery query = dependencies.createArtifactResolutionQuery(); query.forComponents(artifacts); @SuppressWarnings("unchecked") Class<? extends Artifact>[] artifactTypesArray = (Class<? extends Artifact>[]) new Class<?>[] {SourcesArtifact.class}; query.withArtifacts(JvmLibrary.class, artifactTypesArray); query.execute().getResolvedComponents(); } catch (Throwable t) { DependencyFailureHandlerKt.processDependencyThrowable( t, s -> null, (data, messages) -> failureConsumer.accept( new SyncIssueImpl( SyncIssue.TYPE_GENERIC, SyncIssue.SEVERITY_WARNING, null, String.format( "Unable to download sources: %s", messages.get(0)), messages))); } }
Example #26
Source File: IdeDependenciesExtractor.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
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()); } } } } }
Example #27
Source File: AbstractThorntailPlugin.java From thorntail with Apache License 2.0 | 5 votes |
/** * Convenience method for adding a dependency identified by the specified GAV coordinates to the given configuration. * * @param configuration the name of the configuration. * @param gav the GAV coordinates. */ protected void addDependency(String configuration, String gav) { final ConfigurationContainer cfgContainer = project.getConfigurations(); DependencyHandler handler = project.getDependencies(); // Add the bootstrap library to the runtime classpath. if (cfgContainer.findByName(configuration) != null) { handler.add(configuration, gav); } else { System.err.printf("Unable to lookup configuration by name: %s, Thorntail integration might not work.%n", configuration); } }
Example #28
Source File: MeecrowavePlugin.java From openwebbeans-meecrowave with Apache License 2.0 | 5 votes |
@Override public void apply(final Project project) { project.getExtensions().create(NAME, MeecrowaveExtension.class); project.afterEvaluate(actionProject -> { final MeecrowaveExtension extension = MeecrowaveExtension.class.cast(actionProject.getExtensions().findByName(NAME)); if (extension != null && extension.isSkipMavenCentral()) { return; } actionProject.getRepositories().mavenCentral(); }); final Configuration configuration = project.getConfigurations().maybeCreate(NAME); configuration.getIncoming().beforeResolve(resolvableDependencies -> { String version; try { final String resource = "META-INF/maven/org.apache.meecrowave/meecrowave-gradle-plugin/pom.properties"; try (final InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource)) { final Properties p = new Properties(); p.load(is); version = p.getProperty("version"); } } catch (final IOException e) { throw new IllegalStateException(e); } final DependencyHandler dependencyHandler = project.getDependencies(); final DependencySet dependencies = configuration.getDependencies(); dependencies.add(dependencyHandler.create("org.apache.meecrowave:meecrowave-core:" + version)); }); project.task(new HashMap<String, Object>() {{ put("type", MeecrowaveTask.class); put("group", "Embedded Application Server"); put("description", "Starts a meecrowave!"); }}, NAME); }
Example #29
Source File: IdeDependenciesExtractor.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
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()); } } } } }
Example #30
Source File: DefaultScriptHandlerFactory.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
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)); }