Permalink
Browse files

MECLIPSEWTP-73 : Fixed setting of defaultBundleDir for jarModule and …

…ejbClientModule
  • Loading branch information...
1 parent e1e5ead commit 03401f6eda2598236eee169d4b7e7492703b9f6d @fbricon fbricon committed Dec 2, 2010
@@ -192,11 +192,12 @@ public String getDefaultBundleDirectory() {
Set<EarModule> earModules = new LinkedHashSet<EarModule>(artifacts.size());
String defaultBundleDir = getDefaultBundleDirectory();
+ IProjectFacetVersion javaEEVersion = getEarFacetVersion();
EarModuleFactory earModuleFactory = EarModuleFactory.createEarModuleFactory(getArtifactTypeMappingService(),
getFileNameMapping(), getMainArtifactId(), artifacts);
//Resolve Ear modules from plugin config
- earModules.addAll(getEarModulesFromConfig(earModuleFactory, defaultBundleDir));
+ earModules.addAll(getEarModulesFromConfig(earModuleFactory, defaultBundleDir, javaEEVersion));
ScopeArtifactFilter filter = new ScopeArtifactFilter(Artifact.SCOPE_RUNTIME);
@@ -212,7 +213,7 @@ public String getDefaultBundleDirectory() {
// Artifact is not yet registered and it has neither test, nor a
// provided scope, nor is it optional
if(!isArtifactRegistered(artifact, earModules) && filter.include(artifact) && !artifact.isOptional()) {
- EarModule module = earModuleFactory.newEarModule(artifact, defaultBundleDir);
+ EarModule module = earModuleFactory.newEarModule(artifact, defaultBundleDir, javaEEVersion);
if(module != null) {
earModules.add(module);
}
@@ -265,7 +266,7 @@ private FileNameMapping getFileNameMapping() {
*
* @param earModuleFactory
*/
- private Set<EarModule> getEarModulesFromConfig(EarModuleFactory earModuleFactory, String defaultBundleDir) throws EarPluginException {
+ private Set<EarModule> getEarModulesFromConfig(EarModuleFactory earModuleFactory, String defaultBundleDir, IProjectFacetVersion javaEEVersion) throws EarPluginException {
Set<EarModule> earModules = new LinkedHashSet<EarModule>();
Xpp3Dom configuration = getConfiguration();
if(configuration == null) {
@@ -283,7 +284,7 @@ private FileNameMapping getFileNameMapping() {
}
for(Xpp3Dom domModule : domModules) {
- EarModule earModule = earModuleFactory.newEarModule(domModule, defaultBundleDir);
+ EarModule earModule = earModuleFactory.newEarModule(domModule, defaultBundleDir, javaEEVersion);
if(earModule != null) {
earModules.add(earModule);
}
@@ -33,7 +33,10 @@
import java.util.Set;
import org.apache.maven.artifact.Artifact;
+import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.Xpp3Dom;
+import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
import org.maven.ide.eclipse.wtp.earmodules.output.FileNameMapping;
import org.maven.ide.eclipse.wtp.earmodules.output.FileNameMappingFactory;
@@ -77,9 +80,10 @@ public static EarModuleFactory createEarModuleFactory(ArtifactTypeMappingService
*
* @param artifact the artifact
* @param defaultLibBundleDir the default bundle dir for {@link JarModule}
+ * @param javaEEVersion
* @return an ear module for this artifact
*/
- public EarModule newEarModule(Artifact artifact, String defaultLibBundleDir) throws UnknownArtifactTypeException {
+ public EarModule newEarModule(Artifact artifact, String defaultLibBundleDir, IProjectFacetVersion javaEEVersion) throws UnknownArtifactTypeException {
// Get the standard artifact type based on default config and user-defined mapping(s)
final String artifactType = artifactTypeMappingService.getStandardType(artifact.getType());
AbstractEarModule earModule = null;
@@ -92,6 +96,10 @@ public EarModule newEarModule(Artifact artifact, String defaultLibBundleDir) thr
earModule = new ParModule(artifact);
} else if("ejb-client".equals(artifactType)) {
earModule = new EjbClientModule(artifact);
+ if (javaEEVersion.compareTo(IJ2EEFacetConstants.ENTERPRISE_APPLICATION_14) > 0)
+ {
+ ((EjbClientModule)earModule).setLibBundleDir(defaultLibBundleDir);
+ }
} else if("rar".equals(artifactType)) {
earModule = new RarModule(artifact);
} else if("war".equals(artifactType)) {
@@ -112,7 +120,7 @@ public EarModule newEarModule(Artifact artifact, String defaultLibBundleDir) thr
}
- public EarModule newEarModule(Xpp3Dom domModule, String defaultLibBundleDir) throws EarPluginException {
+ public EarModule newEarModule(Xpp3Dom domModule, String defaultLibBundleDir, IProjectFacetVersion javaEEVersion) throws EarPluginException {
String artifactType = domModule.getName();
String groupId = getChildValue(domModule, "groupId");
String artifactId = getChildValue(domModule, "artifactId");
@@ -122,6 +130,7 @@ public EarModule newEarModule(Xpp3Dom domModule, String defaultLibBundleDir) thr
// Get the standard artifact type based on default config and user-defined mapping(s)
if ( "jarModule".equals(artifactType) || "javaModule".equals(artifactType)) {
JarModule jarModule = new JarModule();
+ jarModule.setBundleDir(defaultLibBundleDir);
jarModule.setIncludeInApplicationXml(getBooleanChildValue(domModule, "includeInApplicationXml"));
earModule = jarModule;
}
@@ -138,6 +147,10 @@ else if ( "parModule".equals(artifactType)){
}
else if ( "ejbClientModule".equals(artifactType)){
earModule = new EjbClientModule();
+ if (javaEEVersion.compareTo(IJ2EEFacetConstants.ENTERPRISE_APPLICATION_14) > 0)
+ {
+ ((EjbClientModule)earModule).setLibBundleDir(defaultLibBundleDir);
+ }
}
else if ( "rarModule".equals(artifactType)){
earModule = new RarModule();
@@ -161,7 +174,10 @@ else if ( "harModule".equals(artifactType)){
Artifact artifact = artifactRepository.resolveArtifact(groupId, artifactId, earModule.getType(), classifier);
earModule.setArtifact(artifact);
- earModule.setBundleDir(getChildValue(domModule, "bundleDir"));
+ String bundleDir = getChildValue(domModule, "bundleDir");
+ if (StringUtils.isNotBlank(bundleDir)){
+ earModule.setBundleDir(bundleDir);
+ }
//To this point, we're sure to have a valid earModule ...
String bundleFileName = getChildValue(domModule, "bundleFileName");
if (null==bundleFileName){

0 comments on commit 03401f6

Please sign in to comment.