in nbm-maven-plugin/src/main/java/org/apache/netbeans/nbm/AbstractNbmMojo.java [310:369]
protected final ArtifactResult turnJarToNbmFile(Artifact art, ArtifactFactory artifactFactory,
ArtifactResolver artifactResolver, MavenProject project,
ArtifactRepository localRepository)
throws MojoExecutionException {
if ("jar".equals(art.getType()) || "nbm".equals(art.getType())) {
//TODO, it would be nice to have a check to see if the
// "to-be-created" module nbm artifact is actually already in the
// list of dependencies (as "nbm-file") or not..
// that would be a timesaver
ExamineManifest mnf = new ExamineManifest(getLog());
File jar = art.getFile();
if (!jar.isFile()) {
//MNBMODULE-210 with recent CoS changes in netbeans (7.4) jar will be file as we link open projects in
// the build via WorkspaceReader.
// That's fine here, as all we need is to know if project is osgi or nbm module.
// the nbm file has to be in local repository though.
String path = localRepository.pathOf(art);
File jar2 = new File(localRepository.getBasedir(), path.replace("/", File.separator));
File manifest = new File(jar, "META-INF/MANIFEST.MF");
if (!jar2.isFile() || !manifest.isFile()) {
getLog().warn("MNBMODULE-131: need to at least run install phase on " + jar2);
return new ArtifactResult(null, null);
}
mnf.setManifestFile(manifest);
} else {
mnf.setJarFile(jar);
}
mnf.checkFile();
if (mnf.isNetBeansModule()) {
Artifact nbmArt = artifactFactory.createDependencyArtifact(
art.getGroupId(),
art.getArtifactId(),
art.getVersionRange(),
"nbm-file",
art.getClassifier(),
art.getScope());
try {
artifactResolver.resolve(nbmArt, project.getRemoteArtifactRepositories(), localRepository);
} catch (ArtifactResolutionException ex) {
//shall be check before actually resolving from repos?
checkReactor(art, nbmArt);
if (!nbmArt.isResolved()) {
throw new MojoExecutionException("Failed to retrieve the nbm file from repository", ex);
}
} catch (ArtifactNotFoundException ex) {
//shall be check before actually resolving from repos?
checkReactor(art, nbmArt);
if (!nbmArt.isResolved()) {
throw new MojoExecutionException("Failed to retrieve the nbm file from repository", ex);
}
}
return new ArtifactResult(nbmArt, mnf);
}
if (mnf.isOsgiBundle()) {
return new ArtifactResult(null, mnf);
}
}
return new ArtifactResult(null, null);
}