[jboss-cvs] jboss-seam-tools/src/org/jboss/seam/tools/output/maven ...
Thomas Heute
theute at jboss.com
Tue Aug 8 07:33:12 EDT 2006
User: theute
Date: 06/08/08 07:33:12
Added: src/org/jboss/seam/tools/output/maven
MavenWebProject.java MavenRootProject.java
MavenEjbContext.java MavenEarProject.java
MavenEarContext.java MavenRootContext.java
MavenWebContext.java MavenEjbProject.java
Log:
- WTP and Maven support
- Legal headers
- Moved the templates
Revision Changes Path
1.1 date: 2006/08/08 11:33:12; author: theute; state: Exp;jboss-seam-tools/src/org/jboss/seam/tools/output/maven/MavenWebProject.java
Index: MavenWebProject.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.maven;
import java.io.File;
import java.io.IOException;
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;
import org.jboss.seam.tools.freemarker.WebHashModel;
import freemarker.template.Configuration;
import freemarker.template.TemplateHashModel;
/**
* @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
* @version <tt>$Revision: 1.1 $</tt>
*/
public class MavenWebProject extends WebProject {
public MavenWebContext getWebContext()
{
return (MavenWebContext) webContext;
}
@Override
public void generate(Context context) throws GenerationException, IOException
{
// Create outputLocation directory
String outputLocationDirectoryPath = webContext.getOutputLocation();
Util.createDirectory(outputLocationDirectoryPath);
// Create src/main/webapp directory
String webappDirectoryPath = outputLocationDirectoryPath + File.separatorChar + "src" + File.separatorChar + "main" + File.separatorChar + "webapp";
Util.createDirectory(webappDirectoryPath);
Configuration cfg = ConfigurationFactory.getConfiguration();
TemplateHashModel webHash = new WebHashModel(this, context);
createWebInf(webappDirectoryPath, webHash);
String outputLocation = getWebContext().getOutputLocation();
if (context.isBasicProject())
{
copyBasicProject(webappDirectoryPath, webHash, context);
}
// Process pom.xml
File file = new File(outputLocation + File.separatorChar + "pom.xml");
TemplateProcessor.process(cfg, "web/pom.xml.ftl", webHash, file);
}
}
1.1 date: 2006/08/08 11:33:12; author: theute; state: Exp;jboss-seam-tools/src/org/jboss/seam/tools/output/maven/MavenRootProject.java
Index: MavenRootProject.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.maven;
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.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.RootHashModel;
import org.jboss.seam.tools.freemarker.TemplateProcessor;
import org.jboss.seam.tools.output.maven.MavenEarProject;
import org.jboss.seam.tools.output.maven.MavenEjbProject;
import org.jboss.seam.tools.output.maven.MavenWebProject;
import freemarker.template.Configuration;
import freemarker.template.TemplateHashModel;
/**
* @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
* @version <tt>$Revision: 1.1 $</tt>
*/
public class MavenRootProject extends RootProject {
@Override
public void generate(Context context) throws GenerationException, IOException {
// Create outputLocation directory
String outputDirectoryPath = context.getOutputLocation();
Util.createDirectory(outputDirectoryPath);
Configuration cfg = ConfigurationFactory.getConfiguration();
TemplateHashModel rootHash = new RootHashModel(this, context);
// Process pom.xml
File file = new File(outputDirectoryPath + File.separatorChar + "pom.xml");
TemplateProcessor.process(cfg, "other/pom.xml.ftl", rootHash, file);
String earOuputLocation = outputDirectoryPath + File.separatorChar + earProject.getProjectName();
earProject.getEarContext().setOutputLocation(earOuputLocation);
((MavenEarProject)getEarProject()).generate(context);
for (WebProject webProject: getWebProjects())
{
String webOuputLocation = outputDirectoryPath + File.separatorChar + webProject.getProjectName();
webProject.getWebContext().setOutputLocation(webOuputLocation);
((MavenWebProject)webProject).generate(context);
}
for (EjbProject ejbProject: getEjbProjects())
{
String ejbOuputLocation = outputDirectoryPath + File.separatorChar + ejbProject.getProjectName();
ejbProject.getEjbContext().setOutputLocation(ejbOuputLocation);
((MavenEjbProject)ejbProject).generate(context);
}
}
}
1.1 date: 2006/08/08 11:33:12; author: theute; state: Exp;jboss-seam-tools/src/org/jboss/seam/tools/output/maven/MavenEjbContext.java
Index: MavenEjbContext.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.maven;
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 MavenEjbContext extends EjbContext {
private String groupId;
private String artifactId;
private String version;
private String description = "";
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getArtifactId() {
return artifactId;
}
public void setArtifactId(String artifactId) {
this.artifactId = artifactId;
}
public String getGroupId() {
return groupId;
}
public void setGroupId(String groupId) {
this.groupId = groupId;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
}
1.1 date: 2006/08/08 11:33:12; author: theute; state: Exp;jboss-seam-tools/src/org/jboss/seam/tools/output/maven/MavenEarProject.java
Index: MavenEarProject.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.maven;
import java.io.File;
import org.jboss.seam.tools.EarProject;
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;
import org.jboss.seam.tools.freemarker.TemplateProcessor;
import freemarker.template.Configuration;
import freemarker.template.TemplateHashModel;
/**
* @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
* @version <tt>$Revision: 1.1 $</tt>
*/
public class MavenEarProject extends EarProject {
public void generate(Context context) throws GenerationException
{
// Create outputLocation directory
String outputDirectoryPath = getEarContext().getOutputLocation();
boolean created = new File(outputDirectoryPath).mkdirs();
if (!created) throw new GenerationException("Could not create directory: " + outputDirectoryPath);
// Create src/main/resources directory
String contentDirectoryPath = outputDirectoryPath + File.separatorChar + "src" + File.separatorChar + "main" + File.separatorChar + "resources";
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);
// Process WebContent/META-INF/jboss-app.xml
File file = new File(metainfDirectory + File.separatorChar + "jboss-app.xml");
TemplateProcessor.process(cfg, "ear/jboss-app.xml.ftl", earHash, file);
// Process pom.xml
file = new File(outputDirectoryPath + File.separatorChar + "pom.xml");
TemplateProcessor.process(cfg, "ear/pom.xml.ftl", earHash, file);
}
}
1.1 date: 2006/08/08 11:33:12; author: theute; state: Exp;jboss-seam-tools/src/org/jboss/seam/tools/output/maven/MavenEarContext.java
Index: MavenEarContext.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.maven;
import org.jboss.seam.tools.contexts.EarContext;
/**
* @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
* @version <tt>$Revision: 1.1 $</tt>
*/
public class MavenEarContext extends EarContext {
private String groupId;
private String artifactId;
private String version;
private String description = "";
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getArtifactId() {
return artifactId;
}
public void setArtifactId(String artifactId) {
this.artifactId = artifactId;
}
public String getGroupId() {
return groupId;
}
public void setGroupId(String groupId) {
this.groupId = groupId;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
}
1.1 date: 2006/08/08 11:33:12; author: theute; state: Exp;jboss-seam-tools/src/org/jboss/seam/tools/output/maven/MavenRootContext.java
Index: MavenRootContext.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.maven;
import org.jboss.seam.tools.contexts.RootContext;
/**
* @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
* @version <tt>$Revision: 1.1 $</tt>
*/
public class MavenRootContext extends RootContext {
private String groupId;
private String artifactId;
private String version;
private String description = "";
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getArtifactId() {
return artifactId;
}
public void setArtifactId(String artifactId) {
this.artifactId = artifactId;
}
public String getGroupId() {
return groupId;
}
public void setGroupId(String groupId) {
this.groupId = groupId;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
}
1.1 date: 2006/08/08 11:33:12; author: theute; state: Exp;jboss-seam-tools/src/org/jboss/seam/tools/output/maven/MavenWebContext.java
Index: MavenWebContext.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.maven;
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 MavenWebContext extends WebContext {
private String groupId;
private String artifactId;
private String version;
private String description = "";
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getArtifactId() {
return artifactId;
}
public void setArtifactId(String artifactId) {
this.artifactId = artifactId;
}
public String getGroupId() {
return groupId;
}
public void setGroupId(String groupId) {
this.groupId = groupId;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
}
1.1 date: 2006/08/08 11:33:12; author: theute; state: Exp;jboss-seam-tools/src/org/jboss/seam/tools/output/maven/MavenEjbProject.java
Index: MavenEjbProject.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.maven;
import java.io.File;
import java.io.IOException;
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;
import org.jboss.seam.tools.freemarker.TemplateProcessor;
import freemarker.template.Configuration;
import freemarker.template.TemplateHashModel;
/**
* @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
* @version <tt>$Revision: 1.1 $</tt>
*/
public class MavenEjbProject extends EjbProject {
public MavenEjbContext getEjbContext()
{
return (MavenEjbContext) ejbContext;
}
@Override
public void generate(Context context) throws GenerationException, IOException
{
String outputLocation = ejbContext.getOutputLocation();
Util.createDirectory(outputLocation);
// Create src/main/java directory
String srcJavaDirectoryPath = outputLocation + File.separatorChar + "src" + File.separatorChar + "main" + File.separatorChar + "java";
Util.createDirectory(srcJavaDirectoryPath);
// Create src/main/resources directory
String srcResourcesDirectoryPath = outputLocation + File.separatorChar + "src" + File.separatorChar + "main" + File.separatorChar + "resources";
Util.createDirectory(srcResourcesDirectoryPath);
TemplateHashModel ejbHash = new EjbHashModel(this, context);
createResources(srcResourcesDirectoryPath, ejbHash);
if (context.isBasicProject())
{
createBasicProjectMainSources(srcJavaDirectoryPath, ejbHash, context);
if (context.isTestSupport())
{
// Create src/test/java directory
String srcTestJavaDirectoryPath = outputLocation + File.separatorChar + "src" + File.separatorChar + "test" + File.separatorChar + "java";
Util.createDirectory(srcTestJavaDirectoryPath);
createBasicProjectTestSources(srcTestJavaDirectoryPath, ejbHash, context);
// Create src/test/config directory
String srcTestConfigDirectoryPath = outputLocation + File.separatorChar + "src" + File.separatorChar + "test" + File.separatorChar + "config";
Util.createDirectory(srcTestConfigDirectoryPath);
createBasicProjectTestResources(srcTestConfigDirectoryPath, ejbHash, context);
}
}
if (context.isTestSupport())
{
// Create src/test/resources directory
String srcTestResourcesDirectoryPath = outputLocation + File.separatorChar + "src" + File.separatorChar + "test" + File.separatorChar + "resources";
Util.createDirectory(srcTestResourcesDirectoryPath);
createTestSupport(srcTestResourcesDirectoryPath, ejbHash, context);
}
Configuration cfg = ConfigurationFactory.getConfiguration();
// Process pom.xml
File file = new File(outputLocation + File.separatorChar + "pom.xml");
TemplateProcessor.process(cfg, "ejb/pom.xml.ftl", ejbHash, file);
}
}
More information about the jboss-cvs-commits
mailing list