Author: akazakov
Date: 2009-04-22 11:19:00 -0400 (Wed, 22 Apr 2009)
New Revision: 14849
Modified:
branches/jbosstools-3.0.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam2ProjectCreator.java
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 the patch should affect Seam 2.x only
Modified:
branches/jbosstools-3.0.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam2ProjectCreator.java
===================================================================
---
branches/jbosstools-3.0.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam2ProjectCreator.java 2009-04-22
14:15:46 UTC (rev 14848)
+++
branches/jbosstools-3.0.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam2ProjectCreator.java 2009-04-22
15:19:00 UTC (rev 14849)
@@ -14,15 +14,26 @@
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
+import java.io.FilenameFilter;
import java.io.IOException;
import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
+import java.util.regex.Pattern;
import org.apache.tools.ant.types.FilterSet;
import org.apache.tools.ant.types.FilterSetCollection;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
import org.eclipse.wst.common.componentcore.ComponentCore;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
@@ -198,6 +209,84 @@
}
@Override
+ protected void fillManifests() {
+ try {
+ File[] earJars = earContentsFolder.listFiles(new FilenameFilter() {
+ /* (non-Javadoc)
+ * @see java.io.FilenameFilter#accept(java.io.File, java.lang.String)
+ */
+ public boolean accept(File dir, String name) {
+ return name.lastIndexOf(".jar") > 0; //$NON-NLS-1$
+ }
+ });
+ String earJarsStrWar = ""; //$NON-NLS-1$
+ String earJarsStrEjb = ""; //$NON-NLS-1$
+ for (File file : earJars) {
+ 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 manifestFilterColWar = new FilterSetCollection(projectFilterSet);
+ FilterSet manifestFilter = new FilterSet();
+ 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);
+ }
+ }
+
+ private boolean isJBossSeamJar(File file) {
+ String regex = "(jboss-seam){1}(-[0-9][0-9\\.]+){0,1}(.jar){1}";
+ return Pattern.matches(regex, file.getName());
+ }
+
+ @Override
+ protected void configureEjbClassPath(IProject ejbProject, IProgressMonitor monitor)
throws CoreException {
+ if (jbossSeamPath != null && jbossSeamPath.trim().length() > 0
+ && new File(jbossSeamPath).exists()) {
+ IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
+ IJavaProject ejbJavaProject = JavaCore
+ .create(ejbProject);
+ 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);
+ }
+ }
+ }
+
+ @Override
protected void createEjbProject() {
super.createEjbProject();
// Copy security.drl to source folder
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-22
14:15:46 UTC (rev 14848)
+++
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-22
15:19:00 UTC (rev 14849)
@@ -14,12 +14,10 @@
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;
@@ -31,9 +29,6 @@
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;
@@ -113,7 +108,7 @@
protected File ejbMetaInf;
protected File droolsLibFolder;
- private String jbossSeamPath;
+ protected String jbossSeamPath;
/**
* @param model Seam facet data model
@@ -209,6 +204,36 @@
return SeamFacetInstallDelegate.JBOSS_EAR_CONTENT;
}
+ protected void fillManifests() {
+ try {
+ File[] earJars = earContentsFolder.listFiles(new FilenameFilter() {
+ /* (non-Javadoc)
+ * @see java.io.FilenameFilter#accept(java.io.File, java.lang.String)
+ */
+ public boolean accept(File dir, String name) {
+ return name.lastIndexOf(".jar") > 0; //$NON-NLS-1$
+ }
+ });
+ String earJarsStr = ""; //$NON-NLS-1$
+ for (File file : earJars) {
+ earJarsStr += " " + file.getName() + " \n"; //$NON-NLS-1$
//$NON-NLS-2$
+ }
+
+ FilterSetCollection manifestFilterCol = 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$
+ } catch (IOException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+ }
+
+ protected void configureEjbClassPath(IProject ejbProject, IProgressMonitor monitor)
throws CoreException {
+ // Do nothing special for Seam 1.2
+ }
+
/**
* Creates test project for seam web project in case of WAR deployment and test, EAR and
EJB projects in case of EAR deployment.
* @param monitor
@@ -222,41 +247,7 @@
createEjbProject();
createEarProject();
- try {
- File[] earJars = earContentsFolder.listFiles(new FilenameFilter() {
- /* (non-Javadoc)
- * @see java.io.FilenameFilter#accept(java.io.File, java.lang.String)
- */
- public boolean accept(File dir, String name) {
- return name.lastIndexOf(".jar") > 0; //$NON-NLS-1$
- }
- });
- String earJarsStrWar = ""; //$NON-NLS-1$
- String earJarsStrEjb = ""; //$NON-NLS-1$
- for (File file : earJars) {
- 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 manifestFilterColWar = new
FilterSetCollection(projectFilterSet);
- FilterSet manifestFilter = new FilterSet();
- 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);
- }
+ fillManifests();
}
SeamFacetAbstractInstallDelegate.toggleHibernateOnProject(seamWebProject,
consoleName);
@@ -284,35 +275,9 @@
ClasspathHelper.addClasspathEntries(ejbProjectToBeImported, pfv);
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);
- }
- }
+
+ configureEjbClassPath(ejbProjectToBeImported, monitor);
+
WtpUtils.reconfigure(ejbProjectToBeImported,monitor);
WtpUtils.reconfigure(earProjectToBeImported, monitor);
}
@@ -334,11 +299,6 @@
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.
*/