use of org.gradle.api.artifacts.PublishArtifact in project gradle by gradle.
the class EclipsePlugin method createArtifact.
private static LocalComponentArtifactMetadata createArtifact(String extension, ProjectComponentIdentifier projectId, String projectName, Project project) {
File projectFile = new File(project.getProjectDir(), "." + extension);
Task byName = project.getTasks().getByName("eclipseProject");
String type = "eclipse." + extension;
PublishArtifact publishArtifact = new DefaultPublishArtifact(projectName, extension, type, null, null, projectFile, byName);
return new PublishArtifactLocalArtifactMetadata(projectId, publishArtifact);
}
use of org.gradle.api.artifacts.PublishArtifact in project gradle by gradle.
the class JvmLocalLibraryMetaDataAdapter method createLocalComponentMetaData.
@Override
@SuppressWarnings("unchecked")
public DefaultLibraryLocalComponentMetadata createLocalComponentMetaData(Binary selectedBinary, String projectPath, boolean toAssembly) {
EnumMap<UsageKind, Iterable<DependencySpec>> dependenciesPerUsage = new EnumMap<UsageKind, Iterable<DependencySpec>>(UsageKind.class);
EnumMap<UsageKind, List<PublishArtifact>> artifacts = new EnumMap<UsageKind, List<PublishArtifact>>(UsageKind.class);
initializeUsages(dependenciesPerUsage, artifacts);
if (selectedBinary instanceof JarBinarySpecInternal) {
JarBinarySpecInternal jarBinarySpec = (JarBinarySpecInternal) selectedBinary;
createJarBinarySpecLocalComponentMetaData(artifacts, jarBinarySpec, dependenciesPerUsage, toAssembly);
}
if (selectedBinary instanceof WithJvmAssembly) {
// a local component that provides a JVM assembly
JvmAssembly assembly = ((WithJvmAssembly) selectedBinary).getAssembly();
createJvmAssemblyLocalComponentMetaData(artifacts, assembly, dependenciesPerUsage, toAssembly);
}
return createResolvedMetaData((BinarySpecInternal) selectedBinary, projectPath, dependenciesPerUsage, artifacts);
}
use of org.gradle.api.artifacts.PublishArtifact in project gradle by gradle.
the class IdeaPlugin method createImlArtifact.
private static LocalComponentArtifactMetadata createImlArtifact(ProjectComponentIdentifier projectId, Project project) {
String moduleName = project.getExtensions().getByType(IdeaModel.class).getModule().getName();
File imlFile = new File(project.getProjectDir(), moduleName + ".iml");
Task byName = project.getTasks().getByName("ideaModule");
PublishArtifact publishArtifact = new DefaultPublishArtifact(moduleName, "iml", "iml", null, null, imlFile, byName);
return new PublishArtifactLocalArtifactMetadata(projectId, publishArtifact);
}
use of org.gradle.api.artifacts.PublishArtifact in project gradle by gradle.
the class DefaultArtifactPom method addArtifact.
public void addArtifact(Artifact artifact, File src) {
throwExceptionIfArtifactOrSrcIsNull(artifact, src);
PublishArtifact publishArtifact = new MavenArtifact(artifact, src);
ArtifactKey artifactKey = new ArtifactKey(publishArtifact);
if (this.artifacts.containsKey(artifactKey)) {
throw new InvalidUserDataException(String.format("A POM cannot have multiple artifacts with the same type and classifier. Already have %s, trying to add %s.", this.artifacts.get(artifactKey), publishArtifact));
}
if (publishArtifact.getClassifier() != null) {
addArtifact(publishArtifact);
assignArtifactValuesToPom(artifact, pom, false);
return;
}
if (this.artifact != null) {
// Choose the 'main' artifact based on its type.
if (!PACKAGING_TYPES.contains(artifact.getType())) {
addArtifact(publishArtifact);
return;
}
if (PACKAGING_TYPES.contains(this.artifact.getType())) {
throw new InvalidUserDataException("A POM can not have multiple main artifacts. " + "Already have " + this.artifact + ", trying to add " + publishArtifact);
}
addArtifact(this.artifact);
}
this.artifact = publishArtifact;
this.artifacts.put(artifactKey, publishArtifact);
assignArtifactValuesToPom(artifact, pom, true);
}
use of org.gradle.api.artifacts.PublishArtifact in project gradle by gradle.
the class DefaultArtifactPomContainer method createDeployableFilesInfos.
public Set<MavenDeployment> createDeployableFilesInfos() {
Set<MavenDeployment> mavenDeployments = new HashSet<MavenDeployment>();
for (String activeArtifactPomName : artifactPoms.keySet()) {
ArtifactPom activeArtifactPom = artifactPoms.get(activeArtifactPomName);
File pomFile = createPomFile(activeArtifactPomName);
PublishArtifact pomArtifact = activeArtifactPom.writePom(pomFile);
mavenDeployments.add(new DefaultMavenDeployment(pomArtifact, activeArtifactPom.getArtifact(), activeArtifactPom.getAttachedArtifacts()));
}
return mavenDeployments;
}
Aggregations