in versioning/versioning-plugin/src/main/java/org/apache/aries/versioning/mojo/VersionCheckerMojo.java [93:160]
public void execute() throws MojoExecutionException {
if (skip) {
getLog().info("Version check is skipped");
return;
}
if ("pom".equals(project.getPackaging())) {
getLog().info("Skipping version check for pom");
return;
}
if (newFile == null) {
newFile = project.getArtifact().getFile();
}
if (oldArtifact != null) {
try {
BundleInfo newBundle = getBundleInfo(newFile);
if (newBundle == null || newBundle.getBundleManifest() == null) {
//not a bundle type, just return
getLog().info(newFile + " is not an OSGi bundle, skipping.");
return;
}
if (null == newBundle.getBundleManifest().getManifestVersion()
&& null == newBundle.getBundleManifest().getSymbolicName()
&& Version.emptyVersion.equals(newBundle.getBundleManifest().getVersion())) {
//not a bundle type, just return
getLog().info(newFile + " is not an OSGi bundle, skipping.");
return;
}
BundleInfo oldBundle = getBundleInfo(resolve(oldArtifact));
String bundleSymbolicName = newBundle.getBundleManifest().getSymbolicName();
URLClassLoader oldClassLoader = new URLClassLoader(new URL[] {oldBundle.getBundle().toURI()
.toURL()});
URLClassLoader newClassLoader = new URLClassLoader(new URL[] {newBundle.getBundle().toURI()
.toURL()});
BundleCompatibility bundleCompatibility = new BundleCompatibility(bundleSymbolicName,
newBundle, oldBundle,
oldClassLoader,
newClassLoader,
excludes);
bundleCompatibility.invoke();
String bundleElement = bundleCompatibility.getBundleElement();
String pkgElement = bundleCompatibility.getPkgElements().toString();
boolean failed = false;
if ((bundleElement != null) && (bundleElement.trim().length() > 0)) {
getLog().error(bundleElement + "\r\n");
failed = true;
}
if ((pkgElement != null) && (pkgElement.trim().length() > 0)) {
getLog().error(pkgElement);
failed = true;
}
if (writePackageinfos) {
writePackageInfos(bundleCompatibility);
}
if (failed) {
throw new RuntimeException("Semantic Versioning incorrect");
} else {
getLog().info("All package or bundle versions are semanticly versioned correctly.");
}
} catch (MalformedURLException e) {
throw new MojoExecutionException("Problem analyzing sources");
} catch (IOException e) {
throw new MojoExecutionException("Problem analyzing sources");
}
}
}