use of org.gradle.api.artifacts.DependencySet in project gradle by gradle.
the class JacocoPlugin method configureTaskClasspathDefaults.
/**
* 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()));
}
});
}
use of org.gradle.api.artifacts.DependencySet in project gradle by gradle.
the class CoffeeScriptBasePlugin method addJsConfiguration.
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;
}
use of org.gradle.api.artifacts.DependencySet in project gradle by gradle.
the class UnresolvableConfigurationResult method getChildren.
@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;
}
use of org.gradle.api.artifacts.DependencySet in project tomee by apache.
the class TomEEEmbeddedPlugin method apply.
@Override
public void apply(final Project project) {
final List<String> extensions = asList(TomEEEmbeddedExtension.NAME, TomEEEmbeddedExtension.ALIAS);
for (final String name : extensions) {
project.getExtensions().create(name, TomEEEmbeddedExtension.class);
}
project.afterEvaluate(new Action<Project>() {
@Override
public void execute(final Project actionProject) {
for (final String name : extensions) {
final TomEEEmbeddedExtension extension = TomEEEmbeddedExtension.class.cast(actionProject.getExtensions().findByName(name));
if (extension == null) {
return;
}
if (extension.isSkipDefaultRepository() != null && !extension.isSkipDefaultRepository()) {
actionProject.getRepositories().mavenCentral();
return;
}
}
actionProject.getRepositories().mavenCentral();
}
});
String configName = TomEEEmbeddedExtension.ALIAS;
try {
project.getConfigurations().getByName(configName);
} catch (final UnknownConfigurationException uce) {
configName = TomEEEmbeddedExtension.NAME;
}
final Configuration configuration = project.getConfigurations().maybeCreate(configName);
configuration.getIncoming().beforeResolve(new Action<ResolvableDependencies>() {
@Override
public void execute(final ResolvableDependencies resolvableDependencies) {
String tomeeVersion = null;
for (final String name : extensions) {
final TomEEEmbeddedExtension extension = TomEEEmbeddedExtension.class.cast(project.getExtensions().findByName(name));
if (extension == null) {
return;
}
tomeeVersion = extension.getTomeeVersion();
if (tomeeVersion != null) {
break;
}
}
if (tomeeVersion == null) {
try {
try (final InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/maven/org.apache.tomee.gradle/tomee-embedded/pom.properties")) {
final Properties p = new Properties();
p.load(is);
tomeeVersion = p.getProperty("version");
}
} catch (final IOException e) {
// we should never be there
tomeeVersion = "7.0.2";
}
}
final DependencyHandler dependencyHandler = project.getDependencies();
final DependencySet dependencies = configuration.getDependencies();
dependencies.add(dependencyHandler.create("org.apache.tomee:tomee-embedded:" + tomeeVersion));
}
});
project.task(new HashMap<String, Object>() {
{
put("type", TomEEEmbeddedTask.class);
put("group", "Embedded Application Server");
put("description", "Start an embedded Apache TomEE server deploying application classpath");
}
}, TomEEEmbeddedExtension.NAME);
}
use of org.gradle.api.artifacts.DependencySet in project gradle by gradle.
the class AntlrPlugin method apply.
public void apply(final Project project) {
project.getPluginManager().apply(JavaPlugin.class);
// set up a configuration named 'antlr' for the user to specify the antlr libs to use in case
// they want a specific version etc.
final Configuration antlrConfiguration = project.getConfigurations().create(ANTLR_CONFIGURATION_NAME).setVisible(false).setDescription("The Antlr libraries to be used for this project.");
antlrConfiguration.defaultDependencies(new Action<DependencySet>() {
@Override
public void execute(DependencySet dependencies) {
dependencies.add(project.getDependencies().create("antlr:antlr:2.7.7@jar"));
}
});
project.getConfigurations().getByName(COMPILE_CONFIGURATION_NAME).extendsFrom(antlrConfiguration);
// Wire the antlr configuration into all antlr tasks
project.getTasks().withType(AntlrTask.class, new Action<AntlrTask>() {
public void execute(AntlrTask antlrTask) {
antlrTask.getConventionMapping().map("antlrClasspath", new Callable<Object>() {
public Object call() throws Exception {
return project.getConfigurations().getByName(ANTLR_CONFIGURATION_NAME);
}
});
}
});
project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(new Action<SourceSet>() {
public void execute(SourceSet sourceSet) {
// for each source set we will:
// 1) Add a new 'antlr' virtual directory mapping
final AntlrSourceVirtualDirectoryImpl antlrDirectoryDelegate = new AntlrSourceVirtualDirectoryImpl(((DefaultSourceSet) sourceSet).getDisplayName(), sourceDirectorySetFactory);
new DslObject(sourceSet).getConvention().getPlugins().put(AntlrSourceVirtualDirectory.NAME, antlrDirectoryDelegate);
final String srcDir = "src/" + sourceSet.getName() + "/antlr";
antlrDirectoryDelegate.getAntlr().srcDir(srcDir);
sourceSet.getAllSource().source(antlrDirectoryDelegate.getAntlr());
// 2) create an AntlrTask for this sourceSet following the gradle
// naming conventions via call to sourceSet.getTaskName()
final String taskName = sourceSet.getTaskName("generate", "GrammarSource");
AntlrTask antlrTask = project.getTasks().create(taskName, AntlrTask.class);
antlrTask.setDescription("Processes the " + sourceSet.getName() + " Antlr grammars.");
// 3) set up convention mapping for default sources (allows user to not have to specify)
antlrTask.setSource(antlrDirectoryDelegate.getAntlr());
// 4) Set up the Antlr output directory (adding to javac inputs!)
final String outputDirectoryName = project.getBuildDir() + "/generated-src/antlr/" + sourceSet.getName();
final File outputDirectory = new File(outputDirectoryName);
antlrTask.setOutputDirectory(outputDirectory);
sourceSet.getJava().srcDir(outputDirectory);
// 6) register fact that antlr should be run before compiling
project.getTasks().getByName(sourceSet.getCompileJavaTaskName()).dependsOn(taskName);
}
});
}
Aggregations