use of org.gradle.api.internal.tasks.DefaultSourceSetOutput in project gradle by gradle.
the class DefaultJvmPluginServices method registerClassesDirVariant.
private void registerClassesDirVariant(final SourceSet sourceSet, Configuration configuration) {
// Define a classes variant to use for compilation
ConfigurationPublications publications = configuration.getOutgoing();
ConfigurationVariantInternal variant = (ConfigurationVariantInternal) publications.getVariants().maybeCreate("classes");
variant.setDescription("Directories containing compiled class files for " + sourceSet.getName() + ".");
variant.getAttributes().attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objectFactory.named(LibraryElements.class, LibraryElements.CLASSES));
variant.artifactsProvider(new Factory<List<PublishArtifact>>() {
@Nullable
@Override
public List<PublishArtifact> create() {
Set<File> classesDirs = sourceSet.getOutput().getClassesDirs().getFiles();
DefaultSourceSetOutput output = Cast.uncheckedCast(sourceSet.getOutput());
TaskDependency classesContributors = output.getClassesContributors();
ImmutableList.Builder<PublishArtifact> artifacts = ImmutableList.builderWithExpectedSize(classesDirs.size());
for (File classesDir : classesDirs) {
// this is an approximation: all "compiled" sources will use the same task dependency
artifacts.add(new JvmPluginsHelper.IntermediateJavaArtifact(ArtifactTypeDefinition.JVM_CLASS_DIRECTORY, classesContributors) {
@Override
public File getFile() {
return classesDir;
}
});
}
return artifacts.build();
}
});
}
Aggregations