use of org.gradle.api.artifacts.Configuration in project gradle by gradle.
the class ArtifactRepositoryPluginResolver method exists.
/*
* Checks whether the implementation artifact exists in the backing artifact repository.
*/
private boolean exists(PluginRequestInternal request) {
Dependency dependency = resolution.getDependencyHandler().create(getMarkerDependency(request));
ConfigurationContainer configurations = resolution.getConfigurationContainer();
Configuration configuration = configurations.detachedConfiguration(dependency);
configuration.setTransitive(false);
return !configuration.getResolvedConfiguration().hasError();
}
use of org.gradle.api.artifacts.Configuration in project gradle by gradle.
the class WarPlugin method apply.
public void apply(final Project project) {
project.getPluginManager().apply(JavaPlugin.class);
final WarPluginConvention pluginConvention = new WarPluginConvention(project);
project.getConvention().getPlugins().put("war", pluginConvention);
project.getTasks().withType(War.class, new Action<War>() {
public void execute(War task) {
task.from(new Callable() {
public Object call() throws Exception {
return pluginConvention.getWebAppDir();
}
});
task.dependsOn(new Callable() {
public Object call() throws Exception {
return project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getRuntimeClasspath();
}
});
task.classpath(new Object[] { new Callable() {
public Object call() throws Exception {
FileCollection runtimeClasspath = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getRuntimeClasspath();
Configuration providedRuntime = project.getConfigurations().getByName(PROVIDED_RUNTIME_CONFIGURATION_NAME);
return runtimeClasspath.minus(providedRuntime);
}
} });
}
});
War war = project.getTasks().create(WAR_TASK_NAME, War.class);
war.setDescription("Generates a war archive with all the compiled classes, the web-app content and the libraries.");
war.setGroup(BasePlugin.BUILD_GROUP);
ArchivePublishArtifact warArtifact = new ArchivePublishArtifact(war);
project.getExtensions().getByType(DefaultArtifactPublicationSet.class).addCandidate(warArtifact);
configureConfigurations(project.getConfigurations());
configureComponent(project, warArtifact);
}
use of org.gradle.api.artifacts.Configuration in project gradle by gradle.
the class JavaLibraryPlugin method addApiToMainSourceSet.
private void addApiToMainSourceSet(JavaPluginConvention convention, ConfigurationContainer configurations) {
SourceSet sourceSet = convention.getSourceSets().getByName("main");
Configuration apiConfiguration = configurations.maybeCreate(sourceSet.getApiConfigurationName());
apiConfiguration.setVisible(false);
apiConfiguration.setDescription("API dependencies for " + sourceSet + ".");
apiConfiguration.setCanBeResolved(false);
apiConfiguration.setCanBeConsumed(false);
Configuration apiElementsConfiguration = configurations.getByName(sourceSet.getApiElementsConfigurationName());
apiElementsConfiguration.extendsFrom(apiConfiguration);
// Use a magic type to move the Jar variants out of the way so that the classes variant is used instead
apiElementsConfiguration.getOutgoing().getAttributes().attribute(ArtifactAttributes.ARTIFACT_FORMAT, JavaPlugin.NON_DEFAULT_JAR_TYPE);
Configuration implementationConfiguration = configurations.getByName(sourceSet.getImplementationConfigurationName());
implementationConfiguration.extendsFrom(apiConfiguration);
Configuration compileConfiguration = configurations.getByName(sourceSet.getCompileConfigurationName());
apiConfiguration.extendsFrom(compileConfiguration);
}
use of org.gradle.api.artifacts.Configuration in project gradle by gradle.
the class BasePlugin method configureConfigurations.
private void configureConfigurations(final Project project) {
ConfigurationContainer configurations = project.getConfigurations();
project.setStatus("integration");
Configuration archivesConfiguration = configurations.maybeCreate(Dependency.ARCHIVES_CONFIGURATION).setDescription("Configuration for archive artifacts.");
configurations.maybeCreate(Dependency.DEFAULT_CONFIGURATION).setDescription("Configuration for default artifacts.");
final DefaultArtifactPublicationSet defaultArtifacts = project.getExtensions().create("defaultArtifacts", DefaultArtifactPublicationSet.class, archivesConfiguration.getArtifacts());
configurations.all(new Action<Configuration>() {
public void execute(Configuration configuration) {
configuration.getArtifacts().all(new Action<PublishArtifact>() {
public void execute(PublishArtifact artifact) {
defaultArtifacts.addCandidate(artifact);
}
});
}
});
}
use of org.gradle.api.artifacts.Configuration in project gradle by gradle.
the class DefaultConfiguration method extendsFrom.
public Configuration extendsFrom(Configuration... extendsFrom) {
validateMutation(MutationType.DEPENDENCIES);
for (Configuration configuration : extendsFrom) {
if (configuration.getHierarchy().contains(this)) {
throw new InvalidUserDataException(String.format("Cyclic extendsFrom from %s and %s is not allowed. See existing hierarchy: %s", this, configuration, configuration.getHierarchy()));
}
if (this.extendsFrom.add(configuration)) {
inheritedArtifacts.addCollection(configuration.getAllArtifacts());
inheritedDependencies.addCollection(configuration.getAllDependencies());
((ConfigurationInternal) configuration).addMutationValidator(parentMutationValidator);
}
}
return this;
}
Aggregations