Author: akazakov
Date: 2009-04-21 13:44:01 -0400 (Tue, 21 Apr 2009)
New Revision: 14837
Modified:
branches/jbosstools-3.0.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamProjectCreator.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4166 Patch applied to 3.0.1 brunch
Modified:
branches/jbosstools-3.0.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamProjectCreator.java
===================================================================
---
branches/jbosstools-3.0.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamProjectCreator.java 2009-04-21
17:40:55 UTC (rev 14836)
+++
branches/jbosstools-3.0.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamProjectCreator.java 2009-04-21
17:44:01 UTC (rev 14837)
@@ -14,10 +14,12 @@
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.Collections;
+import java.util.regex.Pattern;
import org.apache.tools.ant.types.FilterSet;
import org.apache.tools.ant.types.FilterSetCollection;
import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
@@ -29,6 +31,9 @@
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jst.common.project.facet.JavaFacetUtils;
import org.eclipse.jst.common.project.facet.core.ClasspathHelper;
import org.eclipse.wst.common.componentcore.ComponentCore;
@@ -108,6 +113,7 @@
protected File ejbMetaInf;
protected File droolsLibFolder;
+ private String jbossSeamPath;
/**
* @param model Seam facet data model
@@ -225,17 +231,29 @@
return name.lastIndexOf(".jar") > 0; //$NON-NLS-1$
}
});
- String earJarsStr = ""; //$NON-NLS-1$
+ String earJarsStrWar = ""; //$NON-NLS-1$
+ String earJarsStrEjb = ""; //$NON-NLS-1$
for (File file : earJars) {
- earJarsStr += " " + file.getName() + " \n"; //$NON-NLS-1$
//$NON-NLS-2$
+ earJarsStrWar += " " + file.getName() + " \n"; //$NON-NLS-1$
//$NON-NLS-2$
+ if (isJBossSeamJar(file)) {
+ jbossSeamPath = file.getAbsolutePath();
+ } else {
+ earJarsStrEjb += " " + file.getName() + " \n"; //$NON-NLS-1$
//$NON-NLS-2$
+ }
}
- FilterSetCollection manifestFilterCol = new FilterSetCollection(projectFilterSet);
+ FilterSetCollection manifestFilterColWar = new
FilterSetCollection(projectFilterSet);
FilterSet manifestFilter = new FilterSet();
- manifestFilter.addFilter("earLibs", earJarsStr); //$NON-NLS-1$
- manifestFilterCol.addFilterSet(manifestFilter);
- AntCopyUtils.copyFileToFolder(new
File(SeamFacetInstallDataModelProvider.getTemplatesFolder(),
"war/META-INF/MANIFEST.MF"), webMetaInf, manifestFilterCol, true);
//$NON-NLS-1$
- AntCopyUtils.copyFileToFolder(new
File(SeamFacetInstallDataModelProvider.getTemplatesFolder(),
"ejb/ejbModule/META-INF/MANIFEST.MF"), ejbMetaInf, manifestFilterCol, true);
//$NON-NLS-1$
+ manifestFilter.addFilter("earLibs", earJarsStrWar); //$NON-NLS-1$
+ manifestFilterColWar.addFilterSet(manifestFilter);
+
+ FilterSetCollection manifestFilterColEjb = new
FilterSetCollection(projectFilterSet);
+ FilterSet manifestFilterEjb = new FilterSet();
+ manifestFilterEjb.addFilter("earLibs", earJarsStrEjb); //$NON-NLS-1$
+ manifestFilterColEjb.addFilterSet(manifestFilterEjb);
+
+ AntCopyUtils.copyFileToFolder(new
File(SeamFacetInstallDataModelProvider.getTemplatesFolder(),
"war/META-INF/MANIFEST.MF"), webMetaInf, manifestFilterColWar, true);
//$NON-NLS-1$
+ AntCopyUtils.copyFileToFolder(new
File(SeamFacetInstallDataModelProvider.getTemplatesFolder(),
"ejb/ejbModule/META-INF/MANIFEST.MF"), ejbMetaInf, manifestFilterColEjb, true);
//$NON-NLS-1$
} catch (IOException e) {
SeamCorePlugin.getPluginLog().logError(e);
}
@@ -264,9 +282,38 @@
IProjectFacet sf = ProjectFacetsManager.getProjectFacet("jst.ejb");
IProjectFacetVersion pfv =
ProjectFacetsManager.create(ejbProjectToBeImported).getInstalledVersion(sf);
ClasspathHelper.addClasspathEntries(ejbProjectToBeImported, pfv);
- WtpUtils.reconfigure(ejbProjectToBeImported,monitor);
IProject earProjectToBeImported = wsRoot.getProject(earProjectName);
ResourcesUtils.importExistingProject(earProjectToBeImported, wsPath + "/" +
earProjectName, earProjectName, monitor, false);
+ if (jbossSeamPath != null && jbossSeamPath.trim().length() > 0
+ && new File(jbossSeamPath).exists()) {
+ IJavaProject ejbJavaProject = JavaCore
+ .create(ejbProjectToBeImported);
+ if (ejbJavaProject != null) {
+ if (!ejbJavaProject.isOpen()) {
+ ejbJavaProject.open(monitor);
+ }
+ IClasspathEntry[] cps = ejbJavaProject.getRawClasspath();
+ IClasspathEntry[] entries = new IClasspathEntry[cps.length + 1];
+ for (int i = 0; i < cps.length; i++) {
+ entries[i] = cps[i];
+ }
+ IPath path = new Path(jbossSeamPath);
+ IFile[] files = wsRoot.findFilesForLocation(path);
+ IFile f = null;
+ if (files != null && files.length > 0) {
+ f=files[0];
+ } else {
+ f = wsRoot.getFile(path);
+ }
+ if (f.exists()) {
+ path = f.getFullPath();
+ }
+ entries[cps.length] = JavaCore.newLibraryEntry(path, null,
+ null);
+ ejbJavaProject.setRawClasspath(entries, monitor);
+ }
+ }
+ WtpUtils.reconfigure(ejbProjectToBeImported,monitor);
WtpUtils.reconfigure(earProjectToBeImported, monitor);
}
@@ -287,6 +334,11 @@
WtpUtils.reconfigure(testProjectToBeImported, monitor);
}
+ private boolean isJBossSeamJar(File file) {
+ String regex = "(jboss-seam){1}(-[0-9][0-9\\.]+){0,1}(.jar){1}";
+ return Pattern.matches(regex, file.getName());
+ }
+
/**
* Creates test project for given seam web project.
*/