<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Devon Hillard&#039;s Digital Sanctuary &#187; seam-gen</title>
	<atom:link href="http://www.digitalsanctuary.com/tech-blog/tag/seam-gen/feed" rel="self" type="application/rss+xml" />
	<link>http://www.digitalsanctuary.com/tech-blog</link>
	<description>Java, ATG, Seam, and related Technologies</description>
	<lastBuildDate>Mon, 30 Jan 2012 23:04:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>seam-gen and multiple projects part two</title>
		<link>http://www.digitalsanctuary.com/tech-blog/java/seam-gen-and-multiple-projects-part-two.html</link>
		<comments>http://www.digitalsanctuary.com/tech-blog/java/seam-gen-and-multiple-projects-part-two.html#comments</comments>
		<pubDate>Sun, 19 Aug 2007 20:28:27 +0000</pubDate>
		<dc:creator>Devon</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[JBoss]]></category>
		<category><![CDATA[Seam]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[seam-gen]]></category>

		<guid isPermaLink="false">http://www.digitalsanctuary.com/tech-blog/java/jboss/seam/seam-gen-and-multiple-projects-part-two.html</guid>
		<description><![CDATA[This is a follow-up from my post two days ago &#8220;seam-gen and multiple projects&#8220;. After some feedback from &#8220;atao&#8221; in this thread on the JBoss Seam forum, I have taken a different approach to the problem, and have enhanced seam-gen &#8230; <a href="http://www.digitalsanctuary.com/tech-blog/java/seam-gen-and-multiple-projects-part-two.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This is a follow-up from my post two days ago &#8220;<a href="http://www.digitalsanctuary.com/tech-blog/java/jboss/seam/seam-gen-and-multiple-projects.html" title="seam-gen and multiple projects" target="_blank">seam-gen and multiple projects</a>&#8220;.</p>
<p>After some feedback from &#8220;atao&#8221; in <a href="http://www.jboss.com/index.html?module=bb&amp;op=viewtopic&amp;t=116435" title="JBoss Seam Forum" target="_blank">this thread</a> on the JBoss Seam forum, I have taken a different approach to the problem, and have enhanced seam-gen to generate targets within the generated project&#8217;s ant build script, which in turn call the related seam-gen tasks.  This is more elegant for two reasons.  Firstly, the projects are independent and don&#8217;t rely on special configs kept outside of the project.  Secondly, you can run those tasks from within your IDE (Eclipse for me) while doing development.  You don&#8217;t have to fire up a command prompt, navigate to your seam installation, and run the seam-gen commands there.  All in all a much better solution.  Thank you very much &#8220;atao&#8221; for the better approach.</p>
<p>The changes made to the seam-gen related files are slightly more extensive than the previous approach, but well worth it.</p>
<p><span id="more-31"></span></p>
<p>First: in $SEAM_HOME/seam-gen/build-scripts you need to change build.properties to contain this:</p>
<p><code>jboss.home=@jbossHome@<br />
seamgen.home=@seamGenHome@</code></p>
<p>Second: in $SEAM_HOME/seam-gen/build-scripts you need to add the following block at the bottom of the build file (just before the  tag):</p>
<p><code><!-- Seam Gen Targets --><br />
&lt;target name="update-project" description="Update project dependencies"&gt;<br />
&lt;ant antfile="${seamgen.home}/build.xml" target="update-project" dir="${seamgen.home}"&gt;&lt;/ant&gt;&lt;/target&gt;</p>
<p>&lt;property file="seamgen.properties"&gt;&lt;/property&gt; &lt;target name="new-action" description="Create a new action"&gt;<br />
&lt;ant antfile="${seamgen.home}/build.xml" target="new-action" dir="${seamgen.home}"&gt;&lt;/ant&gt;&lt;/target&gt;<br />
&lt;property file="seamgen.properties"&gt;&lt;/property&gt; &lt;target name="new-form" description="Create a new form action"&gt;<br />
&lt;ant antfile="${seamgen.home}/build.xml" target="new-form" dir="${seamgen.home}"&gt;&lt;/ant&gt;&lt;/target&gt;<br />
&lt;property file="seamgen.properties"&gt;&lt;/property&gt; &lt;target name="new-conversation" description="Create a new conversation"&gt;<br />
&lt;ant antfile="${seamgen.home}/build.xml" target="new-conversation" dir="${seamgen.home}"&gt;&lt;/ant&gt;&lt;/target&gt;<br />
&lt;property file="seamgen.properties"&gt;&lt;/property&gt; &lt;target name="new-entity" description="Create a new entity"&gt;<br />
&lt;ant antfile="${seamgen.home}/build.xml" target="new-entity" dir="${seamgen.home}"&gt;&lt;/ant&gt;&lt;/target&gt;<br />
&lt;property file="seamgen.properties"&gt;&lt;/property&gt; &lt;target name="generate-entities" description="Reverse engineer entities from the database"&gt;<br />
&lt;ant antfile="${seamgen.home}/build.xml" target="generate-entities" dir="${seamgen.home}"&gt;&lt;/ant&gt;&lt;/target&gt;<br />
&lt;property file="seamgen.properties"&gt;&lt;/property&gt;</code></p>
<p>Finally, in $SEAM_HOME/seam-gen you need to make a few edits to build.xml:</p>
<p>in the definition of the &#8220;project&#8221; filterset, within the &#8220;init-properties&#8221; target, you need to add the following filter (I put mine right after line 97 of revision 1.90):</p>
<p><code>&lt;filter token="seamGenHome" value="${basedir}"&gt;<br />
&lt;/filter&gt;</code></p>
<p>Then, in the &#8220;file-copy&#8221; target, you need to add the following task call (I put mine on line 632 of revision 1.90):</p>
<p><code>&lt;copy file="build.properties" tofile="${project.home}/seamgen.properties"&gt;<br />
&lt;/copy&gt;</code></p>
<p>If you want to just download the enhanced files here they are (based on the current head as of today):</p>
<p><a href="http://digitalsanctuary.com/tech-files/seamgen/build-scripts/build.properties" target="_new">$SEAM_HOME/seam-gen/build-scripts/build.properties</a><br />
<a href="http://digitalsanctuary.com/tech-files/seamgen/build-scripts/build.xml" target="_new">$SEAM_HOME/seam-gen/build-scripts/build.xml</a><br />
<a href="http://digitalsanctuary.com/tech-files/seamgen/build.xml" target="_new">$SEAM_HOME/seam-gen/build.xml</a></p>
<p>Enjoy!</p>
<p>Devon</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digitalsanctuary.com/tech-blog/java/seam-gen-and-multiple-projects-part-two.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>seam-gen and multiple projects</title>
		<link>http://www.digitalsanctuary.com/tech-blog/java/seam-gen-and-multiple-projects.html</link>
		<comments>http://www.digitalsanctuary.com/tech-blog/java/seam-gen-and-multiple-projects.html#comments</comments>
		<pubDate>Sat, 18 Aug 2007 06:37:22 +0000</pubDate>
		<dc:creator>Devon</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[JBoss]]></category>
		<category><![CDATA[Seam]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[seam-gen]]></category>

		<guid isPermaLink="false">http://www.digitalsanctuary.com/tech-blog/archives/28</guid>
		<description><![CDATA[Enhancing seam-gen to support multiple projects. <a href="http://www.digitalsanctuary.com/tech-blog/java/seam-gen-and-multiple-projects.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>seam-gen is a command line tool (although the new JBoss Tools eclipse plugin supports an Eclipse driven version as well) which can be used to create new Seam projects with a basic set of files, configs, and templates.  It can also update the Seam jars in the project, do deployments, echo settings, create new actions, new forms, new entities, and so on.  It is very handy, not only for developers who are just starting out with Seam, but also for experienced Seam developers (who might have customized the template resources which seam-gen uses to create the project framework).</p>
<p>The one big gap with seam-gen is that it keeps it&#8217;s project settings in a build.properties file in the seam-gen directory of the seam project (which I checkout from CVS as an Eclipse project, making it easy to update).  What this means is that there is only one project supported.  If I use seam-gen to create a new project called shoestore, then I create another project called yourspace, now I can&#8217;t use seam-gen to create a new form in shoestore, or update shoestore to the latest Seam jars.</p>
<p>Obviously if you&#8217;re only working on one project at a time, this isn&#8217;t a problem, but I tend to have multiple projects going at once.  A couple existing applications in maintenance mode, a couple projects under development, and maybe a project or two to test something out in.   So tonight I&#8217;ve made a couple of tiny changes to to the seam-gen tool, and the ant build.xml file it uses, which allow you to create, and continue to work with, any number of projects using seam-gen.</p>
<p>The two files to change are the seam (or seam.bat if you are using Windows) executable file (found in the root directory of your Seam downloaded (or checked-out) project) and the build.xml ant build file found inside the seam-gen directory, within the Seam project.</p>
<p><span id="more-28"></span></p>
<p>In the seam file you will want to replace lines 33-35 (at revision 1.20 at least) which look like this:</p>
<p><code>java -cp "${JAVA_HOME}\lib\tools.jar;..\lib\ant-launcher.jar;..\lib\ant-nodeps.jar;..\lib\ant.jar" -Dant.home=..\lib org.apache.tools.ant.launch.Launcher ${*}<br />
else<br />
java -cp "${JAVA_HOME}/lib/tools.jar:../lib/ant-launcher.jar:../lib/ant-nodeps.jar:../lib/ant.jar" -Dant.home=../lib org.apache.tools.ant.launch.Launcher ${*}</code></p>
<p>with the following lines:</p>
<p><code>if [ "${2}" = "" ]<br />
then<br />
java -cp "${JAVA_HOME}\lib\tools.jar;..\lib\ant-launcher.jar;..\lib\ant-nodeps.jar;..\lib\ant.jar" -Dant.home=..\lib org.apache.tools.ant.launch.Launcher ${*}<br />
else<br />
java -cp "${JAVA_HOME}\lib\tools.jar;..\lib\ant-launcher.jar;..\lib\ant-nodeps.jar;..\lib\ant.jar" -Dant.home=..\lib org.apache.tools.ant.launch.Launcher -propertyfile ${1}-build.properties ${2}<br />
fi<br />
else<br />
if [ "${2}" = "" ]<br />
then<br />
java -cp "${JAVA_HOME}/lib/tools.jar:../lib/ant-launcher.jar:../lib/ant-nodeps.jar:../lib/ant.jar" -Dant.home=../lib org.apache.tools.ant.launch.Launcher ${*}<br />
else<br />
java -cp "${JAVA_HOME}/lib/tools.jar:../lib/ant-launcher.jar:../lib/ant-nodeps.jar:../lib/ant.jar" -Dant.home=../lib org.apache.tools.ant.launch.Launcher -propertyfile ${1}-build.properties ${2}<br />
fi</code></p>
<p>As I don&#8217;t have a Windows machine, I have not been able to test changes to the seam.bat version, but they should be similar.</p>
<p>Basically, what we are doing here, is if a second argument has been passed in (i.e. &#8216;seam myproject new-form&#8217; instead of &#8216;seam new-form&#8217;) we use the first argument, assume it is the project name, and load up that project&#8217;s build.properties file when we call the actual seam-gen ant tasks.</p>
<p>The second part is to modify the actual build.xml ant build file to create project specific properties file when using &#8216;seam setup&#8217;.</p>
<p>Replace line 355 (on revistion 1.90) which looks like this:</p>
<p><code>&lt;propertyfile file="build.properties"&gt;&lt;/propertyfile&gt;</code></p>
<p>with this:</p>
<p><code>&lt;propertyfile file="${project.name.new}-build.properties"&gt;&lt;/propertyfile&gt;</code></p>
<p>Then replace line 381, which looks like this:</p>
<p><code>        &lt;echo message="Type 'seam new-project' to create the new project"&gt;&lt;/echo&gt;</code></p>
<p>with this:</p>
<p><code>    	&lt;echo message="Type 'seam ${project.name.new} new-project' to create the new project"&gt;<br />
&lt;/echo&gt;</code></p>
<p>That is all there is to it.  Now, by prefacing a seam command with a project name, you can manage multiple projects with seam-gen.</p>
<p>Missing features include the windows seam.bat edit (I don&#8217;t have a Windows machine to test this on), and a list target to list available projects based on the XXXXX-build.properties files present (my Ant-fu is not strong enough).</p>
<p>The Eclipse generated patch file for the build.xml edits is here:  <a href="http://www.digitalsanctuary.com/tech-blog/wp-content/uploads/2007/08/buildxml-patch.txt" title="build.xml patch file" target="_new">build.xml patch file</a></p>
<p>The Eclipse generated patch file for the seam edits is here: <a href="http://www.digitalsanctuary.com/tech-blog/wp-content/uploads/2007/08/seam-patch.txt" title="seam patch file" target="_new">seam patch file</a></p>
<p>Enjoy!</p>
<p>Devon</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digitalsanctuary.com/tech-blog/java/seam-gen-and-multiple-projects.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 1/17 queries in 0.003 seconds using disk: basic
Object Caching 302/334 objects using disk: basic

Served from: www.digitalsanctuary.com @ 2012-02-07 00:06:26 -->
