org.gradle.api.artifacts.DependencySet Java Examples
The following examples show how to use
org.gradle.api.artifacts.DependencySet.
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: GradleArtifactResolvingHelper.java From ARCHIVE-wildfly-swarm with Apache License 2.0 | 6 votes |
private Set<ResolvedDependency> doResolve(final Collection<ArtifactSpec> deps) { final Configuration config = this.project.getConfigurations().detachedConfiguration(); final DependencySet dependencySet = config.getDependencies(); deps.forEach(spec -> { final DefaultExternalModuleDependency d = new DefaultExternalModuleDependency(spec.groupId(), spec.artifactId(), spec.version()); final DefaultDependencyArtifact da = new DefaultDependencyArtifact(spec.artifactId(), spec.type(), spec.type(), spec.classifier(), null); d.addArtifact(da); d.getExcludeRules().add(new DefaultExcludeRule()); dependencySet.add(d); }); return config.getResolvedConfiguration().getFirstLevelModuleDependencies(); }
Example #2
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 #3
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 #4
Source File: CodeServerBuilder.java From putnami-gradle-plugin with GNU Lesser General Public License v3.0 | 6 votes |
private Collection<File> listProjectDepsSrcDirs(Project project) { ConfigurationContainer configs = project.getConfigurations(); Configuration compileConf = configs.getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME); DependencySet depSet = compileConf.getAllDependencies(); List<File> result = Lists.newArrayList(); for (Dependency dep : depSet) { if (dep instanceof ProjectDependency) { Project projectDependency = ((ProjectDependency) dep).getDependencyProject(); if (projectDependency.getPlugins().hasPlugin(PwtLibPlugin.class)) { JavaPluginConvention javaConvention = projectDependency.getConvention().getPlugin(JavaPluginConvention.class); SourceSet mainSourceSet = javaConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); result.addAll(mainSourceSet.getAllSource().getSrcDirs()); } } } return result; }
Example #5
Source File: SmokeTestsPlugin.java From firebase-android-sdk with Apache License 2.0 | 6 votes |
private static void getChangedProjectsLoop(Collection<Project> projects, Set<Project> changed) { for (Project p : projects) { // Skip project if it is not a Firebase library. if (p.getExtensions().findByType(FirebaseLibraryExtension.class) == null) { continue; } // Skip processing and recursion if this project has already been added to the set. if (!changed.add(p)) { continue; } // Find all (head) dependencies to other projects in this repository. DependencySet all = p.getConfigurations().getByName("releaseRuntimeClasspath").getAllDependencies(); Set<Project> affected = all.stream() .filter(it -> it instanceof ProjectDependency) .map(it -> (ProjectDependency) it) .map(ProjectDependency::getDependencyProject) .collect(Collectors.toSet()); // Recurse with the new dependencies. getChangedProjectsLoop(affected, changed); } }
Example #6
Source File: GradleProject.java From jig with Apache License 2.0 | 6 votes |
private Stream<Project> allDependencyProjectsFrom(Project root) { if (isNonJavaProject(root)) { return Stream.empty(); } //FIXME: 誰かcompileとimplementation両方が取得できるより良い方法があれば DependencySet compileDependencies = root.getConfigurations().getByName("compile").getAllDependencies(); DependencySet implementationDependencies = root.getConfigurations().getByName("implementation").getAllDependencies(); Stream<Project> descendantStream = Stream.concat(compileDependencies.stream(), implementationDependencies.stream()) .filter(dependency -> ProjectDependency.class.isAssignableFrom(dependency.getClass())) .map(ProjectDependency.class::cast) .map(ProjectDependency::getDependencyProject) .flatMap(this::allDependencyProjectsFrom); return Stream.concat(Stream.of(root), descendantStream); }
Example #7
Source File: GradleArtifactResolvingHelper.java From wildfly-swarm with Apache License 2.0 | 6 votes |
private Set<ResolvedDependency> doResolve(final Collection<ArtifactSpec> deps) { final Configuration config = this.project.getConfigurations().detachedConfiguration(); final DependencySet dependencySet = config.getDependencies(); deps.stream() .forEach(spec -> { if (projects.containsKey(spec.groupId() + ":" + spec.artifactId() + ":" + spec.version())) { dependencySet.add(new DefaultProjectDependency((ProjectInternal) projects.get(spec.groupId() + ":" + spec.artifactId() + ":" + spec.version()), new DefaultProjectAccessListener(), false)); } else { final DefaultExternalModuleDependency d = new DefaultExternalModuleDependency(spec.groupId(), spec.artifactId(), spec.version()); final DefaultDependencyArtifact da = new DefaultDependencyArtifact(spec.artifactId(), spec.type(), spec.type(), spec.classifier(), null); d.addArtifact(da); d.getExcludeRules().add(new DefaultExcludeRule()); dependencySet.add(d); } }); return config.getResolvedConfiguration().getFirstLevelModuleDependencies(); }
Example #8
Source File: AndroidComponent.java From atlas with Apache License 2.0 | 5 votes |
public AndroidComponent(Configuration compileConfiguration, DependencySet compileDependencies, Project project) { this.compileConfiguration = compileConfiguration; this.compileDependencies = compileDependencies; this.project = project; ObjectFactory factory = project.getObjects(); apiUsage = factory.named(Usage.class, Usage.JAVA_API); runtimeUsage = factory.named(Usage.class, Usage.JAVA_RUNTIME); }
Example #9
Source File: JavaccPlugin.java From javaccPlugin with MIT License | 5 votes |
private void configureDefaultJavaccDependency(final Project project, Configuration configuration) { configuration.defaultDependencies(new Action<DependencySet>() { @Override public void execute(DependencySet dependencies) { dependencies.add(project.getDependencies().create("net.java.dev.javacc:javacc:6.1.2")); } }); }
Example #10
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 #11
Source File: ConfigBuild.java From client-gradle-plugin with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void build() { ProjectConfiguration clientConfig = createSubstrateConfiguration(); boolean result; try { String mainClassName = clientConfig.getMainClassName(); String name = clientConfig.getAppName(); for (org.gradle.api.artifacts.Configuration configuration : project.getBuildscript().getConfigurations()) { project.getLogger().debug("Configuration = " + configuration); DependencySet deps = configuration.getAllDependencies(); project.getLogger().debug("Dependencies = " + deps); deps.forEach(dep -> project.getLogger().debug("Dependency = " + dep)); } project.getLogger().debug("mainClassName = " + mainClassName + " and app name = " + name); Path buildRootPath = project.getLayout().getBuildDirectory().dir("client").get().getAsFile().toPath(); project.getLogger().debug("BuildRoot: " + buildRootPath); SubstrateDispatcher dispatcher = new SubstrateDispatcher(buildRootPath, clientConfig); result = dispatcher.nativeCompile(); } catch (Exception e) { throw new GradleException("Failed to compile", e); } if (!result) { throw new IllegalStateException("Compilation failed"); } }
Example #12
Source File: UpdatePomTask.java From atlas with Apache License 2.0 | 5 votes |
private Map<String, DependencyExtraInfo> getExtraMap() { Map<String, DependencyExtraInfo> dependencyExtraInfoMap = new HashMap<>(); DependencySet dependencies = project.getConfigurations().getByName("compile").getDependencies(); dependencies.forEach(new Consumer<Dependency>() { @Override public void accept(Dependency dependency) { String group = dependency.getGroup(); String name = dependency.getName(); String scope = "compile"; String type = ""; if (dependency instanceof DefaultProjectDependency) { DefaultProjectDependency projectDependency = (DefaultProjectDependency)dependency; if (projectDependency.getDependencyProject().getPlugins().hasPlugin(LibraryPlugin.class)) { type = "aar"; } } dependencyExtraInfoMap.put(group + ":" + name, new DependencyExtraInfo(type, scope)); } }); return dependencyExtraInfoMap; }
Example #13
Source File: NoHttpCheckstylePlugin.java From nohttp with Apache License 2.0 | 5 votes |
private void configureDefaultDependenciesForProject(Configuration configuration) { configuration.defaultDependencies(new Action<DependencySet>() { @Override public void execute(DependencySet dependencies) { NoHttpExtension extension = NoHttpCheckstylePlugin.this.extension; dependencies.add(NoHttpCheckstylePlugin.this.project.getDependencies().create("io.spring.nohttp:nohttp-checkstyle:" + extension.getToolVersion())); } }); }
Example #14
Source File: NoHttpCliPlugin.java From nohttp with Apache License 2.0 | 5 votes |
private void configureDefaultDependenciesForProject(Configuration configuration) { configuration.defaultDependencies(new Action<DependencySet>() { @Override public void execute(DependencySet dependencies) { NoHttpExtension extension = NoHttpCliPlugin.this.extension; dependencies.add(NoHttpCliPlugin.this.project.getDependencies().create("io.spring.nohttp:nohttp-cli:" + extension.getToolVersion())); } }); }
Example #15
Source File: GradleDependencyResolutionHelper.java From thorntail with Apache License 2.0 | 4 votes |
/** * Resolve the given artifact specifications. * * @param project the Gradle project reference. * @param specs the specifications that need to be resolved. * @param transitive should the artifacts be resolved transitively? * @param excludeDefaults should we skip resolving artifacts that belong to the Thorntail group? * @return collection of resolved artifact specifications. */ public static Set<ArtifactSpec> resolveArtifacts(Project project, Collection<ArtifactSpec> specs, boolean transitive, boolean excludeDefaults) { if (project == null) { throw new IllegalArgumentException("Gradle project reference cannot be null."); } if (specs == null) { project.getLogger().warn("Artifact specification collection is null."); return Collections.emptySet(); } // Early return if there is nothing to resolve. if (specs.isEmpty()) { return Collections.emptySet(); } final Configuration config = project.getConfigurations().detachedConfiguration().setTransitive(transitive); final DependencySet dependencySet = config.getDependencies(); final Map<String, Project> projectGAVCoordinates = getAllProjects(project); final ProjectAccessListener listener = new DefaultProjectAccessListener(); Set<ArtifactSpec> result = new HashSet<>(); specs.forEach(s -> { // 1. Do we need to resolve this entry? final String specGAV = String.format(GROUP_ARTIFACT_VERSION_FORMAT, s.groupId(), s.artifactId(), s.version()); boolean resolved = s.file != null; boolean projectEntry = projectGAVCoordinates.containsKey(specGAV); // 2. Should we skip this spec? if (excludeDefaults && FractionDescriptor.THORNTAIL_GROUP_ID.equals(s.groupId()) && !projectEntry) { return; } // 3. Should this entry be resolved? if (!resolved || transitive) { // a.) Does this entry represent a project dependency? if (projectGAVCoordinates.containsKey(specGAV)) { dependencySet.add(new DefaultProjectDependency((ProjectInternal) projectGAVCoordinates.get(specGAV), listener, false)); } else { DefaultExternalModuleDependency d = new DefaultExternalModuleDependency(s.groupId(), s.artifactId(), s.version()); DefaultDependencyArtifact da = new DefaultDependencyArtifact(s.artifactId(), s.type(), s.type(), s.classifier(), null); d.addArtifact(da); dependencySet.add(d); } } else { // 4. Nothing else to do, just add the spec to the result. result.add(s); } }); // 5. Are there any specs that need resolution? if (!dependencySet.isEmpty()) { config.getResolvedConfiguration().getResolvedArtifacts().stream() .map(ra -> asDescriptor("compile", ra).toArtifactSpec()) .forEach(result::add); } return result; }
Example #16
Source File: JavaLibrary.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public JavaLibrary(PublishArtifact jarArtifact, DependencySet runtimeDependencies) { artifacts.add(jarArtifact); this.runtimeDependencies = runtimeDependencies; }
Example #17
Source File: JavaLibrary.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public JavaLibrary(PublishArtifact jarArtifact, DependencySet runtimeDependencies) { artifacts.add(jarArtifact); this.runtimeDependencies = runtimeDependencies; }
Example #18
Source File: TasksFromProjectDependencies.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public TasksFromProjectDependencies(String taskName, DependencySet dependencies) { this.taskName = taskName; this.dependencies = dependencies; }
Example #19
Source File: TasksFromProjectDependencies.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public TasksFromProjectDependencies(String taskName, DependencySet dependencies) { this.taskName = taskName; this.dependencies = dependencies; }
Example #20
Source File: JavaLibrary.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public JavaLibrary(PublishArtifact jarArtifact, DependencySet runtimeDependencies) { artifacts.add(jarArtifact); this.runtimeDependencies = runtimeDependencies; }
Example #21
Source File: JavaLibrary.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public JavaLibrary(PublishArtifact jarArtifact, DependencySet runtimeDependencies) { artifacts.add(jarArtifact); this.runtimeDependencies = runtimeDependencies; }
Example #22
Source File: AtlasProjectDependencyManager.java From atlas with Apache License 2.0 | 3 votes |
public static void addProjectDependency(Project project, String variantName) { Task task = project.getTasks().findByName("prepare" + variantName + "Dependencies"); if (null == task){ return; } DependencySet dependencies = project.getConfigurations().getByName( AtlasPlugin.BUNDLE_COMPILE).getDependencies(); if (null == dependencies){ return; } dependencies.forEach(new Consumer<Dependency>() { @Override public void accept(Dependency dependency) { if (dependency instanceof DefaultProjectDependency){ Project subProject = ((DefaultProjectDependency)dependency).getDependencyProject(); Task assembleTask = subProject.getTasks().findByName("assembleRelease"); task.dependsOn(assembleTask); } } }); }