use of org.apache.maven.artifact.Artifact in project aries by apache.
the class EbaMojo method writeApplicationManifest.
private void writeApplicationManifest(String fileName) throws MojoExecutionException {
try {
// TODO: add support for dependency version ranges. Need to pick
// them up from the pom and convert them to OSGi version ranges.
FileUtils.fileAppend(fileName, MANIFEST_VERSION + ": " + "1" + "\n");
FileUtils.fileAppend(fileName, APPLICATION_MANIFESTVERSION + ": " + "1" + "\n");
FileUtils.fileAppend(fileName, APPLICATION_SYMBOLICNAME + ": " + getApplicationSymbolicName(project.getArtifact()) + "\n");
FileUtils.fileAppend(fileName, APPLICATION_VERSION + ": " + getApplicationVersion() + "\n");
FileUtils.fileAppend(fileName, APPLICATION_NAME + ": " + project.getName() + "\n");
FileUtils.fileAppend(fileName, APPLICATION_DESCRIPTION + ": " + project.getDescription() + "\n");
// Write the APPLICATION-CONTENT
// TODO: check that the dependencies are bundles (currently, the converter
// will throw an exception)
Set<Artifact> artifacts;
if (useTransitiveDependencies) {
artifacts = project.getArtifacts();
} else {
artifacts = project.getDependencyArtifacts();
}
artifacts = selectArtifacts(artifacts);
Iterator<Artifact> iter = artifacts.iterator();
FileUtils.fileAppend(fileName, APPLICATION_CONTENT + ": ");
if (iter.hasNext()) {
Artifact artifact = iter.next();
FileUtils.fileAppend(fileName, maven2OsgiConverter.getBundleSymbolicName(artifact) + ";version=\"" + Analyzer.cleanupVersion(artifact.getVersion()) + // + maven2OsgiConverter.getVersion(artifact.getVersion())
"\"");
}
while (iter.hasNext()) {
Artifact artifact = iter.next();
FileUtils.fileAppend(fileName, ",\n " + maven2OsgiConverter.getBundleSymbolicName(artifact) + ";version=\"" + Analyzer.cleanupVersion(artifact.getVersion()) + // + maven2OsgiConverter.getVersion(artifact.getVersion())
"\"");
}
FileUtils.fileAppend(fileName, "\n");
// Add any service imports or exports
if (instructions.containsKey(APPLICATION_EXPORTSERVICE)) {
FileUtils.fileAppend(fileName, APPLICATION_EXPORTSERVICE + ": " + instructions.get(APPLICATION_EXPORTSERVICE) + "\n");
}
if (instructions.containsKey(APPLICATION_IMPORTSERVICE)) {
FileUtils.fileAppend(fileName, APPLICATION_IMPORTSERVICE + ": " + instructions.get(APPLICATION_IMPORTSERVICE) + "\n");
}
if (instructions.containsKey(APPLICATION_USEBUNDLE)) {
FileUtils.fileAppend(fileName, APPLICATION_USEBUNDLE + ": " + instructions.get(APPLICATION_USEBUNDLE) + "\n");
}
// Add any use bundle entry
} catch (Exception e) {
throw new MojoExecutionException("Error writing dependencies into APPLICATION.MF", e);
}
}
use of org.apache.maven.artifact.Artifact in project aries by apache.
the class EbaMavenProjectStub method getArtifact.
public Artifact getArtifact() {
Artifact artifact = new EbaArtifactStub();
artifact.setGroupId(getGroupId());
artifact.setArtifactId(getArtifactId());
artifact.setVersion(getVersion());
return artifact;
}
use of org.apache.maven.artifact.Artifact in project aries by apache.
the class EsaMavenProjectStub method createArtifact.
protected Artifact createArtifact(String groupId, String artifactId, String version, String type, boolean optional) {
Artifact artifact = new EsaArtifactStub();
artifact.setGroupId(groupId);
artifact.setArtifactId(artifactId);
artifact.setVersion(version);
artifact.setOptional(optional);
artifact.setFile(new File(getBasedir() + "/src/test/remote-repo/" + artifact.getGroupId().replace('.', '/') + "/" + artifact.getArtifactId() + "/" + artifact.getVersion() + "/" + artifact.getArtifactId() + "-" + artifact.getVersion() + "." + type));
return artifact;
}
use of org.apache.maven.artifact.Artifact in project aries by apache.
the class EsaMavenProjectStub9 method getArtifacts.
public Set getArtifacts() {
try {
Set artifacts = new HashSet();
artifacts.add(createArtifact("org.apache.maven.test", "maven-artifact01", "1.0-SNAPSHOT", false));
Artifact artifact02 = createArtifact("org.apache.maven.test", "maven-artifact02", "1.0-SNAPSHOT", false);
artifact02.setVersionRange(VersionRange.createFromVersionSpec("[1.3, 2.5)"));
artifacts.add(artifact02);
artifacts.add(createArtifact("org.apache.maven.test", "maven-artifact03", "1.1-SNAPSHOT", false));
artifacts.add(createArtifact("org.apache.maven.test", "maven-artifact04", "1.2-SNAPSHOT", "esa", true));
return artifacts;
} catch (InvalidVersionSpecificationException e) {
throw new RuntimeException(e);
}
}
use of org.apache.maven.artifact.Artifact in project asterixdb by apache.
the class LicenseMojo method gatherProjectDependencies.
private void gatherProjectDependencies(MavenProject project, Map<MavenProject, List<Pair<String, String>>> dependencyLicenseMap, Map<String, MavenProject> dependencyGavMap) throws ProjectBuildingException {
final Set dependencyArtifacts = project.getArtifacts();
if (dependencyArtifacts != null) {
for (Object depArtifactObj : dependencyArtifacts) {
final Artifact depArtifact = (Artifact) depArtifactObj;
if (!excludedScopes.contains(depArtifact.getScope())) {
MavenProject dep = resolveDependency(depArtifact);
dep.setArtifact(depArtifact);
dependencyGavMap.put(toGav(dep), dep);
List<Pair<String, String>> licenseUrls = new ArrayList<>();
for (Object license : dep.getLicenses()) {
final License license1 = (License) license;
String url = license1.getUrl() != null ? license1.getUrl() : (license1.getName() != null ? license1.getName() : "LICENSE_EMPTY_NAME_URL");
licenseUrls.add(new ImmutablePair<>(url, license1.getName()));
}
dependencyLicenseMap.put(dep, licenseUrls);
}
}
}
}
Aggregations