[jboss-cvs] jboss-seam-tools/src/org/jboss/seam/tools/output/wtp ...
Thomas Heute
theute at jboss.com
Tue Aug 8 07:33:14 EDT 2006
User: theute
Date: 06/08/08 07:33:14
Modified: src/org/jboss/seam/tools/output/wtp
WTPWebProject.java WTPEarProject.java
WTPEjbProject.java
Added: src/org/jboss/seam/tools/output/wtp
WTPRootProject.java WTPWebContext.java
WTPEjbContext.java
Removed: src/org/jboss/seam/tools/output/wtp
WTPSeamProject.java
Log:
- WTP and Maven support
- Legal headers
- Moved the templates
Revision Changes Path
1.2 +67 -12 jboss-seam-tools/src/org/jboss/seam/tools/output/wtp/WTPWebProject.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: WTPWebProject.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam-tools/src/org/jboss/seam/tools/output/wtp/WTPWebProject.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- WTPWebProject.java 24 Jul 2006 08:08:02 -0000 1.1
+++ WTPWebProject.java 8 Aug 2006 11:33:14 -0000 1.2
@@ -1,9 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.seam.tools.output.wtp;
import java.io.File;
+import java.io.IOException;
-import org.jboss.seam.tools.Context;
+import org.jboss.seam.tools.Util;
import org.jboss.seam.tools.WebProject;
+import org.jboss.seam.tools.contexts.Context;
import org.jboss.seam.tools.exception.GenerationException;
import org.jboss.seam.tools.freemarker.ConfigurationFactory;
import org.jboss.seam.tools.freemarker.TemplateProcessor;
@@ -12,18 +35,50 @@
import freemarker.template.Configuration;
import freemarker.template.TemplateHashModel;
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version <tt>$Revision: 1.2 $</tt>
+ */
public class WTPWebProject extends WebProject {
- @Override
- public void generate(Context context) throws GenerationException
+ public WTPWebContext getWebContext()
{
- super.generate(context);
+ return (WTPWebContext) webContext;
+ }
- Configuration cfg = ConfigurationFactory.getConfiguration();
+ @Override
+ public void generate(Context context) throws GenerationException, IOException
+ {
+ // Create outputLocation directory
+ String outputLocationDirectoryPath = webContext.getOutputLocation();
+ Util.createDirectory(outputLocationDirectoryPath);
+
+ // Create contentLocation directory
+ String contentDirectoryPath = webContext.getOutputLocation() + File.separatorChar + webContext.getContentDirectory();
+ Util.createDirectory(contentDirectoryPath);
+
+ // Create src directory
+ String srcDirectoryPath = webContext.getOutputLocation() + File.separatorChar + "src";
+ Util.createDirectory(srcDirectoryPath);
TemplateHashModel webHash = new WebHashModel(this, context);
- String outputLocation = getOutputLocation();
+ createWebInf(contentDirectoryPath, webHash);
+
+ // Create WEB-INF/lib directory
+ String webinfLibDirectoryPath = contentDirectoryPath + File.separatorChar + "WEB-INF" + File.separatorChar + "lib";
+ Util.createDirectory(webinfLibDirectoryPath);
+
+
+ if (context.isBasicProject())
+ {
+ copyBasicProject(contentDirectoryPath, webHash, context);
+ copyLibs(context);
+ }
+
+ Configuration cfg = ConfigurationFactory.getConfiguration();
+
+ String outputLocation = getWebContext().getOutputLocation();
// Process .classpath
File file = new File(outputLocation + File.separatorChar + ".classpath");
1.2 +68 -6 jboss-seam-tools/src/org/jboss/seam/tools/output/wtp/WTPEarProject.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: WTPEarProject.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam-tools/src/org/jboss/seam/tools/output/wtp/WTPEarProject.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- WTPEarProject.java 24 Jul 2006 08:08:02 -0000 1.1
+++ WTPEarProject.java 8 Aug 2006 11:33:14 -0000 1.2
@@ -1,9 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.seam.tools.output.wtp;
import java.io.File;
+import java.io.IOException;
-import org.jboss.seam.tools.Context;
import org.jboss.seam.tools.EarProject;
+import org.jboss.seam.tools.Util;
+import org.jboss.seam.tools.contexts.Context;
import org.jboss.seam.tools.exception.GenerationException;
import org.jboss.seam.tools.freemarker.ConfigurationFactory;
import org.jboss.seam.tools.freemarker.EarHashModel;
@@ -12,20 +35,45 @@
import freemarker.template.Configuration;
import freemarker.template.TemplateHashModel;
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version <tt>$Revision: 1.2 $</tt>
+ */
public class WTPEarProject extends EarProject {
public void generate(Context context) throws GenerationException
{
- super.generate(context);
+ // Create outputLocation directory
+ String outputDirectoryPath = getEarContext().getOutputLocation();
+ boolean created = new File(outputDirectoryPath).mkdirs();
+ if (!created) throw new GenerationException("Could not create directory: " + outputDirectoryPath);
+
+ // Create contentLocation directory
+ String contentDirectoryPath = outputDirectoryPath + File.separatorChar + getEarContext().getContentDirectory();
+ created = new File(contentDirectoryPath).mkdirs();
+ if (!created) throw new GenerationException("Could not create directory: " + contentDirectoryPath);
+
+ // Create META-INF directory
+ String metainfDirectory = contentDirectoryPath + File.separatorChar + "META-INF";
+ created = new File(metainfDirectory).mkdirs();
+ if (!created) throw new GenerationException("Could not create directory: " + metainfDirectory);
Configuration cfg = ConfigurationFactory.getConfiguration();
TemplateHashModel earHash = new EarHashModel(this, context);
- String outputDirectoryPath = getOutputLocation().getAbsolutePath();
+ // Process WebContent/META-INF/application.xml
+ File file = new File(metainfDirectory + File.separatorChar + "application.xml");
+ TemplateProcessor.process(cfg, "ear/application.xml.ftl", earHash, file);
+
+ // Process WebContent/META-INF/jboss-app.xml
+ file = new File(metainfDirectory + File.separatorChar + "jboss-app.xml");
+ TemplateProcessor.process(cfg, "ear/jboss-app.xml.ftl", earHash, file);
+
+ copyLibs(context);
// Process .project
- File file = new File(outputDirectoryPath + File.separatorChar + ".project");
+ file = new File(outputDirectoryPath + File.separatorChar + ".project");
TemplateProcessor.process(cfg, "ear/eclipse.project.ftl", earHash, file);
// Create directory .settings
@@ -43,4 +91,18 @@
}
+
+ private void copyLibs(Context context) throws GenerationException
+ {
+ File src = new File(context.getSeamLocation() + File.separatorChar + "jboss-seam.jar");
+ File dst = new File(getEarContext().getOutputLocation() + File.separatorChar + getEarContext().getContentDirectory() + File.separatorChar + "jboss-seam.jar");
+
+ try {
+ Util.copy(src, dst);
+ } catch (IOException e) {
+ throw new GenerationException("Cannot copy: " + src.getAbsolutePath() +" library to " + dst.getAbsolutePath());
+ }
+ }
+
+
}
1.3 +98 -11 jboss-seam-tools/src/org/jboss/seam/tools/output/wtp/WTPEjbProject.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: WTPEjbProject.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam-tools/src/org/jboss/seam/tools/output/wtp/WTPEjbProject.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- WTPEjbProject.java 24 Jul 2006 15:00:23 -0000 1.2
+++ WTPEjbProject.java 8 Aug 2006 11:33:14 -0000 1.3
@@ -1,9 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.seam.tools.output.wtp;
import java.io.File;
+import java.io.IOException;
-import org.jboss.seam.tools.Context;
import org.jboss.seam.tools.EjbProject;
+import org.jboss.seam.tools.Util;
+import org.jboss.seam.tools.contexts.Context;
import org.jboss.seam.tools.exception.GenerationException;
import org.jboss.seam.tools.freemarker.ConfigurationFactory;
import org.jboss.seam.tools.freemarker.EjbHashModel;
@@ -12,19 +35,58 @@
import freemarker.template.Configuration;
import freemarker.template.TemplateHashModel;
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version <tt>$Revision: 1.3 $</tt>
+ */
public class WTPEjbProject extends EjbProject {
@Override
- public void generate(Context context) throws GenerationException
+ public void generate(Context context) throws GenerationException, IOException
{
- super.generate(context);
+ String outputLocation = ejbContext.getOutputLocation();
+ Util.createDirectory(outputLocation);
- Configuration cfg = ConfigurationFactory.getConfiguration();
+ // Create contentLocation directory
+ String contentDirectoryPath = outputLocation + File.separatorChar + ejbContext.getContentDirectory();
+ Util.createDirectory(contentDirectoryPath);
+
+ // Create lib directory
+ String libDirectoryPath = outputLocation + File.separatorChar + "lib";
+ Util.createDirectory(libDirectoryPath);
TemplateHashModel ejbHash = new EjbHashModel(this, context);
- String outputLocation = getOutputLocation();
+ createResources(contentDirectoryPath, ejbHash);
+
+ if (context.isBasicProject())
+ {
+ createBasicProjectMainSources(contentDirectoryPath, ejbHash, context);
+ if (context.isTestSupport())
+ {
+ createBasicProjectTestSources(contentDirectoryPath, ejbHash, context);
+ String srcPackageDir = contentDirectoryPath + File.separatorChar + "org" + File.separatorChar + "jboss" + File.separatorChar + "seam";
+ createBasicProjectTestResources(srcPackageDir, ejbHash, context);
+ }
+ }
+
+ if (context.isTestSupport())
+ {
+
+ // Create confTest directory
+ String confTestDir = ejbContext.getOutputLocation() + File.separatorChar + "confTest";
+ File file = new File(confTestDir);
+ file.mkdirs();
+
+ createTestSupport(confTestDir, ejbHash, context);
+ }
+
+ copyLibs(context);
+
+ Configuration cfg = ConfigurationFactory.getConfiguration();
+
+ // Eclipse files
// Process .project
File file = new File(outputLocation + File.separatorChar + ".project");
TemplateProcessor.process(cfg, "ejb/eclipse.project.ftl", ejbHash, file);
@@ -53,6 +115,31 @@
// Process .settings/org.eclipse.wst.common.project.facet.core.xml
file = new File(settingsDirectoryPath + File.separatorChar + "org.eclipse.wst.common.project.facet.core.xml");
TemplateProcessor.process(cfg, "ejb/org.eclipse.wst.common.project.facet.core.xml.ftl", ejbHash, file);
+ }
+
+ private void copyLibs(Context context) throws GenerationException
+ {
+ copyLib(context, "jboss-ejb3-all.jar");
+ copyLib(context, "hibernate-all.jar");
+ copyLib(context, "myfaces-api-1.1.3.jar");
+ copyLib(context, "myfaces-impl-1.1.3.jar");
+ copyLib(context, "testng-4.5.1-jdk15.jar");
+ if (context.isTestSupport())
+ {
+ copyLib(context, "servlet-api.jar");
+ copyLib(context, "thirdparty-all.jar");
+ }
+ }
+ public void copyLib(Context context, String libName) throws GenerationException
+ {
+ File src = new File(context.getSeamLocation() + File.separatorChar + "lib" + File.separatorChar + libName);
+ File dst = new File(ejbContext.getOutputLocation() + File.separatorChar + "lib" + File.separatorChar + libName);
+ try {
+ Util.copy(src, dst);
+ } catch (IOException e) {
+ throw new GenerationException("Could not copy: " + src.getAbsolutePath() +" to: " + dst.getAbsolutePath());
+ }
}
+
}
1.1 date: 2006/08/08 11:33:14; author: theute; state: Exp;jboss-seam-tools/src/org/jboss/seam/tools/output/wtp/WTPRootProject.java
Index: WTPRootProject.java
===================================================================
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.seam.tools.output.wtp;
import java.io.File;
import java.io.IOException;
import org.jboss.seam.tools.EjbProject;
import org.jboss.seam.tools.RootProject;
import org.jboss.seam.tools.WebProject;
import org.jboss.seam.tools.contexts.Context;
import org.jboss.seam.tools.exception.GenerationException;
/**
* @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
* @version <tt>$Revision: 1.1 $</tt>
*/
public class WTPRootProject extends RootProject {
@Override
public void generate(Context context) throws GenerationException, IOException
{
// Create outputLocation directory
String outputDirectoryPath = context.getOutputLocation();
File outputDirectory = new File(outputDirectoryPath);
if (! outputDirectory.exists())
{
boolean created = outputDirectory.mkdirs();
if (!created) throw new GenerationException("Could not create directory: " + outputDirectoryPath);
}
String earOuputLocation = outputDirectoryPath + File.separatorChar + earProject.getProjectName();
earProject.getEarContext().setOutputLocation(earOuputLocation);
((WTPEarProject)getEarProject()).generate(context);
for (WebProject webProject: getWebProjects())
{
String webOuputLocation = outputDirectoryPath + File.separatorChar + webProject.getProjectName();
webProject.getWebContext().setOutputLocation(webOuputLocation);
((WTPWebProject)webProject).generate(context);
}
for (EjbProject ejbProject: getEjbProjects())
{
String ejbOuputLocation = outputDirectoryPath + File.separatorChar + ejbProject.getProjectName();
ejbProject.getEjbContext().setOutputLocation(ejbOuputLocation);
((WTPEjbProject)ejbProject).generate(context);
}
}
}
1.1 date: 2006/08/08 11:33:14; author: theute; state: Exp;jboss-seam-tools/src/org/jboss/seam/tools/output/wtp/WTPWebContext.java
Index: WTPWebContext.java
===================================================================
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.seam.tools.output.wtp;
import org.jboss.seam.tools.contexts.WebContext;
/**
* @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
* @version <tt>$Revision: 1.1 $</tt>
*/
public class WTPWebContext extends WebContext {
private String id;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}
1.1 date: 2006/08/08 11:33:14; author: theute; state: Exp;jboss-seam-tools/src/org/jboss/seam/tools/output/wtp/WTPEjbContext.java
Index: WTPEjbContext.java
===================================================================
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.seam.tools.output.wtp;
import org.jboss.seam.tools.contexts.EjbContext;
/**
* @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
* @version <tt>$Revision: 1.1 $</tt>
*/
public class WTPEjbContext extends EjbContext {
private String id;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}
More information about the jboss-cvs-commits
mailing list