Java Code Examples for org.gradle.api.artifacts.PublishArtifact
The following examples show how to use
org.gradle.api.artifacts.PublishArtifact. These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Pushjet-Android Source File: MavenArtifactNotationParserFactory.java License: BSD 2-Clause "Simplified" License | 6 votes |
public NotationParser<Object, MavenArtifact> create() { FileNotationParser fileNotationParser = new FileNotationParser(fileResolver); ArchiveTaskNotationParser archiveTaskNotationParser = new ArchiveTaskNotationParser(); PublishArtifactNotationParser publishArtifactNotationParser = new PublishArtifactNotationParser(); NotationParser<Object, MavenArtifact> sourceNotationParser = NotationParserBuilder .toType(MavenArtifact.class) .fromType(AbstractArchiveTask.class, archiveTaskNotationParser) .fromType(PublishArtifact.class, publishArtifactNotationParser) .converter(fileNotationParser) .toComposite(); MavenArtifactMapNotationParser mavenArtifactMapNotationParser = new MavenArtifactMapNotationParser(sourceNotationParser); NotationParserBuilder<MavenArtifact> parserBuilder = NotationParserBuilder .toType(MavenArtifact.class) .fromType(AbstractArchiveTask.class, archiveTaskNotationParser) .fromType(PublishArtifact.class, publishArtifactNotationParser) .parser(mavenArtifactMapNotationParser) .converter(fileNotationParser); return parserBuilder.toComposite(); }
Example 2
Source Project: Pushjet-Android Source File: DefaultMavenPublication.java License: BSD 2-Clause "Simplified" License | 6 votes |
public void from(SoftwareComponent component) { if (this.component != null) { throw new InvalidUserDataException(String.format("Maven publication '%s' cannot include multiple components", name)); } this.component = (SoftwareComponentInternal) component; for (Usage usage : this.component.getUsages()) { // TODO Need a smarter way to map usage to artifact classifier for (PublishArtifact publishArtifact : usage.getArtifacts()) { artifact(publishArtifact); } // TODO Need a smarter way to map usage to scope for (ModuleDependency dependency : usage.getDependencies()) { if (dependency instanceof ProjectDependency) { addProjectDependency((ProjectDependency) dependency); } else { addModuleDependency(dependency); } } } }
Example 3
Source Project: pushfish-android Source File: DefaultMavenPublication.java License: BSD 2-Clause "Simplified" License | 6 votes |
public void from(SoftwareComponent component) { if (this.component != null) { throw new InvalidUserDataException(String.format("Maven publication '%s' cannot include multiple components", name)); } this.component = (SoftwareComponentInternal) component; for (Usage usage : this.component.getUsages()) { // TODO Need a smarter way to map usage to artifact classifier for (PublishArtifact publishArtifact : usage.getArtifacts()) { artifact(publishArtifact); } // TODO Need a smarter way to map usage to scope for (ModuleDependency dependency : usage.getDependencies()) { if (dependency instanceof ProjectDependency) { addProjectDependency((ProjectDependency) dependency); } else { addModuleDependency(dependency); } } } }
Example 4
Source Project: Pushjet-Android Source File: PublishArtifactToFileBuildOutcomeTransformer.java License: BSD 2-Clause "Simplified" License | 5 votes |
private String getTypeIdentifier(PublishArtifact artifact) { if (artifact instanceof ArchivePublishArtifact) { ArchivePublishArtifact publishArtifact = (ArchivePublishArtifact) artifact; AbstractArchiveTask task = publishArtifact.getArchiveTask(); // There is an inheritance hierarchy in play here, so the order // of the clauses is very important. if (task instanceof War) { return WAR_ARTIFACT.getTypeIdentifier(); } else if (task instanceof Ear) { return EAR_ARTIFACT.getTypeIdentifier(); } else if (task instanceof Jar) { return JAR_ARTIFACT.getTypeIdentifier(); } else if (task instanceof Zip) { return ZIP_ARTIFACT.getTypeIdentifier(); } else if (task instanceof Tar) { return TAR_ARTIFACT.getTypeIdentifier(); } else { // we don't know about this kind of archive task return ARCHIVE_ARTIFACT.getTypeIdentifier(); } } else { // This could very well be a zip (or something else we understand), but we can't know for sure. // The client may try to infer from the file extension. return UNKNOWN_ARTIFACT.getTypeIdentifier(); } }
Example 5
Source Project: Pushjet-Android Source File: DefaultArtifactPomContainer.java License: BSD 2-Clause "Simplified" License | 5 votes |
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; }
Example 6
Source Project: pushfish-android Source File: PublishArtifactToFileBuildOutcomeTransformer.java License: BSD 2-Clause "Simplified" License | 5 votes |
public GradleFileBuildOutcome transform(PublishArtifact artifact, Project project) { String id = getId(artifact, project); String taskPath = getTaskPath(artifact); String description = getDescription(artifact); String typeIdentifier = getTypeIdentifier(artifact); return new DefaultGradleFileBuildOutcome(id, description, taskPath, artifact.getFile(), typeIdentifier); }
Example 7
Source Project: pushfish-android Source File: DefaultArtifactPom.java License: BSD 2-Clause "Simplified" License | 5 votes |
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); }
Example 8
Source Project: Pushjet-Android Source File: DefaultIvyPublication.java License: BSD 2-Clause "Simplified" License | 5 votes |
public void from(SoftwareComponent component) { if (this.component != null) { throw new InvalidUserDataException(String.format("Ivy publication '%s' cannot include multiple components", name)); } this.component = (SoftwareComponentInternal) component; configurations.maybeCreate("default"); for (Usage usage : this.component.getUsages()) { String conf = usage.getName(); configurations.maybeCreate(conf); configurations.getByName("default").extend(conf); for (PublishArtifact publishArtifact : usage.getArtifacts()) { artifact(publishArtifact).setConf(conf); } for (ModuleDependency dependency : usage.getDependencies()) { // TODO: When we support multiple components or configurable dependencies, we'll need to merge the confs of multiple dependencies with same id. String confMapping = String.format("%s->%s", conf, dependency.getConfiguration()); if (dependency instanceof ProjectDependency) { addProjectDependency((ProjectDependency) dependency, confMapping); } else { addModuleDependency(dependency, confMapping); } } } }
Example 9
Source Project: Pushjet-Android Source File: PublishArtifactToFileBuildOutcomeTransformer.java License: BSD 2-Clause "Simplified" License | 5 votes |
private String getId(PublishArtifact artifact, Project project) { // Assume that each artifact points to a unique file, and use the relative path from the project as the id URI artifactUri = artifact.getFile().toURI(); URI projectDirUri = project.getProjectDir().toURI(); URI relativeUri = projectDirUri.relativize(artifactUri); return relativeUri.getPath(); }
Example 10
Source Project: pushfish-android Source File: MavenArtifactNotationParserFactory.java License: BSD 2-Clause "Simplified" License | 5 votes |
public void convert(PublishArtifact publishArtifact, NotationConvertResult<? super MavenArtifact> result) throws TypeConversionException { DefaultMavenArtifact artifact = instantiator.newInstance( DefaultMavenArtifact.class, publishArtifact.getFile(), publishArtifact.getExtension(), publishArtifact.getClassifier()); artifact.builtBy(publishArtifact.getBuildDependencies()); result.converted(artifact); }
Example 11
Source Project: playframework Source File: PlayApplicationPlugin.java License: Apache License 2.0 | 5 votes |
private void registerOutgoingArtifact(Project project, TaskProvider<Jar> assetsJarTask) { Configuration runtimeElementsConfiguration = project.getConfigurations().getByName(RUNTIME_ELEMENTS_CONFIGURATION_NAME); PublishArtifact jarArtifact = new LazyPublishArtifact(assetsJarTask); ConfigurationPublications publications = runtimeElementsConfiguration.getOutgoing(); publications.getArtifacts().add(jarArtifact); publications.getAttributes().attribute(ArtifactAttributes.ARTIFACT_FORMAT, ArtifactTypeDefinition.JAR_TYPE); }
Example 12
Source Project: Pushjet-Android Source File: PublishArtifactNotationParserFactory.java License: BSD 2-Clause "Simplified" License | 5 votes |
public NotationParser<Object, PublishArtifact> create() { FileNotationParser fileParser = new FileNotationParser(); return NotationParserBuilder .toType(PublishArtifact.class) .parser(new ArchiveTaskNotationParser()) .parser(new FileMapNotationParser(fileParser)) .parser(fileParser) .toComposite(); }
Example 13
Source Project: pushfish-android Source File: PublishArtifactNotationParserFactory.java License: BSD 2-Clause "Simplified" License | 5 votes |
public NotationParser<Object, PublishArtifact> create() { FileNotationParser fileParser = new FileNotationParser(); return NotationParserBuilder .toType(PublishArtifact.class) .parser(new ArchiveTaskNotationParser()) .parser(new FileMapNotationParser(fileParser)) .parser(fileParser) .toComposite(); }
Example 14
Source Project: pushfish-android Source File: PublishArtifactNotationParserFactory.java License: BSD 2-Clause "Simplified" License | 5 votes |
@Override protected PublishArtifact parseType(File file) { Module module = metaDataProvider.getModule(); ArtifactFile artifactFile = new ArtifactFile(file, module.getVersion()); return instantiator.newInstance(DefaultPublishArtifact.class, artifactFile.getName(), artifactFile.getExtension(), artifactFile.getExtension() == null? "":artifactFile.getExtension(), artifactFile.getClassifier(), null, file, new Task[0]); }
Example 15
Source Project: pushfish-android Source File: PublishArtifactToFileBuildOutcomeTransformer.java License: BSD 2-Clause "Simplified" License | 5 votes |
public GradleFileBuildOutcome transform(PublishArtifact artifact, Project project) { String id = getId(artifact, project); String taskPath = getTaskPath(artifact); String description = getDescription(artifact); String typeIdentifier = getTypeIdentifier(artifact); return new DefaultGradleFileBuildOutcome(id, description, taskPath, artifact.getFile(), typeIdentifier); }
Example 16
Source Project: pushfish-android Source File: PublishArtifactToFileBuildOutcomeTransformer.java License: BSD 2-Clause "Simplified" License | 5 votes |
private String getId(PublishArtifact artifact, Project project) { // Assume that each artifact points to a unique file, and use the relative path from the project as the id URI artifactUri = artifact.getFile().toURI(); URI projectDirUri = project.getProjectDir().toURI(); URI relativeUri = projectDirUri.relativize(artifactUri); return relativeUri.getPath(); }
Example 17
Source Project: Pushjet-Android Source File: MavenArtifactNotationParserFactory.java License: BSD 2-Clause "Simplified" License | 5 votes |
public void convert(PublishArtifact publishArtifact, NotationConvertResult<? super MavenArtifact> result) throws TypeConversionException { DefaultMavenArtifact artifact = instantiator.newInstance( DefaultMavenArtifact.class, publishArtifact.getFile(), publishArtifact.getExtension(), publishArtifact.getClassifier()); artifact.builtBy(publishArtifact.getBuildDependencies()); result.converted(artifact); }
Example 18
Source Project: Pushjet-Android Source File: DefaultMavenDeployment.java License: BSD 2-Clause "Simplified" License | 5 votes |
public Set<PublishArtifact> getArtifacts() { Set<PublishArtifact> artifacts = new HashSet<PublishArtifact>(); artifacts.addAll(attachedArtifacts); if (mainArtifact != null) { artifacts.add(mainArtifact); } artifacts.add(pomArtifact); return artifacts; }
Example 19
Source Project: pushfish-android Source File: DefaultPublishArtifactSet.java License: BSD 2-Clause "Simplified" License | 5 votes |
public Set<File> getFiles() { Set<File> files = new LinkedHashSet<File>(); for (PublishArtifact artifact : DefaultPublishArtifactSet.this) { files.add(artifact.getFile()); } return files; }
Example 20
Source Project: Pushjet-Android Source File: MavenArtifactNotationParserFactory.java License: BSD 2-Clause "Simplified" License | 5 votes |
@Override protected MavenArtifact parseType(PublishArtifact publishArtifact) { DefaultMavenArtifact artifact = instantiator.newInstance( DefaultMavenArtifact.class, publishArtifact.getFile(), publishArtifact.getExtension(), publishArtifact.getClassifier()); artifact.builtBy(publishArtifact.getBuildDependencies()); return artifact; }
Example 21
Source Project: Pushjet-Android Source File: PublishArtifactToFileBuildOutcomeTransformer.java License: BSD 2-Clause "Simplified" License | 5 votes |
private String getTaskPath(PublishArtifact artifact) { if (artifact instanceof ArchivePublishArtifact) { return ((ArchivePublishArtifact) artifact).getArchiveTask().getPath(); } else { String taskPath = null; Set<? extends Task> tasks = artifact.getBuildDependencies().getDependencies(null); if (!tasks.isEmpty()) { taskPath = tasks.iterator().next().getPath(); } return taskPath; } }
Example 22
Source Project: Pushjet-Android Source File: DefaultConfigurationsToArtifactsConverter.java License: BSD 2-Clause "Simplified" License | 5 votes |
public void addArtifacts(MutableLocalComponentMetaData metaData, Iterable<? extends Configuration> configurations) { ModuleVersionIdentifier id = metaData.getId(); for (Configuration configuration : configurations) { for (PublishArtifact publishArtifact : configuration.getArtifacts()) { IvyArtifactName ivyArtifact = createIvyArtifact(publishArtifact, id); metaData.addArtifact(configuration.getName(), ivyArtifact, publishArtifact.getFile()); } } }
Example 23
Source Project: Pushjet-Android Source File: AbstractMavenResolver.java License: BSD 2-Clause "Simplified" License | 5 votes |
private void addPomAndArtifact(InstallDeployTaskSupport installOrDeployTask, MavenDeployment mavenDeployment) { Pom pom = new Pom(); pom.setProject(installOrDeployTask.getProject()); pom.setFile(mavenDeployment.getPomArtifact().getFile()); installOrDeployTask.addPom(pom); if (mavenDeployment.getMainArtifact() != null) { installOrDeployTask.setFile(mavenDeployment.getMainArtifact().getFile()); } for (PublishArtifact classifierArtifact : mavenDeployment.getAttachedArtifacts()) { AttachedArtifact attachedArtifact = installOrDeployTask.createAttach(); attachedArtifact.setClassifier(classifierArtifact.getClassifier()); attachedArtifact.setFile(classifierArtifact.getFile()); attachedArtifact.setType(classifierArtifact.getType()); } }
Example 24
Source Project: pushfish-android Source File: AbstractMavenResolver.java License: BSD 2-Clause "Simplified" License | 5 votes |
private void addPomAndArtifact(InstallDeployTaskSupport installOrDeployTask, MavenDeployment mavenDeployment) { Pom pom = new Pom(); pom.setProject(installOrDeployTask.getProject()); pom.setFile(mavenDeployment.getPomArtifact().getFile()); installOrDeployTask.addPom(pom); if (mavenDeployment.getMainArtifact() != null) { installOrDeployTask.setFile(mavenDeployment.getMainArtifact().getFile()); } for (PublishArtifact classifierArtifact : mavenDeployment.getAttachedArtifacts()) { AttachedArtifact attachedArtifact = installOrDeployTask.createAttach(); attachedArtifact.setClassifier(classifierArtifact.getClassifier()); attachedArtifact.setFile(classifierArtifact.getFile()); attachedArtifact.setType(classifierArtifact.getType()); } }
Example 25
Source Project: Pushjet-Android Source File: PublishArtifactToFileBuildOutcomeTransformer.java License: BSD 2-Clause "Simplified" License | 5 votes |
private String getTaskPath(PublishArtifact artifact) { if (artifact instanceof ArchivePublishArtifact) { return ((ArchivePublishArtifact) artifact).getArchiveTask().getPath(); } else { String taskPath = null; Set<? extends Task> tasks = artifact.getBuildDependencies().getDependencies(null); if (!tasks.isEmpty()) { taskPath = tasks.iterator().next().getPath(); } return taskPath; } }
Example 26
Source Project: pushfish-android Source File: MavenArtifactNotationParserFactory.java License: BSD 2-Clause "Simplified" License | 5 votes |
@Override protected MavenArtifact parseType(PublishArtifact publishArtifact) { DefaultMavenArtifact artifact = instantiator.newInstance( DefaultMavenArtifact.class, publishArtifact.getFile(), publishArtifact.getExtension(), publishArtifact.getClassifier()); artifact.builtBy(publishArtifact.getBuildDependencies()); return artifact; }
Example 27
Source Project: Pushjet-Android Source File: PublishArtifactToFileBuildOutcomeTransformer.java License: BSD 2-Clause "Simplified" License | 5 votes |
public GradleFileBuildOutcome transform(PublishArtifact artifact, Project project) { String id = getId(artifact, project); String taskPath = getTaskPath(artifact); String description = getDescription(artifact); String typeIdentifier = getTypeIdentifier(artifact); return new DefaultGradleFileBuildOutcome(id, description, taskPath, artifact.getFile(), typeIdentifier); }
Example 28
Source Project: Pushjet-Android Source File: PublishArtifactNotationParserFactory.java License: BSD 2-Clause "Simplified" License | 4 votes |
protected PublishArtifact parseMap(@MapKey("file") File file) { return fileParser.parseType(file); }
Example 29
Source Project: pushfish-android Source File: DefaultArtifactPom.java License: BSD 2-Clause "Simplified" License | 4 votes |
private void addArtifact(PublishArtifact artifact) { classifiers.add(artifact); artifacts.put(new ArtifactKey(artifact), artifact); }
Example 30
Source Project: Pushjet-Android Source File: DefaultArtifactPom.java License: BSD 2-Clause "Simplified" License | 4 votes |
public PublishArtifact writePom(final File pomFile) { getPom().writeTo(pomFile); return new PomArtifact(pomFile); }