Author: akazakov
Date: 2008-09-30 13:01:27 -0400 (Tue, 30 Sep 2008)
New Revision: 10575
Removed:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam1ProjectCreator.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam2FacetInstallDelegate.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam2ProjectCreator.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetAbstractInstallDelegate.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegate.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamProjectCreator.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2731 Moved EJB/EAR project creation from seam
facet to wizard.
Deleted:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam1ProjectCreator.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam1ProjectCreator.java 2008-09-30
16:51:41 UTC (rev 10574)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam1ProjectCreator.java 2008-09-30
17:01:27 UTC (rev 10575)
@@ -1,115 +0,0 @@
- /*******************************************************************************
- * Copyright (c) 2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.seam.internal.core.project.facet;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.apache.tools.ant.types.FilterSet;
-import org.apache.tools.ant.types.FilterSetCollection;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-import org.jboss.tools.seam.core.SeamCorePlugin;
-
-/**
- * @author Alexey Kazakov
- * This class helps New Seam Wizard Page to create EJB, EAR and test projects for seam
1.2 WAR project.
- */
-public class Seam1ProjectCreator extends SeamProjectCreator {
-
- protected static AntCopyUtils.FileSet JBOSS_TEST_LIB_FILESET = new
AntCopyUtils.FileSet()
- .include("testng-.*-jdk15\\.jar") //$NON-NLS-1$
- .include("myfaces-api-.*\\.jar") //$NON-NLS-1$
- .include("myfaces-impl-.*\\.jar") //$NON-NLS-1$
- .include("servlet-api\\.jar") //$NON-NLS-1$
- .include("hibernate-all\\.jar") //$NON-NLS-1$
- .include("jboss-ejb3-all\\.jar") //$NON-NLS-1$
- .include("thirdparty-all\\.jar") //$NON-NLS-1$
- .exclude(".*/CVS") //$NON-NLS-1$
- .exclude(".*/\\.svn"); //$NON-NLS-1$
-
- /**
- * @param model Seam facet data model
- * @param seamWebProject Seam web project
- */
- public Seam1ProjectCreator(IDataModel model, IProject seamWebProject) {
- super(model, seamWebProject);
- }
-
- /*
- * (non-Javadoc)
- * @see
org.jboss.tools.seam.internal.core.project.facet.SeamProjectCreator#createTestProject()
- */
- @Override
- protected void createTestProject() {
- File testProjectDir = new
File(seamWebProject.getLocation().removeLastSegments(1).toFile(), testProjectName);
//$NON-NLS-1$
- testProjectDir.mkdir();
-
- IVirtualComponent component = ComponentCore.createComponent(seamWebProject);
- IVirtualFolder webRootVirtFolder = component.getRootFolder().getFolder(new
Path("/")); //$NON-NLS-1$
-
- File testLibDir = new File(testProjectDir, "lib"); //$NON-NLS-1$
- File embededEjbDir = new File(testProjectDir, "embedded-ejb"); //$NON-NLS-1$
- File testSrcDir = new File(testProjectDir, "test-src"); //$NON-NLS-1$
- FilterSet filterSet = new FilterSet();
- filterSet.addFilter("projectName", seamWebProject.getName()); //$NON-NLS-1$
- filterSet.addFilter("runtimeName",
WtpUtils.getServerRuntimeName(seamWebProject)); //$NON-NLS-1$
- filterSet.addFilter("webRootFolder",
webRootVirtFolder.getUnderlyingFolder().getFullPath().removeFirstSegments(1).toString());
//$NON-NLS-1$
-
- AntCopyUtils.FileSet includeLibs = new
AntCopyUtils.FileSet(JBOSS_TEST_LIB_FILESET).dir(new File(seamRuntime.getHomeDir(),
"lib")); //$NON-NLS-1$
- File[] libs = includeLibs.getDir().listFiles(new
AntCopyUtils.FileSetFileFilter(includeLibs));
- StringBuffer testLibraries = new StringBuffer();
-
- for (File file : libs) {
- testLibraries.append("\t<classpathentry kind=\"lib\"
path=\"lib/" + file.getName() + "\"/>\n"); //$NON-NLS-1$
//$NON-NLS-2$
- }
-
- StringBuffer requiredProjects = new StringBuffer();
- requiredProjects.append("\t<classpathentry
combineaccessrules=\"false\" kind=\"src\" path=\"/" +
seamWebProject.getName() + "\"/>"); //$NON-NLS-1$ //$NON-NLS-2$
- if (!SeamFacetAbstractInstallDelegate.isWarConfiguration(model)) {
- requiredProjects.append("\n\t<classpathentry
combineaccessrules=\"false\" kind=\"src\" path=\"/" +
ejbProjectName + "\"/>"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- filterSet.addFilter("testLibraries", testLibraries.toString());
//$NON-NLS-1$
- filterSet.addFilter("requiredProjects", requiredProjects.toString());
//$NON-NLS-1$
- File testTemplateDir = null;
- try {
- testTemplateDir = new File(SeamFacetInstallDataModelProvider.getTemplatesFolder(),
"test"); //$NON-NLS-1$
- } catch (IOException e) {
- SeamCorePlugin.getPluginLog().logError(e);
- return;
- }
- AntCopyUtils.FileSet excludeCvsSvn
- = new
AntCopyUtils.FileSet(SeamFacetAbstractInstallDelegate.CVS_SVN).dir(testTemplateDir);
-
- AntCopyUtils.copyFilesAndFolders(
- testTemplateDir,
- testProjectDir,
- new AntCopyUtils.FileSetFileFilter(excludeCvsSvn),
- new FilterSetCollection(filterSet), true);
-
- excludeCvsSvn.dir(new File(seamRuntime.getHomeDir(), "embedded-ejb/conf"));
//$NON-NLS-1$
- AntCopyUtils.copyFiles(
- new File(seamRuntime.getHomeDir(), "embedded-ejb/conf"), //$NON-NLS-1$
- embededEjbDir,
- new AntCopyUtils.FileSetFileFilter(excludeCvsSvn));
-
- AntCopyUtils.copyFiles(
- new File(seamRuntime.getHomeDir(), "lib"), //$NON-NLS-1$
- testLibDir,
- new AntCopyUtils.FileSetFileFilter(includeLibs));
-
- SeamFacetAbstractInstallDelegate.createComponentsProperties(testSrcDir, "",
Boolean.TRUE); //$NON-NLS-1$
- }
-}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam2FacetInstallDelegate.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam2FacetInstallDelegate.java 2008-09-30
16:51:41 UTC (rev 10574)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam2FacetInstallDelegate.java 2008-09-30
17:01:27 UTC (rev 10575)
@@ -11,17 +11,12 @@
package org.jboss.tools.seam.internal.core.project.facet;
import java.io.File;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.util.Set;
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.IProject;
import org.eclipse.core.resources.IResource;
-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;
@@ -29,27 +24,18 @@
import org.eclipse.jst.common.project.facet.core.ClasspathHelper;
import org.eclipse.jst.javaee.web.WebApp;
import org.eclipse.wst.common.componentcore.ComponentCore;
-import
org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-import org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy;
-import org.eclipse.wst.common.project.facet.core.IProjectFacet;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
-import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
-import org.jboss.tools.common.util.ResourcesUtils;
import org.jboss.tools.seam.core.ISeamProject;
-import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.core.project.facet.SeamRuntime;
import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
// TODO: why not just *one* global filter set to avoid any missing names ? (assert for it
in our unittests!
public class Seam2FacetInstallDelegate extends SeamFacetAbstractInstallDelegate{
- public static String DEV_WAR_PROFILE = "dev-war"; //$NON-NLS-1$
- public static String DEV_EAR_PROFILE = "dev"; //$NON-NLS-1$
-
public static AntCopyUtils.FileSet JBOSS_WAR_LIB_FILESET_WAR_CONFIG = new
AntCopyUtils.FileSet()
.include("ajax4jsf.*\\.jar") //$NON-NLS-1$
.include("richfaces.*\\.jar")
@@ -90,67 +76,11 @@
.include("jboss-seam-ui\\.jar") //$NON-NLS-1$
.include("jsf-facelets\\.jar"); //$NON-NLS-1$
- public static AntCopyUtils.FileSet JBOSS_EAR_CONTENT = new AntCopyUtils.FileSet()
- .include("antlr-runtime.jar") //$NON-NLS-1$
- .include("drools-compiler.*\\.jar") //$NON-NLS-1$
- .include("drools-core.*\\.jar") //$NON-NLS-1$
- .include("jboss-seam.jar") //$NON-NLS-1$
- .include("jboss-el.*.jar") //$NON-NLS-1$
- .include("mvel14.*.jar") //$NON-NLS-1$
- .include("jbpm-jpdl.*\\.jar") //$NON-NLS-1$
- .include("richfaces-api.*\\.jar"); //$NON-NLS-1$
-
- /*public static AntCopyUtils.FileSet JBOSS_EAR_CONTENT_META_INF = new
AntCopyUtils.FileSet()
- .include("META-INF/application\\.xml") //$NON-NLS-1$
- .include("META-INF/jboss-app\\.xml"); //$NON-NLS-1$
- */
-
- public static AntCopyUtils.FileSet VIEW_FILESET = new AntCopyUtils.FileSet()
- .include("home\\.xhtml") //$NON-NLS-1$
- .include("error\\.xhtml") //$NON-NLS-1$
- .include("login\\.xhtml") //$NON-NLS-1$
- .include("login\\.page.xml") //$NON-NLS-1$
- .include("index\\.html") //$NON-NLS-1$
- .include("layout") //$NON-NLS-1$
- .include("layout/.*") //$NON-NLS-1$
- .include("stylesheet") //$NON-NLS-1$
- .include("stylesheet/.*") //$NON-NLS-1$
- .include("img/.*") //$NON-NLS-1$
- .include("img") //$NON-NLS-1$
- .exclude(".*/.*\\.ftl") //$NON-NLS-1$
- .exclude(".*/CVS") //$NON-NLS-1$
- .exclude(".*/\\.svn"); //$NON-NLS-1$
-
- public static AntCopyUtils.FileSet JBOOS_WAR_WEBINF_SET = new AntCopyUtils.FileSet()
- .include("WEB-INF") //$NON-NLS-1$
- //.include("WEB-INF/web\\.xml") //$NON-NLS-1$
- .include("WEB-INF/pages\\.xml") //$NON-NLS-1$
- .include("WEB-INF/jboss-web\\.xml") //$NON-NLS-1$
- .include("WEB-INF/faces-config\\.xml") //$NON-NLS-1$
- .include("WEB-INF/componets\\.xml"); //$NON-NLS-1$
-
- public static AntCopyUtils.FileSet JBOOS_WAR_WEB_INF_CLASSES_SET = new
AntCopyUtils.FileSet()
- .include("import\\.sql") //$NON-NLS-1$
- .include("security\\.drl") //$NON-NLS-1$
- .include("seam\\.properties") //$NON-NLS-1$
- .include("messages_en\\.properties"); //$NON-NLS-1$
-
- public static AntCopyUtils.FileSet JBOOS_EJB_WEB_INF_CLASSES_SET = new
AntCopyUtils.FileSet()
- .include("import\\.sql") //$NON-NLS-1$
- .include("seam\\.properties")
- .exclude(".*/WEB-INF"); //$NON-NLS-1$
-
public static String DROOLS_LIB_SEAM_RELATED_PATH = "lib"; //$NON-NLS-1$
- public static String SEAM_LIB_RELATED_PATH = "lib"; //$NON-NLS-1$
-
- public static String WEB_LIBRARIES_RELATED_PATH = "WEB-INF/lib";
//$NON-NLS-1$
-
public void doExecute(final IProject project, IProjectFacetVersion fv,
Object config, IProgressMonitor monitor) throws CoreException {
final IDataModel model = (IDataModel)config;
- IFacetedProjectWorkingCopy fc =
(IFacetedProjectWorkingCopy)model.getProperty(IFacetDataModelProperties.FACETED_PROJECT_WORKING_COPY);
- Set<IProjectFacetVersion> fvd = fc.getProjectFacets();
// get WebContents folder path from DWP model
IVirtualComponent component = ComponentCore.createComponent(project);
@@ -170,8 +100,6 @@
model.setProperty(ISeamFacetDataModelProperties.HIBERNATE_HBM2DDL_AUTO,"create-drop");
//$NON-NLS-1$
}
- final String consoleName =
isWarConfiguration(model)?project.getName():project.getName()+"-ejb";
-
final File webContentFolder = webRootFolder.getLocation().toFile();
final File webInfFolder = new File(webContentFolder,"WEB-INF");
//$NON-NLS-1$
final File webInfClasses = new File(webInfFolder,"classes"); //$NON-NLS-1$
@@ -179,7 +107,6 @@
webInfClassesMetaInf.mkdirs();
final File webLibFolder = new File(webContentFolder,WEB_LIBRARIES_RELATED_PATH);
final File srcFolder = isWarConfiguration(model)?new
File(srcRootFolder.getUnderlyingFolder().getLocation().toFile(),"model"):srcRootFolder.getUnderlyingFolder().getLocation().toFile();
//$NON-NLS-1$
- final File webMetaInf = new File(webContentFolder, "META-INF");
//$NON-NLS-1$
final SeamRuntime selectedRuntime =
SeamRuntimeManager.getInstance().findRuntimeByName(model.getProperty(ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME).toString());
final String seamHomePath = selectedRuntime.getHomeDir();
@@ -187,7 +114,6 @@
final File seamHomeFolder = new File(seamHomePath);
final File seamLibFolder = new File(seamHomePath,SEAM_LIB_RELATED_PATH);
final File seamGenResFolder = new File(seamHomePath,"seam-gen/resources");
//$NON-NLS-1$
- final File seamGenResMetainfFolder = new File(seamGenResFolder,"META-INF");
//$NON-NLS-1$
final File droolsLibFolder = new File(seamHomePath,DROOLS_LIB_SEAM_RELATED_PATH);
final File seamGenHomeFolder = new File(seamHomePath,"seam-gen");
//$NON-NLS-1$
@@ -242,10 +168,8 @@
hibernateDialectFilterSet.addFilterSet(projectFilterSet);
hibernateDialectFilterSet.addFilterSet(SeamFacetFilterSetFactory.createHibernateDialectFilterSet(model));
-// createTestProject(model,project,selectedRuntime);
-
//
********************************************************************************************
- // Handle WAR/EAR configurations
+ // Handle WAR configurations
//
********************************************************************************************
if(isWarConfiguration(model)) {
AntCopyUtils.FileSet webInfClassesSet = new
AntCopyUtils.FileSet(JBOOS_WAR_WEB_INF_CLASSES_SET).dir(seamGenResFolder);
@@ -318,165 +242,21 @@
WtpUtils.setClasspathEntryAsExported(project, new
Path("org.eclipse.jst.j2ee.internal.web.container"), monitor); //$NON-NLS-1$
} else {
- model.setProperty(ISeamFacetDataModelProperties.SEAM_EJB_PROJECT,
project.getName()+"-ejb"); //$NON-NLS-1$
- model.setProperty(ISeamFacetDataModelProperties.SEAM_EAR_PROJECT,
project.getName()+"-ear"); //$NON-NLS-1$
-
// In case of EAR configuration
- AntCopyUtils.copyFiles(seamHomeFolder,webLibFolder,new
AntCopyUtils.FileSetFileFilter(new
AntCopyUtils.FileSet(JBOSS_WAR_LIB_FILESET_EAR_CONFIG).dir(seamHomeFolder)));
- AntCopyUtils.copyFiles(seamLibFolder,webLibFolder,new
AntCopyUtils.FileSetFileFilter(new
AntCopyUtils.FileSet(JBOSS_WAR_LIB_FILESET_EAR_CONFIG).dir(seamLibFolder)));
- AntCopyUtils.copyFiles(droolsLibFolder,webLibFolder,new
AntCopyUtils.FileSetFileFilter(new
AntCopyUtils.FileSet(JBOSS_WAR_LIB_FILESET_EAR_CONFIG).dir(droolsLibFolder)));
- AntCopyUtils.copyFileToFolder(new
File(seamGenResFolder,"messages_en.properties"),srcFolder, true); //$NON-NLS-1$
-
- File ear = new
File(project.getLocation().removeLastSegments(1).toFile(),model.getProperty(ISeamFacetDataModelProperties.SEAM_PROJECT_NAME)+"-ear");
//$NON-NLS-1$
- File ejb = new
File(project.getLocation().removeLastSegments(1).toFile(),model.getProperty(ISeamFacetDataModelProperties.SEAM_PROJECT_NAME)+"-ejb");
//$NON-NLS-1$
- ear.mkdir();
- ejb.mkdir();
-
- try {
- FilterSet filterSet = new FilterSet();
- filterSet.addFilter("projectName", project.getName()); //$NON-NLS-1$
- filterSet.addFilter("runtimeName", WtpUtils.getServerRuntimeName(project));
//$NON-NLS-1$
- if(model.getProperty(ISeamFacetDataModelProperties.JDBC_DRIVER_JAR_PATH)!=null) {
- File driver = new
File(((String[])model.getProperty(ISeamFacetDataModelProperties.JDBC_DRIVER_JAR_PATH))[0]);
- filterSet.addFilter("driverJar"," " + driver.getName() +
"\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- } else {
- filterSet.addFilter("driverJar",""); //$NON-NLS-1$
//$NON-NLS-2$
- }
-
- File ejbTemplateDir = new
File(SeamFacetInstallDataModelProvider.getTemplatesFolder(),"ejb");
- AntCopyUtils.FileSet excludeCvsSvn = new
AntCopyUtils.FileSet(CVS_SVN).dir(ejbTemplateDir);
-
- AntCopyUtils.copyFilesAndFolders(
- ejbTemplateDir, //$NON-NLS-1$
- ejb, new AntCopyUtils.FileSetFileFilter(excludeCvsSvn),
- new FilterSetCollection(filterSet), true);
-
- //
*******************************************************************************************
- // Copy sources to ejb project in case of EAR configuration
- //
*******************************************************************************************
- AntCopyUtils.copyFileToFile(
- new File(seamGenHomeFolder,"src/Authenticator.java"), //$NON-NLS-1$
- new File(ejb,"ejbModule/" +
model.getProperty(ISeamFacetDataModelProperties.SESSION_BEAN_PACKAGE_NAME).toString().replace('.',
'/')+"/"+"Authenticator.java"), //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$
- new FilterSetCollection(filtersFilterSet), true);
- AntCopyUtils.copyFileToFile(
- persistenceFile,
- new File(ejb,"ejbModule/META-INF/persistence.xml"), //$NON-NLS-1$
- viewFilterSetCollection, true);
-
- createComponentsProperties(new File(ejb,"ejbModule"),
isWarConfiguration(model)?"":project.getName()+"-ear", false);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- AntCopyUtils.FileSet ejbSrcResourcesSet = new
AntCopyUtils.FileSet(JBOOS_EJB_WEB_INF_CLASSES_SET).dir(seamGenResFolder);
- AntCopyUtils.copyFilesAndFolders(
- seamGenResFolder,new File(ejb,"ejbModule"),new
AntCopyUtils.FileSetFileFilter(ejbSrcResourcesSet), viewFilterSetCollection, true);
//$NON-NLS-1$
-
- //
********************************************************************************************
- // Copy security.drl to source folder
- //
********************************************************************************************
- AntCopyUtils.copyFileToFolder(new File(seamGenResFolder,"security.drl"),
new File(ejb,"ejbModule/"), true); //$NON-NLS-1$ //$NON-NLS-2$
-
- File resources = new File(ear,"resources");
- AntCopyUtils.copyFileToFile(
- dataSourceDsFile,
- new File(resources,project.getName()+"-ds.xml"), //$NON-NLS-1$
//$NON-NLS-2$
- viewFilterSetCollection, true);
-
- AntCopyUtils.copyFileToFolder(
- new File(seamGenResFolder,"META-INF/ejb-jar.xml"), //$NON-NLS-1$
- new File(ejb,"ejbModule/META-INF/"), //$NON-NLS-1$
- viewFilterSetCollection, true);
-
- /*AntCopyUtils.copyFileToFolder(
- hibernateConsolePref,
- new File(ejb,".settings"), //$NON-NLS-1$
- new FilterSetCollection(projectFilterSet), true);*/
-
- FilterSet ejbFilterSet = new FilterSet();
- ejbFilterSet.addFilter("projectName",ejb.getName()); //$NON-NLS-1$
-
- AntCopyUtils.copyFileToFile(
- hibernateConsoleLaunchFile,
- new File(ejb,ejb.getName()+".launch"), //$NON-NLS-1$
- new FilterSetCollection(ejbFilterSet), true);
-
- AntCopyUtils.copyFileToFolder(
- hibernateConsolePropsFile,
- ejb,
- hibernateDialectFilterSet, true);
-
- File earContentsFolder = new File(ear,"EarContent"); //$NON-NLS-1$
-
- FilterSet earFilterSet = new FilterSet();
- earFilterSet.addFilter("projectName",ear.getName()+".ear");
//$NON-NLS-1$ //$NON-NLS-2$
-
- AntCopyUtils.copyFileToFolder(
- new File(seamGenResFolder,"META-INF/jboss-app.xml"), //$NON-NLS-1$
- new File(earContentsFolder,"META-INF"), //$NON-NLS-1$
- new FilterSetCollection(earFilterSet),true);
-
- // Copy configuration files from template
- AntCopyUtils.copyFilesAndFolders(
- new
File(SeamFacetInstallDataModelProvider.getTemplatesFolder(),"ear-seam2"),
//$NON-NLS-1$
- ear, new AntCopyUtils.FileSetFileFilter(excludeCvsSvn),
- new FilterSetCollection(filterSet), true);
-
- // Fill ear contents
- AntCopyUtils.copyFiles(seamHomeFolder,earContentsFolder,new
AntCopyUtils.FileSetFileFilter(new
AntCopyUtils.FileSet(JBOSS_EAR_CONTENT).dir(seamHomeFolder)));
- AntCopyUtils.copyFiles(seamLibFolder,earContentsFolder,new
AntCopyUtils.FileSetFileFilter(new
AntCopyUtils.FileSet(JBOSS_EAR_CONTENT).dir(seamLibFolder)));
- AntCopyUtils.copyFiles(droolsLibFolder,earContentsFolder,new
AntCopyUtils.FileSetFileFilter(new
AntCopyUtils.FileSet(JBOSS_EAR_CONTENT).dir(droolsLibFolder)));
- AntCopyUtils.copyFiles(seamLibFolder,earContentsFolder,new
AntCopyUtils.FileSetFileFilter(new
AntCopyUtils.FileSet(JBOSS_EAR_CONTENT).dir(seamLibFolder)));
- AntCopyUtils.copyFiles(seamGenResFolder,earContentsFolder,new
AntCopyUtils.FileSetFileFilter(new
AntCopyUtils.FileSet(JBOSS_EAR_CONTENT).dir(seamGenResFolder)));
-
- 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) {
- if(name.lastIndexOf(".jar")>0) return true; //$NON-NLS-1$
- return false;
- }
- });
- 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$
- File ejbMetaInf = new File(ejb,"ejbModule/META-INF"); //$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);
- }
+ AntCopyUtils.copyFiles(seamHomeFolder, webLibFolder, new
AntCopyUtils.FileSetFileFilter(new
AntCopyUtils.FileSet(JBOSS_WAR_LIB_FILESET_EAR_CONFIG).dir(seamHomeFolder)));
+ AntCopyUtils.copyFiles(seamLibFolder, webLibFolder, new
AntCopyUtils.FileSetFileFilter(new
AntCopyUtils.FileSet(JBOSS_WAR_LIB_FILESET_EAR_CONFIG).dir(seamLibFolder)));
+ AntCopyUtils.copyFiles(droolsLibFolder, webLibFolder, new
AntCopyUtils.FileSetFileFilter(new
AntCopyUtils.FileSet(JBOSS_WAR_LIB_FILESET_EAR_CONFIG).dir(droolsLibFolder)));
+ AntCopyUtils.copyFileToFolder(new File(seamGenResFolder,
"messages_en.properties"), srcFolder, true); //$NON-NLS-1$
}
ClasspathHelper.addClasspathEntries(project, fv);
+ // TODO
createSeamProjectPreferenes(project, model);
EclipseResourceUtil.addNatureToProject(project, ISeamProject.NATURE_ID);
- toggleHibernateOnProject(project, consoleName);
-
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
- String wsPath = project.getLocation().removeLastSegments(1)
- .toFile().getAbsoluteFile().getPath();
-
- IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
-
- if(!isWarConfiguration(model)) {
- IProject ejbProjectToBeImported =
wsRoot.getProject(project.getName()+"-ejb");
- ResourcesUtils.importExistingProject(ejbProjectToBeImported,
wsPath+"/"+project.getName()+"-ejb",
project.getName()+"-ejb", monitor, false);
- toggleHibernateOnProject(ejbProjectToBeImported, consoleName);
- IProjectFacet sf = ProjectFacetsManager.getProjectFacet("jst.ejb");
- IProjectFacetVersion pfv =
ProjectFacetsManager.create(ejbProjectToBeImported).getInstalledVersion(sf);
- ClasspathHelper.addClasspathEntries(ejbProjectToBeImported, pfv);
-
- IProject earProjectToBeImported =
wsRoot.getProject(project.getName()+"-ear");
- ResourcesUtils.importExistingProject(earProjectToBeImported,
wsPath+"/"+project.getName()+"-ear",
project.getName()+"-ear", monitor, false);
- }
}
/*
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam2ProjectCreator.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam2ProjectCreator.java 2008-09-30
16:51:41 UTC (rev 10574)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam2ProjectCreator.java 2008-09-30
17:01:27 UTC (rev 10575)
@@ -32,7 +32,7 @@
public class Seam2ProjectCreator extends SeamProjectCreator {
// test/*.jar are duplicated here since the filtering seem to be assymetric when
matching
- protected static AntCopyUtils.FileSet JBOSS_TEST_LIB_FILESET = new
AntCopyUtils.FileSet()
+ private static AntCopyUtils.FileSet JBOSS_TEST_LIB_FILESET = new AntCopyUtils.FileSet()
.include("testng\\.jar") //$NON-NLS-1$
.include("test/hibernate-all\\.jar") //$NON-NLS-1$
.include("hibernate-all\\.jar") //$NON-NLS-1$
@@ -48,12 +48,24 @@
.exclude(".*/CVS") //$NON-NLS-1$
.exclude(".*/\\.svn"); //$NON-NLS-1$
+ private static AntCopyUtils.FileSet JBOSS_EAR_CONTENT = new AntCopyUtils.FileSet()
+ .include("antlr-runtime.jar") //$NON-NLS-1$
+ .include("drools-compiler.*\\.jar") //$NON-NLS-1$
+ .include("drools-core.*\\.jar") //$NON-NLS-1$
+ .include("jboss-seam.jar") //$NON-NLS-1$
+ .include("jboss-el.*.jar") //$NON-NLS-1$
+ .include("mvel14.*.jar") //$NON-NLS-1$
+ .include("jbpm-jpdl.*\\.jar") //$NON-NLS-1$
+ .include("richfaces-api.*\\.jar"); //$NON-NLS-1$
+
/**
* @param model Seam facet data model
* @param seamWebProject Seam web project
*/
public Seam2ProjectCreator(IDataModel model, IProject seamWebProject) {
super(model, seamWebProject);
+ viewFilterSetCollection.addFilterSet(SeamFacetFilterSetFactory.createHibernateDialectFilterSet(model));
+ droolsLibFolder = new File(seamHomePath,
Seam2FacetInstallDelegate.DROOLS_LIB_SEAM_RELATED_PATH);
}
@Override
@@ -80,8 +92,8 @@
// TODO: why are these filters not shared!?
filterSet.addConfiguredFilterSet(SeamFacetFilterSetFactory.createHibernateDialectFilterSet(model));
- AntCopyUtils.FileSet includeLibs = new
AntCopyUtils.FileSet(JBOSS_TEST_LIB_FILESET).dir(new
File(seamRuntime.getHomeDir(),"lib")); //$NON-NLS-1$
- AntCopyUtils.FileSet secondSetincludeLibs = new
AntCopyUtils.FileSet(JBOSS_TEST_LIB_FILESET).dir(new
File(seamRuntime.getHomeDir(),"lib/test")); //$NON-NLS-1$
+ AntCopyUtils.FileSet includeLibs = new
AntCopyUtils.FileSet(getJBossTestLibFileset()).dir(new
File(seamRuntime.getHomeDir(),"lib")); //$NON-NLS-1$
+ AntCopyUtils.FileSet secondSetincludeLibs = new
AntCopyUtils.FileSet(getJBossTestLibFileset()).dir(new
File(seamRuntime.getHomeDir(),"lib/test")); //$NON-NLS-1$
File[] firstlibs = includeLibs.getDir().listFiles(new
AntCopyUtils.FileSetFileFilter(includeLibs));
File[] secondLibs = secondSetincludeLibs.getDir().listFiles(new
AntCopyUtils.FileSetFileFilter(secondSetincludeLibs));
@@ -161,4 +173,19 @@
SeamFacetAbstractInstallDelegate.createComponentsProperties(testSrcDir, "",
true); //$NON-NLS-1$
}
+
+ @Override
+ protected void createEjbProject() {
+ super.createEjbProject();
+ // Copy security.drl to source folder
+ AntCopyUtils.copyFileToFolder(new File(seamGenResFolder, "security.drl"), new
File(ejbProjectFolder, "ejbModule/"), true); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ protected AntCopyUtils.FileSet getJBossTestLibFileset() {
+ return JBOSS_TEST_LIB_FILESET;
+ }
+
+ protected AntCopyUtils.FileSet getJbossEarContent() {
+ return JBOSS_EAR_CONTENT;
+ }
}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetAbstractInstallDelegate.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetAbstractInstallDelegate.java 2008-09-30
16:51:41 UTC (rev 10574)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetAbstractInstallDelegate.java 2008-09-30
17:01:27 UTC (rev 10575)
@@ -84,7 +84,42 @@
public static String RESTRICT_RAW_XHTML = "Restrict raw XHTML Documents";
public static String XHTML = "XHTML";
public static String WEB_RESOURCE_COLLECTION_PATTERN = "*.xhtml";
+ public static String SEAM_LIB_RELATED_PATH = "lib"; //$NON-NLS-1$
+ public static final String DEV_WAR_PROFILE = "dev-war"; //$NON-NLS-1$
+ public static final String DEV_EAR_PROFILE = "dev"; //$NON-NLS-1$
+ public static AntCopyUtils.FileSet VIEW_FILESET = new AntCopyUtils.FileSet()
+ .include("home\\.xhtml") //$NON-NLS-1$
+ .include("error\\.xhtml") //$NON-NLS-1$
+ .include("login\\.xhtml") //$NON-NLS-1$
+ .include("login\\.page.xml") //$NON-NLS-1$
+ .include("index\\.html") //$NON-NLS-1$
+ .include("layout") //$NON-NLS-1$
+ .include("layout/.*") //$NON-NLS-1$
+ .include("stylesheet") //$NON-NLS-1$
+ .include("stylesheet/.*") //$NON-NLS-1$
+ .include("img/.*") //$NON-NLS-1$
+ .include("img") //$NON-NLS-1$
+ .exclude(".*/.*\\.ftl") //$NON-NLS-1$
+ .exclude(".*/CVS") //$NON-NLS-1$
+ .exclude(".*/\\.svn"); //$NON-NLS-1$
+
+ public static AntCopyUtils.FileSet JBOOS_WAR_WEBINF_SET = new AntCopyUtils.FileSet()
+ .include("WEB-INF") //$NON-NLS-1$
+ //.include("WEB-INF/web\\.xml") //$NON-NLS-1$
+ .include("WEB-INF/pages\\.xml") //$NON-NLS-1$
+ .include("WEB-INF/jboss-web\\.xml") //$NON-NLS-1$
+ .include("WEB-INF/faces-config\\.xml") //$NON-NLS-1$
+ .include("WEB-INF/componets\\.xml"); //$NON-NLS-1$
+
+ public static AntCopyUtils.FileSet JBOOS_WAR_WEB_INF_CLASSES_SET = new
AntCopyUtils.FileSet()
+ .include("import\\.sql") //$NON-NLS-1$
+ .include("security\\.drl") //$NON-NLS-1$
+ .include("seam\\.properties") //$NON-NLS-1$
+ .include("messages_en\\.properties"); //$NON-NLS-1$
+
+ public static String WEB_LIBRARIES_RELATED_PATH = "WEB-INF/lib";
//$NON-NLS-1$
+
static AntCopyUtils.FileSet CVS_SVN = new AntCopyUtils.FileSet()
.include(".*") //$NON-NLS-1$
.exclude(".*/CVS") //$NON-NLS-1$
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegate.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegate.java 2008-09-30
16:51:41 UTC (rev 10574)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegate.java 2008-09-30
17:01:27 UTC (rev 10575)
@@ -11,18 +11,12 @@
package org.jboss.tools.seam.internal.core.project.facet;
import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.util.Properties;
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.IProject;
import org.eclipse.core.resources.IResource;
-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;
@@ -36,13 +30,9 @@
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-import org.eclipse.wst.common.project.facet.core.IProjectFacet;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
-import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
-import org.jboss.tools.common.util.ResourcesUtils;
import org.jboss.tools.seam.core.ISeamProject;
-import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.core.project.facet.SeamRuntime;
import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
@@ -63,19 +53,6 @@
private static final String ORG_AJAX4JSF_SKIN = "org.ajax4jsf.SKIN";
- /**
- *
- **/
- public static final String DEV_WAR_PROFILE = "dev-war"; //$NON-NLS-1$
-
- /**
- *
- */
- public static final String DEV_EAR_PROFILE = "dev"; //$NON-NLS-1$
-
- /**
- *
- */
public static final AntCopyUtils.FileSet JBOSS_WAR_LIB_FILESET_WAR_CONFIG = new
AntCopyUtils.FileSet()
.include("ajax4jsf.*\\.jar") //$NON-NLS-1$
.include("richfaces.*\\.jar") //$NON-NLS-1$
@@ -102,21 +79,6 @@
// el-ri needed for JBIDE-939
.include("el-ri.*\\.jar"); //$NON-NLS-1$
- private static final String ORG_AJAX4JSF_FILTER_NAME = "ajax4jsf";
-
- private static final String ORG_AJAX4JSF_FILTER_CLASS =
"org.ajax4jsf.Filter";
-
- private static final String ORG_AJAX4JSF_FILTER_DISPLAY_NAME = "Ajax4jsf
Filter";
-
- private static final String ORG_AJAX4JSF_FILTER_MAPPING = "*.seam";
-
- private static final String ORG_JBOSS_SEAM_UI_SEAMFACELETVIEWHANDLER =
"org.jboss.seam.ui.facelet.SeamFaceletViewHandler";
-
- private static final String ORG_AJAX4JSF_VIEW_HANDLERS =
"org.ajax4jsf.VIEW_HANDLERS";
-
- /**
- *
- */
public static AntCopyUtils.FileSet JBOSS_WAR_LIB_FILESET_EAR_CONFIG = new
AntCopyUtils.FileSet()
.include("ajax4jsf.*\\.jar") //$NON-NLS-1$
.include("richfaces.*\\.jar") //$NON-NLS-1$
@@ -132,98 +94,20 @@
.include("jsf-facelets\\.jar") //$NON-NLS-1$
.include("oscache.*\\.jar"); //$NON-NLS-1$
- /**
- *
- */
- public static AntCopyUtils.FileSet JBOSS_EAR_CONTENT = new AntCopyUtils.FileSet()
- .include("antlr.*\\.jar") //$NON-NLS-1$
- .include("commons-jci-core.*\\.jar") //$NON-NLS-1$
- .include("commons-jci-janino.*\\.jar") //$NON-NLS-1$
- .include("drools-compiler.*\\.jar") //$NON-NLS-1$
- .include("drools-core.*\\.jar") //$NON-NLS-1$
- .include("janino.*\\.jar") //$NON-NLS-1$
- .include("jboss-seam.jar") //$NON-NLS-1$
- .include("jbpm.*\\.jar") //$NON-NLS-1$
- .include("security\\.drl") //$NON-NLS-1$
- .include("stringtemplate.*\\.jar") //$NON-NLS-1$
- // el-ri needed for JBIDE-939
- .include("el-ri.*\\.jar"); //$NON-NLS-1$
+ private static final String ORG_AJAX4JSF_FILTER_NAME = "ajax4jsf";
- /**
- *
- */
- public static AntCopyUtils.FileSet JBOSS_EAR_CONTENT_META_INF = new
AntCopyUtils.FileSet()
- .include("META-INF/application\\.xml") //$NON-NLS-1$
- .include("META-INF/jboss-app\\.xml"); //$NON-NLS-1$
+ private static final String ORG_AJAX4JSF_FILTER_CLASS =
"org.ajax4jsf.Filter";
- /**
- *
- */
- public static AntCopyUtils.FileSet VIEW_FILESET = new AntCopyUtils.FileSet()
- .include("home\\.xhtml") //$NON-NLS-1$
- .include("error\\.xhtml") //$NON-NLS-1$
- .include("login\\.xhtml") //$NON-NLS-1$
- .include("login\\.page.xml") //$NON-NLS-1$
- .include("index\\.html") //$NON-NLS-1$
- .include("layout") //$NON-NLS-1$
- .include("layout/.*") //$NON-NLS-1$
- .include("stylesheet") //$NON-NLS-1$
- .include("stylesheet/.*") //$NON-NLS-1$
- .include("img/.*") //$NON-NLS-1$
- .include("img") //$NON-NLS-1$
- .exclude(".*/.*\\.ftl") //$NON-NLS-1$
- .exclude(".*/CVS") //$NON-NLS-1$
- .exclude(".*/\\.svn"); //$NON-NLS-1$
+ private static final String ORG_AJAX4JSF_FILTER_DISPLAY_NAME = "Ajax4jsf
Filter";
- /**
- *
- */
- public static AntCopyUtils.FileSet JBOOS_WAR_WEBINF_SET = new AntCopyUtils.FileSet()
- .include("WEB-INF") //$NON-NLS-1$
- //.include("WEB-INF/web\\.xml") //$NON-NLS-1$
- .include("WEB-INF/pages\\.xml") //$NON-NLS-1$
- .include("WEB-INF/jboss-web\\.xml") //$NON-NLS-1$
- .include("WEB-INF/faces-config\\.xml") //$NON-NLS-1$
- .include("WEB-INF/componets\\.xml"); //$NON-NLS-1$
+ private static final String ORG_AJAX4JSF_FILTER_MAPPING = "*.seam";
- /**
- *
- */
- public static AntCopyUtils.FileSet JBOOS_WAR_WEB_INF_CLASSES_SET = new
AntCopyUtils.FileSet()
- .include("import\\.sql") //$NON-NLS-1$
- .include("security\\.drl") //$NON-NLS-1$
- .include("seam\\.properties") //$NON-NLS-1$
- .include("messages_en\\.properties"); //$NON-NLS-1$
+ private static final String ORG_JBOSS_SEAM_UI_SEAMFACELETVIEWHANDLER =
"org.jboss.seam.ui.facelet.SeamFaceletViewHandler";
- /**
- *
- */
- public static AntCopyUtils.FileSet JBOOS_EJB_WEB_INF_CLASSES_SET = new
AntCopyUtils.FileSet()
- .include("import\\.sql") //$NON-NLS-1$
- .include("seam\\.properties")
- .exclude(".*/WEB-INF"); //$NON-NLS-1$
+ private static final String ORG_AJAX4JSF_VIEW_HANDLERS =
"org.ajax4jsf.VIEW_HANDLERS";
- /**
- *
- */
- public static AntCopyUtils.FileSet JBOSS_EAR_META_INF_SET = new AntCopyUtils.FileSet()
- .include("META-INF/jboss-app\\.xml"); //$NON-NLS-1$
-
- /**
- *
- */
public static String DROOLS_LIB_SEAM_RELATED_PATH = "drools/lib";
//$NON-NLS-1$
- /**
- *
- */
- public static String SEAM_LIB_RELATED_PATH = "lib"; //$NON-NLS-1$
-
- /**
- *
- */
- public static String WEB_LIBRARIES_RELATED_PATH = "WEB-INF/lib";
//$NON-NLS-1$
-
private void doExecuteForWar(final IProject project, IProjectFacetVersion fv,
IDataModel model, IProgressMonitor monitor) throws CoreException {
@@ -245,8 +129,6 @@
model.setProperty(ISeamFacetDataModelProperties.HIBERNATE_HBM2DDL_AUTO,
"create-drop"); //$NON-NLS-1$
}
- final String consoleName = isWarConfiguration(model) ? project.getName() :
project.getName() + "-ejb";
-
final File webContentFolder = webRootFolder.getLocation().toFile();
final File webInfFolder = new File(webContentFolder, "WEB-INF");
//$NON-NLS-1$
final File webInfClasses = new File(webInfFolder, "classes"); //$NON-NLS-1$
@@ -254,7 +136,6 @@
webInfClassesMetaInf.mkdirs();
final File webLibFolder = new File(webContentFolder, WEB_LIBRARIES_RELATED_PATH);
final File srcFolder = isWarConfiguration(model) ? new
File(srcRootFolder.getUnderlyingFolder().getLocation().toFile(), "model") :
srcRootFolder.getUnderlyingFolder().getLocation().toFile(); //$NON-NLS-1$
- final File webMetaInf = new File(webContentFolder, "META-INF");
//$NON-NLS-1$
final SeamRuntime selectedRuntime =
SeamRuntimeManager.getInstance().findRuntimeByName(model.getProperty(ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME).toString());
final String seamHomePath = selectedRuntime.getHomeDir();
@@ -313,17 +194,15 @@
hibernateDialectFilterSet.addFilterSet(projectFilterSet);
hibernateDialectFilterSet.addFilterSet(SeamFacetFilterSetFactory.createHibernateDialectFilterSet(model));
-// createTestProject(model, project, selectedRuntime);
-
//
********************************************************************************************
- // Handle WAR/EAR configurations
+ // Handle WAR configurations
//
********************************************************************************************
if (isWarConfiguration(model)) {
AntCopyUtils.FileSet webInfClassesSet = new
AntCopyUtils.FileSet(JBOOS_WAR_WEB_INF_CLASSES_SET).dir(seamGenResFolder);
AntCopyUtils.copyFilesAndFolders(
seamGenResFolder, srcFolder, new AntCopyUtils.FileSetFileFilter(webInfClassesSet),
viewFilterSetCollection, true);
- createComponentsProperties(srcFolder, isWarConfiguration(model) ? "" :
project.getName() + "-ear", false); //$NON-NLS-1$ //$NON-NLS-2$
+ createComponentsProperties(srcFolder, "", false); //$NON-NLS-1$
//$NON-NLS-2$
/*AntCopyUtils.copyFileToFolder(
hibernateConsolePref,
@@ -383,163 +262,21 @@
WtpUtils.setClasspathEntryAsExported(project, new
Path("org.eclipse.jst.j2ee.internal.web.container"), monitor); //$NON-NLS-1$
} else {
- model.setProperty(ISeamFacetDataModelProperties.SEAM_EJB_PROJECT, project.getName() +
"-ejb"); //$NON-NLS-1$
- model.setProperty(ISeamFacetDataModelProperties.SEAM_EAR_PROJECT, project.getName() +
"-ear"); //$NON-NLS-1$
-
// In case of EAR configuration
AntCopyUtils.copyFiles(seamHomeFolder, webLibFolder, new
AntCopyUtils.FileSetFileFilter(new
AntCopyUtils.FileSet(JBOSS_WAR_LIB_FILESET_EAR_CONFIG).dir(seamHomeFolder)));
AntCopyUtils.copyFiles(seamLibFolder, webLibFolder, new
AntCopyUtils.FileSetFileFilter(new
AntCopyUtils.FileSet(JBOSS_WAR_LIB_FILESET_EAR_CONFIG).dir(seamLibFolder)));
AntCopyUtils.copyFiles(droolsLibFolder, webLibFolder, new
AntCopyUtils.FileSetFileFilter(new
AntCopyUtils.FileSet(JBOSS_WAR_LIB_FILESET_EAR_CONFIG).dir(droolsLibFolder)));
AntCopyUtils.copyFileToFolder(new File(seamGenResFolder,
"messages_en.properties"), srcFolder, true); //$NON-NLS-1$
-
- File ear = new File(project.getLocation().removeLastSegments(1).toFile(),
model.getProperty(ISeamFacetDataModelProperties.SEAM_PROJECT_NAME) + "-ear");
//$NON-NLS-1$
- File ejb = new File(project.getLocation().removeLastSegments(1).toFile(),
model.getProperty(ISeamFacetDataModelProperties.SEAM_PROJECT_NAME) + "-ejb");
//$NON-NLS-1$
- ear.mkdir();
- ejb.mkdir();
-
- try {
- FilterSet filterSet = new FilterSet();
- filterSet.addFilter("projectName", project.getName()); //$NON-NLS-1$
- filterSet.addFilter("runtimeName", WtpUtils.getServerRuntimeName(project));
//$NON-NLS-1$
- if (model.getProperty(ISeamFacetDataModelProperties.JDBC_DRIVER_JAR_PATH) != null) {
- File driver = new File(((String[])
model.getProperty(ISeamFacetDataModelProperties.JDBC_DRIVER_JAR_PATH))[0]);
- filterSet.addFilter("driverJar", " " + driver.getName() +
"\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- } else {
- filterSet.addFilter("driverJar", ""); //$NON-NLS-1$
//$NON-NLS-2$
- }
-
- File ejbTemplateDir = new
File(SeamFacetInstallDataModelProvider.getTemplatesFolder(),"ejb");
- AntCopyUtils.FileSet excludeCvsSvn = new
AntCopyUtils.FileSet(CVS_SVN).dir(ejbTemplateDir);
-
- AntCopyUtils.copyFilesAndFolders(
- ejbTemplateDir, //$NON-NLS-1$
- ejb, new AntCopyUtils.FileSetFileFilter(excludeCvsSvn),
- new FilterSetCollection(filterSet), true);
-
- //
*******************************************************************************************
- // Copy sources to ejb project in case of EAR configuration
- //
*******************************************************************************************
- AntCopyUtils.copyFileToFile(
- new File(seamGenHomeFolder, "src/Authenticator.java"), //$NON-NLS-1$
- new File(ejb, "ejbModule/" +
model.getProperty(ISeamFacetDataModelProperties.SESSION_BEAN_PACKAGE_NAME).toString().replace('.',
'/') + "/" + "Authenticator.java"), //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$
- new FilterSetCollection(filtersFilterSet), true);
- AntCopyUtils.copyFileToFile(
- persistenceFile,
- new File(ejb, "ejbModule/META-INF/persistence.xml"), //$NON-NLS-1$
- viewFilterSetCollection, true);
-
- createComponentsProperties(new File(ejb, "ejbModule"),
isWarConfiguration(model) ? "" : project.getName() + "-ear", false);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- AntCopyUtils.FileSet ejbSrcResourcesSet = new
AntCopyUtils.FileSet(JBOOS_EJB_WEB_INF_CLASSES_SET).dir(seamGenResFolder);
- AntCopyUtils.copyFilesAndFolders(
- seamGenResFolder, new File(ejb, "ejbModule"), new
AntCopyUtils.FileSetFileFilter(ejbSrcResourcesSet), viewFilterSetCollection, true);
//$NON-NLS-1$
-
- AntCopyUtils.copyFileToFolder(
- new File(seamGenResFolder, "META-INF/ejb-jar.xml"), //$NON-NLS-1$
- new File(ejb, "ejbModule/META-INF/"), //$NON-NLS-1$
- viewFilterSetCollection, true);
-
- /*AntCopyUtils.copyFileToFolder(
- hibernateConsolePref,
- new File(ejb,".settings"), //$NON-NLS-1$
- new FilterSetCollection(projectFilterSet), true);*/
-
- FilterSet ejbFilterSet = new FilterSet();
- ejbFilterSet.addFilter("projectName", ejb.getName()); //$NON-NLS-1$
-
- AntCopyUtils.copyFileToFile(
- hibernateConsoleLaunchFile,
- new File(ejb, ejb.getName() + ".launch"), //$NON-NLS-1$
- new FilterSetCollection(ejbFilterSet), true);
-
- AntCopyUtils.copyFileToFolder(
- hibernateConsolePropsFile,
- ejb,
- hibernateDialectFilterSet, true);
-
- File earContentsFolder = new File(ear, "EarContent"); //$NON-NLS-1$
-
- FilterSet earFilterSet = new FilterSet();
- earFilterSet.addFilter("projectName", ear.getName() + ".ear");
//$NON-NLS-1$ //$NON-NLS-2$
-
- AntCopyUtils.copyFileToFolder(
- new File(seamGenResFolder, "META-INF/jboss-app.xml"), //$NON-NLS-1$
- new File(earContentsFolder, "META-INF"), //$NON-NLS-1$
- new FilterSetCollection(earFilterSet), true);
-
- // Copy configuration files from template
- AntCopyUtils.copyFilesAndFolders(
- new File(SeamFacetInstallDataModelProvider.getTemplatesFolder(), "ear"),
//$NON-NLS-1$
- ear, new AntCopyUtils.FileSetFileFilter(excludeCvsSvn),
- new FilterSetCollection(filterSet), true);
-
- // Fill ear contents
- AntCopyUtils.copyFiles(seamHomeFolder, earContentsFolder, new
AntCopyUtils.FileSetFileFilter(new
AntCopyUtils.FileSet(JBOSS_EAR_CONTENT).dir(seamHomeFolder)));
- AntCopyUtils.copyFiles(seamLibFolder, earContentsFolder, new
AntCopyUtils.FileSetFileFilter(new
AntCopyUtils.FileSet(JBOSS_EAR_CONTENT).dir(seamLibFolder)));
- AntCopyUtils.copyFiles(droolsLibFolder, earContentsFolder, new
AntCopyUtils.FileSetFileFilter(new
AntCopyUtils.FileSet(JBOSS_EAR_CONTENT).dir(droolsLibFolder)));
- AntCopyUtils.copyFiles(seamLibFolder, earContentsFolder, new
AntCopyUtils.FileSetFileFilter(new
AntCopyUtils.FileSet(JBOSS_EAR_CONTENT).dir(seamLibFolder)));
- AntCopyUtils.copyFiles(seamGenResFolder, earContentsFolder, new
AntCopyUtils.FileSetFileFilter(new
AntCopyUtils.FileSet(JBOSS_EAR_CONTENT).dir(seamGenResFolder)));
-
- File resources = new File(ear, "resources");
- AntCopyUtils.copyFileToFile(
- dataSourceDsFile,
- new File(resources, project.getName() + "-ds.xml"), //$NON-NLS-1$
//$NON-NLS-2$
- viewFilterSetCollection, true);
-
- 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$
- File ejbMetaInf = new File(ejb, "ejbModule/META-INF"); //$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);
- }
- } catch (IOException e) {
- SeamCorePlugin.getPluginLog().logError(e);
- }
}
ClasspathHelper.addClasspathEntries(project, fv);
+ // TODO
createSeamProjectPreferenes(project, model);
EclipseResourceUtil.addNatureToProject(project, ISeamProject.NATURE_ID);
- toggleHibernateOnProject(project, consoleName);
-
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
- String wsPath = project.getLocation().removeLastSegments(1)
- .toFile().getAbsoluteFile().getPath();
-
- IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
-
- if (!isWarConfiguration(model)) {
- IProject ejbProjectToBeImported = wsRoot.getProject(project.getName() +
"-ejb");
- ResourcesUtils.importExistingProject(ejbProjectToBeImported, wsPath + "/" +
project.getName() + "-ejb", project.getName() + "-ejb", monitor,
false);
- toggleHibernateOnProject(ejbProjectToBeImported, consoleName);
- IProjectFacet sf = ProjectFacetsManager.getProjectFacet("jst.ejb");
- IProjectFacetVersion pfv =
ProjectFacetsManager.create(ejbProjectToBeImported).getInstalledVersion(sf);
- ClasspathHelper.addClasspathEntries(ejbProjectToBeImported, pfv);
-
- IProject earProjectToBeImported = wsRoot.getProject(project.getName() +
"-ear");
- ResourcesUtils.importExistingProject(earProjectToBeImported, wsPath + "/" +
project.getName() + "-ear", project.getName() + "-ear", monitor,
false);
- }
}
/*
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamProjectCreator.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamProjectCreator.java 2008-09-30
16:51:41 UTC (rev 10574)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamProjectCreator.java 2008-09-30
17:01:27 UTC (rev 10575)
@@ -10,13 +10,29 @@
******************************************************************************/
package org.jboss.tools.seam.internal.core.project.facet;
+import java.io.File;
+import java.io.FilenameFilter;
+import java.io.IOException;
+
+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.IProject;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jst.common.project.facet.core.ClasspathHelper;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.jboss.tools.common.util.ResourcesUtils;
+import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.core.project.facet.SeamRuntime;
import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
@@ -24,18 +40,80 @@
* @author Alexey Kazakov
* This is basic class that helps New Seam Wizard Page to create EJB, EAR and test
projects for seam WAR project.
*/
-abstract public class SeamProjectCreator {
+public class SeamProjectCreator {
protected static final String TEST_WAR_PROFILE = "test-war"; //$NON-NLS-1$
protected static final String TEST_EAR_PROFILE = "test"; //$NON-NLS-1$
+ protected static final String DEV_WAR_PROFILE = "dev-war"; //$NON-NLS-1$
+ protected static final String DEV_EAR_PROFILE = "dev"; //$NON-NLS-1$
+ protected static AntCopyUtils.FileSet JBOOS_EJB_WEB_INF_CLASSES_SET = new
AntCopyUtils.FileSet()
+ .include("import\\.sql") //$NON-NLS-1$
+ .include("seam\\.properties")
+ .exclude(".*/WEB-INF"); //$NON-NLS-1$
+
+ private static AntCopyUtils.FileSet JBOSS_TEST_LIB_FILESET = new AntCopyUtils.FileSet()
+ .include("testng-.*-jdk15\\.jar") //$NON-NLS-1$
+ .include("myfaces-api-.*\\.jar") //$NON-NLS-1$
+ .include("myfaces-impl-.*\\.jar") //$NON-NLS-1$
+ .include("servlet-api\\.jar") //$NON-NLS-1$
+ .include("hibernate-all\\.jar") //$NON-NLS-1$
+ .include("jboss-ejb3-all\\.jar") //$NON-NLS-1$
+ .include("thirdparty-all\\.jar") //$NON-NLS-1$
+ .exclude(".*/CVS") //$NON-NLS-1$
+ .exclude(".*/\\.svn"); //$NON-NLS-1$
+
+ private static AntCopyUtils.FileSet JBOSS_EAR_CONTENT = new AntCopyUtils.FileSet()
+ .include("antlr.*\\.jar") //$NON-NLS-1$
+ .include("commons-jci-core.*\\.jar") //$NON-NLS-1$
+ .include("commons-jci-janino.*\\.jar") //$NON-NLS-1$
+ .include("drools-compiler.*\\.jar") //$NON-NLS-1$
+ .include("drools-core.*\\.jar") //$NON-NLS-1$
+ .include("janino.*\\.jar") //$NON-NLS-1$
+ .include("jboss-seam.jar") //$NON-NLS-1$
+ .include("jbpm.*\\.jar") //$NON-NLS-1$
+ .include("security\\.drl") //$NON-NLS-1$
+ .include("stringtemplate.*\\.jar") //$NON-NLS-1$
+ // el-ri needed for JBIDE-939
+ .include("el-ri.*\\.jar"); //$NON-NLS-1$
+
protected IDataModel model;
protected IProject seamWebProject;
protected SeamRuntime seamRuntime;
+ protected String seamHomePath;
+ protected File seamHomeFolder;
+ protected File seamLibFolder;
+ protected File seamGenHomeFolder;
+
protected String earProjectName;
protected String ejbProjectName;
protected String testProjectName;
+ protected File earProjectFolder;
+ protected File ejbProjectFolder;
+ protected File earContentsFolder;
+
+ protected FilterSet filtersFilterSet;
+ protected File seamGenResFolder;
+ protected File persistenceFile;
+ protected File hibernateConsoleLaunchFile;
+ protected File hibernateConsolePropsFile;
+
+ protected FilterSet jdbcFilterSet;
+ protected FilterSet projectFilterSet;
+ protected FilterSetCollection viewFilterSetCollection;
+ protected FilterSetCollection hibernateDialectFilterSet;
+ protected File dataSourceDsFile;
+
+ protected File ejbTemplateDir;
+ protected AntCopyUtils.FileSet excludeCvsSvn;
+ protected FilterSet ejbFilterSet;
+
+ protected File webMetaInf;
+ protected File ejbMetaInf;
+
+ protected File droolsLibFolder;
+
/**
* @param model Seam facet data model
* @param seamWebProject Seam web project
@@ -44,15 +122,67 @@
this.model = model;
this.seamWebProject = seamWebProject;
+ // Set default project names
+ earProjectName = seamWebProject.getName() + "-ear";
+ ejbProjectName = seamWebProject.getName() + "-ejb";
+ testProjectName = seamWebProject.getName() + "-test";
+
seamRuntime =
SeamRuntimeManager.getInstance().findRuntimeByName(model.getProperty(ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME).toString());
if(seamRuntime==null) {
throw new RuntimeException("Can't get seam runtime " +
model.getProperty(ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME).toString());
}
+ seamHomePath = seamRuntime.getHomeDir();
+ seamHomeFolder = new File(seamHomePath);
+ seamLibFolder = new File(seamHomePath,
SeamFacetAbstractInstallDelegate.SEAM_LIB_RELATED_PATH);
+ seamGenHomeFolder = new File(seamHomePath, "seam-gen"); //$NON-NLS-1$
- // Set default project names
- earProjectName = seamWebProject.getName() + "-ear";
- ejbProjectName = seamWebProject.getName() + "-ejb";
- testProjectName = seamWebProject.getName() + "-test";
+ filtersFilterSet = SeamFacetFilterSetFactory.createFiltersFilterSet(model);
+ seamGenResFolder = new File(seamGenHomeFolder, "resources"); //$NON-NLS-1$
+ persistenceFile = new File(seamGenResFolder, "META-INF/persistence-" +
(SeamFacetAbstractInstallDelegate.isWarConfiguration(model) ? DEV_WAR_PROFILE :
DEV_EAR_PROFILE) + ".xml"); //$NON-NLS-1$ //$NON-NLS-2$
+ hibernateConsoleLaunchFile = new File(seamGenHomeFolder,
"hibernatetools/hibernate-console.launch"); //$NON-NLS-1$
+ hibernateConsolePropsFile = new File(seamGenHomeFolder,
"hibernatetools/hibernate-console.properties"); //$NON-NLS-1$
+ dataSourceDsFile = new File(seamGenResFolder, "datasource-ds.xml");
//$NON-NLS-1$
+
+ IVirtualComponent component = ComponentCore.createComponent(seamWebProject);
+ IVirtualFolder webRootVirtFolder = component.getRootFolder().getFolder(new
Path("/")); //$NON-NLS-1$
+ IContainer webRootFolder = webRootVirtFolder.getUnderlyingFolder();
+ File webContentFolder = webRootFolder.getLocation().toFile();
+ webMetaInf = new File(webContentFolder, "META-INF"); //$NON-NLS-1$
+ earProjectFolder = new
File(seamWebProject.getLocation().removeLastSegments(1).toFile(), earProjectName);
+ earContentsFolder = new File(earProjectFolder, "EarContent"); //$NON-NLS-1$
+ ejbProjectFolder = new
File(seamWebProject.getLocation().removeLastSegments(1).toFile(), ejbProjectName);
+ ejbMetaInf = new File(ejbProjectFolder, "ejbModule/META-INF");
//$NON-NLS-1$
+
+ jdbcFilterSet = SeamFacetFilterSetFactory.createJdbcFilterSet(model);
+ projectFilterSet = SeamFacetFilterSetFactory.createProjectFilterSet(model);
+
+ viewFilterSetCollection = new FilterSetCollection();
+ viewFilterSetCollection.addFilterSet(jdbcFilterSet);
+ viewFilterSetCollection.addFilterSet(projectFilterSet);
+
+ hibernateDialectFilterSet = new FilterSetCollection();
+ hibernateDialectFilterSet.addFilterSet(jdbcFilterSet);
+ hibernateDialectFilterSet.addFilterSet(projectFilterSet);
+ hibernateDialectFilterSet.addFilterSet(SeamFacetFilterSetFactory.createHibernateDialectFilterSet(model));
+
+ try {
+ ejbTemplateDir = new File(SeamFacetInstallDataModelProvider.getTemplatesFolder(),
"ejb");
+ } catch (IOException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+ excludeCvsSvn = new
AntCopyUtils.FileSet(SeamFacetAbstractInstallDelegate.CVS_SVN).dir(ejbTemplateDir);
+
+ ejbFilterSet = new FilterSet();
+ ejbFilterSet.addFilter("projectName", seamWebProject.getName());
//$NON-NLS-1$
+ ejbFilterSet.addFilter("runtimeName",
WtpUtils.getServerRuntimeName(seamWebProject)); //$NON-NLS-1$
+ if (model.getProperty(ISeamFacetDataModelProperties.JDBC_DRIVER_JAR_PATH) != null) {
+ File driver = new File(((String[])
model.getProperty(ISeamFacetDataModelProperties.JDBC_DRIVER_JAR_PATH))[0]);
+ ejbFilterSet.addFilter("driverJar", " " + driver.getName() +
"\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ } else {
+ ejbFilterSet.addFilter("driverJar", ""); //$NON-NLS-1$
//$NON-NLS-2$
+ }
+
+ droolsLibFolder = new File(seamHomePath,
SeamFacetInstallDelegate.DROOLS_LIB_SEAM_RELATED_PATH);
}
public IDataModel getModel() {
@@ -63,6 +193,14 @@
this.model = model;
}
+ protected AntCopyUtils.FileSet getJBossTestLibFileset() {
+ return JBOSS_TEST_LIB_FILESET;
+ }
+
+ protected AntCopyUtils.FileSet getJbossEarContent() {
+ return JBOSS_EAR_CONTENT;
+ }
+
/**
* 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
@@ -72,8 +210,54 @@
createTestProject();
final String consoleName = SeamFacetAbstractInstallDelegate.isWarConfiguration(model) ?
seamWebProject.getName() : ejbProjectName;
+ if(!SeamFacetAbstractInstallDelegate.isWarConfiguration(model)) {
+ model.setProperty(ISeamFacetDataModelProperties.SEAM_EJB_PROJECT, ejbProjectName);
+ model.setProperty(ISeamFacetDataModelProperties.SEAM_EAR_PROJECT, testProjectName);
+ 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 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);
+ }
+ }
+
+ SeamFacetAbstractInstallDelegate.toggleHibernateOnProject(seamWebProject,
consoleName);
+
String wsPath =
seamWebProject.getLocation().removeLastSegments(1).toFile().getAbsoluteFile().getPath();
IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
+
+ if (!SeamFacetAbstractInstallDelegate.isWarConfiguration(model)) {
+ IProject ejbProjectToBeImported = wsRoot.getProject(ejbProjectName);
+ ResourcesUtils.importExistingProject(ejbProjectToBeImported, wsPath + "/" +
ejbProjectName, ejbProjectName, monitor, false);
+ SeamFacetAbstractInstallDelegate.toggleHibernateOnProject(ejbProjectToBeImported,
consoleName);
+ IProjectFacet sf = ProjectFacetsManager.getProjectFacet("jst.ejb");
+ IProjectFacetVersion pfv =
ProjectFacetsManager.create(ejbProjectToBeImported).getInstalledVersion(sf);
+ ClasspathHelper.addClasspathEntries(ejbProjectToBeImported, pfv);
+
+ IProject earProjectToBeImported = wsRoot.getProject(earProjectName);
+ ResourcesUtils.importExistingProject(earProjectToBeImported, wsPath + "/" +
earProjectName, earProjectName, monitor, false);
+ }
+
IProject testProjectToBeImported = wsRoot.getProject(testProjectName);
ResourcesUtils.importExistingProject(testProjectToBeImported, wsPath + "/" +
testProjectName, testProjectName, monitor, true);
@@ -83,8 +267,66 @@
/**
* Creates test project for given seam web project.
*/
- abstract protected void createTestProject();
+ protected void createTestProject() {
+ File testProjectDir = new
File(seamWebProject.getLocation().removeLastSegments(1).toFile(), testProjectName);
//$NON-NLS-1$
+ testProjectDir.mkdir();
+ IVirtualComponent component = ComponentCore.createComponent(seamWebProject);
+ IVirtualFolder webRootVirtFolder = component.getRootFolder().getFolder(new
Path("/")); //$NON-NLS-1$
+
+ File testLibDir = new File(testProjectDir, "lib"); //$NON-NLS-1$
+ File embededEjbDir = new File(testProjectDir, "embedded-ejb"); //$NON-NLS-1$
+ File testSrcDir = new File(testProjectDir, "test-src"); //$NON-NLS-1$
+ FilterSet filterSet = new FilterSet();
+ filterSet.addFilter("projectName", seamWebProject.getName()); //$NON-NLS-1$
+ filterSet.addFilter("runtimeName",
WtpUtils.getServerRuntimeName(seamWebProject)); //$NON-NLS-1$
+ filterSet.addFilter("webRootFolder",
webRootVirtFolder.getUnderlyingFolder().getFullPath().removeFirstSegments(1).toString());
//$NON-NLS-1$
+
+ AntCopyUtils.FileSet includeLibs = new
AntCopyUtils.FileSet(getJBossTestLibFileset()).dir(new File(seamRuntime.getHomeDir(),
"lib")); //$NON-NLS-1$
+ File[] libs = includeLibs.getDir().listFiles(new
AntCopyUtils.FileSetFileFilter(includeLibs));
+ StringBuffer testLibraries = new StringBuffer();
+
+ for (File file : libs) {
+ testLibraries.append("\t<classpathentry kind=\"lib\"
path=\"lib/" + file.getName() + "\"/>\n"); //$NON-NLS-1$
//$NON-NLS-2$
+ }
+
+ StringBuffer requiredProjects = new StringBuffer();
+ requiredProjects.append("\t<classpathentry
combineaccessrules=\"false\" kind=\"src\" path=\"/" +
seamWebProject.getName() + "\"/>"); //$NON-NLS-1$ //$NON-NLS-2$
+ if (!SeamFacetAbstractInstallDelegate.isWarConfiguration(model)) {
+ requiredProjects.append("\n\t<classpathentry
combineaccessrules=\"false\" kind=\"src\" path=\"/" +
ejbProjectName + "\"/>"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ filterSet.addFilter("testLibraries", testLibraries.toString());
//$NON-NLS-1$
+ filterSet.addFilter("requiredProjects", requiredProjects.toString());
//$NON-NLS-1$
+ File testTemplateDir = null;
+ try {
+ testTemplateDir = new File(SeamFacetInstallDataModelProvider.getTemplatesFolder(),
"test"); //$NON-NLS-1$
+ } catch (IOException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ return;
+ }
+ AntCopyUtils.FileSet excludeCvsSvn
+ = new
AntCopyUtils.FileSet(SeamFacetAbstractInstallDelegate.CVS_SVN).dir(testTemplateDir);
+
+ AntCopyUtils.copyFilesAndFolders(
+ testTemplateDir,
+ testProjectDir,
+ new AntCopyUtils.FileSetFileFilter(excludeCvsSvn),
+ new FilterSetCollection(filterSet), true);
+
+ excludeCvsSvn.dir(new File(seamRuntime.getHomeDir(), "embedded-ejb/conf"));
//$NON-NLS-1$
+ AntCopyUtils.copyFiles(
+ new File(seamRuntime.getHomeDir(), "embedded-ejb/conf"), //$NON-NLS-1$
+ embededEjbDir,
+ new AntCopyUtils.FileSetFileFilter(excludeCvsSvn));
+
+ AntCopyUtils.copyFiles(
+ new File(seamRuntime.getHomeDir(), "lib"), //$NON-NLS-1$
+ testLibDir,
+ new AntCopyUtils.FileSetFileFilter(includeLibs));
+
+ SeamFacetAbstractInstallDelegate.createComponentsProperties(testSrcDir, "",
Boolean.TRUE); //$NON-NLS-1$
+ }
+
/**
* Creates test project for given seam web project.
* @param testProjectName
@@ -96,4 +338,103 @@
this.testProjectName = testProjectName;
createTestProject();
}
+
+ /**
+ * Creates EJB project for given seam web project.
+ * @param ejbProjectName
+ */
+ protected void createEjbProject(String ejbProjectName) {
+ if(ejbProjectName==null) {
+ throw new IllegalArgumentException("EJB project name must not be null");
+ }
+ this.ejbProjectName = ejbProjectName;
+ createEjbProject();
+ }
+
+ protected void createEjbProject() {
+ ejbProjectFolder.mkdir();
+
+ AntCopyUtils.copyFilesAndFolders(
+ ejbTemplateDir,
+ ejbProjectFolder, new AntCopyUtils.FileSetFileFilter(excludeCvsSvn),
+ new FilterSetCollection(ejbFilterSet), true);
+
+ //
*******************************************************************************************
+ // Copy sources to EJB project in case of EAR configuration
+ //
*******************************************************************************************
+ AntCopyUtils.copyFileToFile(
+ new File(seamGenHomeFolder, "src/Authenticator.java"), //$NON-NLS-1$
+ new File(ejbProjectFolder, "ejbModule/" +
model.getProperty(ISeamFacetDataModelProperties.SESSION_BEAN_PACKAGE_NAME).toString().replace('.',
'/') + "/" + "Authenticator.java"), //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$
+ new FilterSetCollection(filtersFilterSet), true);
+ AntCopyUtils.copyFileToFile(
+ persistenceFile,
+ new File(ejbProjectFolder, "ejbModule/META-INF/persistence.xml"),
//$NON-NLS-1$
+ viewFilterSetCollection, true);
+
+ SeamFacetAbstractInstallDelegate.createComponentsProperties(new File(ejbProjectFolder,
"ejbModule"), earProjectName, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ AntCopyUtils.FileSet ejbSrcResourcesSet = new
AntCopyUtils.FileSet(JBOOS_EJB_WEB_INF_CLASSES_SET).dir(seamGenResFolder);
+ AntCopyUtils.copyFilesAndFolders(
+ seamGenResFolder, new File(ejbProjectFolder, "ejbModule"), new
AntCopyUtils.FileSetFileFilter(ejbSrcResourcesSet), viewFilterSetCollection, true);
//$NON-NLS-1$
+
+ AntCopyUtils.copyFileToFolder(
+ new File(seamGenResFolder, "META-INF/ejb-jar.xml"), //$NON-NLS-1$
+ new File(ejbProjectFolder, "ejbModule/META-INF/"), //$NON-NLS-1$
+ viewFilterSetCollection, true);
+
+ /*AntCopyUtils.copyFileToFolder(
+ hibernateConsolePref,
+ new File(ejbProjectFolder,".settings"), //$NON-NLS-1$
+ new FilterSetCollection(projectFilterSet), true);*/
+
+ FilterSet ejbFilterSet = new FilterSet();
+ ejbFilterSet.addFilter("projectName", ejbProjectFolder.getName());
//$NON-NLS-1$
+
+ AntCopyUtils.copyFileToFile(
+ hibernateConsoleLaunchFile,
+ new File(ejbProjectFolder, ejbProjectFolder.getName() + ".launch"),
//$NON-NLS-1$
+ new FilterSetCollection(ejbFilterSet), true);
+
+ AntCopyUtils.copyFileToFolder(
+ hibernateConsolePropsFile,
+ ejbProjectFolder,
+ hibernateDialectFilterSet, true);
+ }
+
+ protected void createEarProject() {
+ earProjectFolder.mkdir();
+
+ File earContentsFolder = new File(earProjectFolder, "EarContent");
//$NON-NLS-1$
+
+ FilterSet earFilterSet = new FilterSet();
+ earFilterSet.addFilter("projectName", earProjectFolder.getName() +
".ear"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ AntCopyUtils.copyFileToFolder(
+ new File(seamGenResFolder, "META-INF/jboss-app.xml"), //$NON-NLS-1$
+ new File(earContentsFolder, "META-INF"), //$NON-NLS-1$
+ new FilterSetCollection(earFilterSet), true);
+
+ // Copy configuration files from template
+ try {
+ AntCopyUtils.copyFilesAndFolders(
+ new File(SeamFacetInstallDataModelProvider.getTemplatesFolder(), "ear"),
//$NON-NLS-1$
+ earProjectFolder, new AntCopyUtils.FileSetFileFilter(excludeCvsSvn),
+ new FilterSetCollection(ejbFilterSet), true);
+ } catch (IOException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+
+ // Fill ear contents
+ AntCopyUtils.copyFiles(seamHomeFolder, earContentsFolder, new
AntCopyUtils.FileSetFileFilter(new
AntCopyUtils.FileSet(getJbossEarContent()).dir(seamHomeFolder)));
+ AntCopyUtils.copyFiles(seamLibFolder, earContentsFolder, new
AntCopyUtils.FileSetFileFilter(new
AntCopyUtils.FileSet(getJbossEarContent()).dir(seamLibFolder)));
+ AntCopyUtils.copyFiles(droolsLibFolder, earContentsFolder, new
AntCopyUtils.FileSetFileFilter(new
AntCopyUtils.FileSet(getJbossEarContent()).dir(droolsLibFolder)));
+ AntCopyUtils.copyFiles(seamLibFolder, earContentsFolder, new
AntCopyUtils.FileSetFileFilter(new
AntCopyUtils.FileSet(getJbossEarContent()).dir(seamLibFolder)));
+ AntCopyUtils.copyFiles(seamGenResFolder, earContentsFolder, new
AntCopyUtils.FileSetFileFilter(new
AntCopyUtils.FileSet(getJbossEarContent()).dir(seamGenResFolder)));
+
+ File resources = new File(earProjectFolder, "resources");
+ AntCopyUtils.copyFileToFile(
+ dataSourceDsFile,
+ new File(resources, seamWebProject.getName() + "-ds.xml"), //$NON-NLS-1$
//$NON-NLS-2$
+ viewFilterSetCollection, true);
+ }
}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java 2008-09-30
16:51:41 UTC (rev 10574)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java 2008-09-30
17:01:27 UTC (rev 10575)
@@ -53,7 +53,6 @@
import org.jboss.tools.seam.core.project.facet.SeamProjectPreferences;
import org.jboss.tools.seam.core.project.facet.SeamVersion;
import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
-import org.jboss.tools.seam.internal.core.project.facet.Seam1ProjectCreator;
import org.jboss.tools.seam.internal.core.project.facet.Seam2ProjectCreator;
import
org.jboss.tools.seam.internal.core.project.facet.SeamFacetProjectCreationDataModelProvider;
import org.jboss.tools.seam.internal.core.project.facet.SeamProjectCreator;
@@ -210,7 +209,7 @@
SeamVersion seamVersion = SeamVersion.parseFromString(seamVersionString);
SeamProjectCreator creator = null;
if(seamVersion == SeamVersion.SEAM_1_2) {
- creator = new Seam1ProjectCreator(model, project);
+ creator = new SeamProjectCreator(model, project);
} else if(seamVersion == SeamVersion.SEAM_2_0) {
creator = new Seam2ProjectCreator(model, project);
} else {