@Override public void triggerWhenEmptyActionsIfNecessary() { if (!defaultDependencyActions.isEmpty()) { for (Action<? super DependencySet> action : defaultDependencyActions) { if (!dependencies.isEmpty()) { break; } action.execute(dependencies); } } // Discard actions defaultDependencyActions.clear(); for (Configuration superConfig : extendsFrom) { ((ConfigurationInternal) superConfig).triggerWhenEmptyActionsIfNecessary(); } }
/** * Configures the classpath for Jacoco tasks using the 'jacocoAnt' configuration. Uses the version information declared in 'toolVersion' of the Jacoco extension if no dependencies are explicitly * declared. * * @param extension the JacocoPluginExtension */ private void configureTaskClasspathDefaults(final JacocoPluginExtension extension) { final Configuration config = this.project.getConfigurations().getAt(ANT_CONFIGURATION_NAME); project.getTasks().withType(JacocoBase.class, new Action<JacocoBase>() { @Override public void execute(JacocoBase task) { ((IConventionAware) task).getConventionMapping().map("jacocoClasspath", Callables.returning(config)); } }); config.defaultDependencies(new Action<DependencySet>() { @Override public void execute(DependencySet dependencies) { dependencies.add(project.getDependencies().create("org.jacoco:org.jacoco.ant:" + extension.getToolVersion())); } }); }
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; }
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); } } }); }
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(); }
private static void dependencies(Node node, Project project) { final Configuration runtime = project.getConfigurations().findByName("runtime"); if (runtime != null) { final DependencySet allDependencies = runtime.getAllDependencies(); if (!allDependencies.isEmpty()) { final Node dependenciesNode = node.appendNode("dependencies"); for (Dependency dependency : allDependencies) { if (dependency.getGroup() != null) { final Node dependencyNode = dependenciesNode.appendNode("dependency"); dependencyNode.appendNode("groupId", dependency.getGroup()); dependencyNode.appendNode("artifactId", dependency.getName()); dependencyNode.appendNode("version", dependency.getVersion()); } else { LOG.warn("There is a \"null\" dependency (likely pointing directly to a file): ignoring it for the POM generation for {}", project); } } } else { LOG.info("There are no dependencies in the \"runtime\" configuration for {}", project); } } else { LOG.info("There is no \"runtime\" configuration, so not adding any dependencies to the generated POM for {}", project); } }
private void configureDefaultDependencies(Configuration configuration) { configuration.defaultDependencies(new Action<DependencySet>() { @Override public void execute(DependencySet dependencies) { dependencies.add(project.getDependencies().create("jdepend:jdepend:" + extension.getToolVersion())); dependencies.add(project.getDependencies().create("org.apache.ant:ant-jdepend:1.9.6")); } }); }
private void configureDefaultDependencies(Configuration configuration) { configuration.defaultDependencies(new Action<DependencySet>() { @Override public void execute(DependencySet dependencies) { VersionNumber version = VersionNumber.parse(extension.getToolVersion()); String dependency = calculateDefaultDependencyNotation(version); dependencies.add(project.getDependencies().create(dependency)); } }); }
private void configureDefaultDependencies(Configuration configuration) { configuration.defaultDependencies(new Action<DependencySet>() { @Override public void execute(DependencySet dependencies) { dependencies.add(project.getDependencies().create("com.google.code.findbugs:findbugs:" + extension.getToolVersion())); } }); }
private void configureDefaultDependencies(Configuration configuration) { configuration.defaultDependencies(new Action<DependencySet>() { @Override public void execute(DependencySet dependencies) { dependencies.add(project.getDependencies().create("com.puppycrawl.tools:checkstyle:" + extension.getToolVersion())); } }); }
private void configureDefaultDependencies(Configuration configuration) { configuration.defaultDependencies(new Action<DependencySet>() { @Override public void execute(DependencySet dependencies) { dependencies.add(project.getDependencies().create("org.codenarc:CodeNarc:" + extension.getToolVersion())); } }); }
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; }
/** * Configures the agent dependencies using the 'jacocoAnt' configuration. Uses the version declared in 'toolVersion' of the Jacoco extension if no dependencies are explicitly declared. * * @param extension the extension that has the tool version to use */ private void configureAgentDependencies(JacocoAgentJar jacocoAgentJar, final JacocoPluginExtension extension) { Configuration config = project.getConfigurations().getAt(AGENT_CONFIGURATION_NAME); ((IConventionAware) jacocoAgentJar).getConventionMapping().map("agentConf", Callables.returning(config)); config.defaultDependencies(new Action<DependencySet>() { @Override public void execute(DependencySet dependencies) { dependencies.add(project.getDependencies().create("org.jacoco:org.jacoco.agent:" + extension.getToolVersion())); } }); }
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; }
private Collection<ResolvedArtifact> doResolve(final Collection<ArtifactSpec> deps, boolean transitive) { final Configuration config = this.project.getConfigurations().detachedConfiguration().setTransitive(transitive); final DependencySet dependencySet = config.getDependencies(); deps.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); dependencySet.add(d); } }); if (transitive) { return config .getResolvedConfiguration() .getResolvedArtifacts(); } return config .getResolvedConfiguration() .getFirstLevelModuleDependencies() .stream() .map(dep -> dep.getModuleArtifacts()) .flatMap(artifacts -> artifacts.stream()) .collect(Collectors.toList()); }
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")); } }); }
public TasksFromProjectDependencies(String taskName, DependencySet dependencies, ProjectAccessListener projectAccessListener) { this.taskName = taskName; this.dependencies = dependencies; this.projectAccessListener = projectAccessListener; }
@Override public Configuration defaultDependencies(Action<? super DependencySet> action) { validateMutation(MutationType.DEPENDENCIES); this.defaultDependencyActions.add(action); return this; }
public DependencySet getDependencies() { return dependencies; }
public DependencySet getAllDependencies() { return allDependencies; }
public DependencySet getDependencies() { return getAllDependencies(); }
@Override public Set<? extends RenderableDependency> getChildren() { final DependencySet dependencies = configuration.getDependencies(); if (dependencies.isEmpty()) { return Collections.emptySet(); } Set<RenderableDependency> children = Sets.newLinkedHashSet(); for (final Dependency dependency : dependencies) { children.add(new RenderableDependency() { @Override public Object getId() { return dependency; } @Override public String getName() { String label; if (dependency instanceof ProjectDependency) { label = "project " + dependency.getName(); } else { label = Joiner.on(":").join(Iterables.filter(Arrays.asList(dependency.getGroup(), dependency.getName(), dependency.getVersion()), Predicates.<String>notNull())); } return label; } @Override public String getDescription() { return null; } @Override public ResolutionState getResolutionState() { return ResolutionState.UNRESOLVED; } @Override public Set<? extends RenderableDependency> getChildren() { return Collections.emptySet(); } }); } return children; }
public JavaLibrary(PublishArtifact jarArtifact, DependencySet runtimeDependencies) { artifacts.add(jarArtifact); this.runtimeDependencies = runtimeDependencies; }
public AndroidComponent(Configuration compileConfiguration, DependencySet compileDependencies) { this.compileConfiguration = compileConfiguration; this.compileDependencies = compileDependencies; }
public TasksFromProjectDependencies(String taskName, DependencySet dependencies) { this.taskName = taskName; this.dependencies = dependencies; }
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); } } }); }