Minor fixes to the Maven bundle plugin. Fixed the algorithm determining what directories need to be excluded from the distro. Added an 'includeGroupIds' configruation property.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@707438 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3336ce7cd3
commit
13d2bfc113
1 changed files with 45 additions and 11 deletions
|
@ -77,6 +77,13 @@ public class ModuleBundlesBuildMojo extends AbstractMojo {
|
|||
*/
|
||||
private String[] excludeGroupIds;
|
||||
|
||||
/**
|
||||
* Directories containing groupids to include.
|
||||
*
|
||||
* @parameter
|
||||
*/
|
||||
private String[] includeGroupIds;
|
||||
|
||||
/**
|
||||
* Set to true to generate a PDE target platform configuration.
|
||||
*
|
||||
|
@ -105,15 +112,23 @@ public class ModuleBundlesBuildMojo extends AbstractMojo {
|
|||
}
|
||||
root.mkdirs();
|
||||
|
||||
// Build sets of exclude directories and groupids
|
||||
// Build sets of exclude directories and included/excluded/groupids
|
||||
Set<String> excludedFileNames = new HashSet<String>();
|
||||
if (excludeDirectories != null) {
|
||||
for (File f: excludeDirectories) {
|
||||
for (String n: f.list()) {
|
||||
excludedFileNames.add(n);
|
||||
if (f.isDirectory()) {
|
||||
for (String n: f.list()) {
|
||||
excludedFileNames.add(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Set<String> includedGroupIds = new HashSet<String>();
|
||||
if (includeGroupIds != null) {
|
||||
for (String g: includeGroupIds) {
|
||||
includedGroupIds.add(g);
|
||||
}
|
||||
}
|
||||
Set<String> excludedGroupIds = new HashSet<String>();
|
||||
if (excludeGroupIds != null) {
|
||||
for (String g: excludeGroupIds) {
|
||||
|
@ -139,11 +154,17 @@ public class ModuleBundlesBuildMojo extends AbstractMojo {
|
|||
continue;
|
||||
}
|
||||
|
||||
// Exclude artifact if its groupId is excluded
|
||||
// Exclude artifact if its groupId is excluded or if it's not included
|
||||
if (excludedGroupIds.contains(artifact.getGroupId())) {
|
||||
log.debug("Artifact groupId is excluded: " + artifact);
|
||||
continue;
|
||||
}
|
||||
if (!includedGroupIds.isEmpty()) {
|
||||
if (!includedGroupIds.contains(artifact.getGroupId())) {
|
||||
log.debug("Artifact groupId is not included: " + artifact);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
File artifactFile = artifact.getFile();
|
||||
if (!artifactFile.exists()) {
|
||||
|
@ -151,12 +172,6 @@ public class ModuleBundlesBuildMojo extends AbstractMojo {
|
|||
continue;
|
||||
}
|
||||
|
||||
// Exclude artifact if its file name is excluded
|
||||
if (excludedFileNames.contains(artifactFile.getName())) {
|
||||
log.debug("Artifact file is excluded: " + artifact);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Processing artifact: " + artifact);
|
||||
}
|
||||
|
@ -171,6 +186,12 @@ public class ModuleBundlesBuildMojo extends AbstractMojo {
|
|||
|
||||
if (bundleName != null) {
|
||||
|
||||
// Exclude artifact if its file name is excluded
|
||||
if (excludedFileNames.contains(artifactFile.getName())) {
|
||||
log.debug("Artifact file is excluded: " + artifact);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Copy an OSGi bundle as is
|
||||
log.info("Adding OSGi bundle artifact: " + artifact);
|
||||
copyFile(artifactFile, root);
|
||||
|
@ -178,6 +199,12 @@ public class ModuleBundlesBuildMojo extends AbstractMojo {
|
|||
|
||||
} else if ("war".equals(artifact.getType())) {
|
||||
|
||||
// Exclude artifact if its file name is excluded
|
||||
if (excludedFileNames.contains(artifactFile.getName())) {
|
||||
log.debug("Artifact file is excluded: " + artifact);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Copy a WAR as is
|
||||
log.info("Adding WAR artifact: " + artifact);
|
||||
copyFile(artifactFile, root);
|
||||
|
@ -185,6 +212,14 @@ public class ModuleBundlesBuildMojo extends AbstractMojo {
|
|||
|
||||
} else {
|
||||
|
||||
File dir = new File(root, artifactFile.getName().substring(0, artifactFile.getName().length() - 4));
|
||||
|
||||
// Exclude artifact if its file name is excluded
|
||||
if (excludedFileNames.contains(dir.getName())) {
|
||||
log.debug("Artifact file is excluded: " + artifact);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Create a bundle directory for a non-OSGi JAR
|
||||
log.info("Adding JAR artifact: " + artifact);
|
||||
String version = BundleUtil.version(artifactFile.getPath());
|
||||
|
@ -193,7 +228,6 @@ public class ModuleBundlesBuildMojo extends AbstractMojo {
|
|||
jarFiles.add(artifactFile);
|
||||
String symbolicName = (artifact.getGroupId() + "." + artifact.getArtifactId()).replace('-', '.');
|
||||
Manifest mf = BundleUtil.libraryManifest(jarFiles, symbolicName + "_" + version, symbolicName, version, null);
|
||||
File dir = new File(root, artifactFile.getName().substring(0, artifactFile.getName().length() - 4));
|
||||
File file = new File(dir, "META-INF");
|
||||
file.mkdirs();
|
||||
file = new File(file, "MANIFEST.MF");
|
||||
|
|
Loading…
Reference in a new issue