- This topic has 5 replies, 4 voices, and was last updated 21 years, 1 month ago by support-michael.
-
AuthorPosts
-
Bob EdmonstonMemberHello,
I was wondering if you folks at genuitec (or anyone else for that matter) had any sample ant scripts that expect a directory structure like the one used by MyEclipse. I have a bunch of projects that I have converted to the MyEclipse directory structure. The problem is I want to be able to build them on our server using vanilla ant and the existing ant scripts I have for these projects expect a different directory structure (they conform to the one I’ve seen a lot where conf and web are at the top level rather than located under a Web Root). Anyway, before I go and start hacking at these ant scripts, I thought I’d see if you have any sample ant build.xml files you could share that would serve as a template for projects that conform to the MyEclipse way of doing things. No big deal if you don’t have such a thing to share – just thought it would be worth asking.
Thanks,
Bob
Eric GlassMemberHi Bob,
Where I am working some developers do not use MyEclipse yet! Some even were using Netbeans, so I had to create the project to work with all three environments. Here is the ANT script that we use:
<project name=”project” default=”dist” basedir=”.”>
<!– set global properties for this build –>
<property name=”src” location=”jarSrc”/>
<property name=”build” location=”jarBin”/>
<property name=”dist” location=”jarDeploy”/>
<property name=”web” location=”webContext”/>
<property name=”web.inf” location=”${web}/WEB-INF”/>
<property name=”lib” location=”${web.inf}/lib”/>
<property name=”web.src” location=”webSrc”/>
<property name=”web.build” location=”${web.inf}/classes”/><property file=”build.properties”/>
<property name=”tomcat.lib” location=”${tomcat_home}/common/lib”/><path id=”project.class.path”>
<fileset dir=”${lib}”>
<include name=”**/*.jar”/>
</fileset>
<fileset dir=”${tomcat.lib}”>
<include name=”**/*.jar”/>
</fileset>
<pathelement location=”${build}”/>
<pathelement location=”${web.build}”/>
</path><target name=”init”>
<!– Create the time stamp –>
<tstamp/><!– Create the build directory structures used by compiles –>
<mkdir dir=”${build}”/>
<mkdir dir=”${web.build}”/><!– Create the distribution directory structure used by dist –>
<mkdir dir=”${dist}”/>
</target><target name=”compile”
depends=”init”
description=”compile the source ” >
<!– Compile the java code from ${src} into ${build} –>
<javac srcdir=”${src}”
destdir=”${build}”
debug=”on”
fork=”true”
memoryInitialSize=”256M”
memoryMaximumSize=”512M”
failonerror=”false”>
<classpath refid=”project.class.path”/>
</javac>
</target><target name=”webcompile”
depends=”init”
description=”compile the web source ” >
<!– Compile the java code from ${web.src} into ${web.build} –>
<javac srcdir=”${web.src}”
destdir=”${web.build}”
debug=”on”
fork=”true”
memoryInitialSize=”256M”
memoryMaximumSize=”512M”
failonerror=”false”>
<classpath refid=”project.class.path”/>
</javac>
</target><target name=”dist” depends=”compile,webcompile”
description=”generate and deploy the distribution” >
<!– Put everything in ${build} into the project.jar file –>
<jar jarfile=”${dist}/project.jar” basedir=”${build}”/><!– Copy the project.jar file to the ${lib} directory –>
<copy file=”${dist}/project.jar” tofile=”${lib}/project.jar”/><!– Copy the files in the ${web.src} directory to the ${web.build} –>
<!– directory that are not included in the webcompile target –>
<copy todir=”${web.build}”>
<fileset dir=”${web.src}”>
<include name=”**/*.properties”/>
</fileset>
</copy>
</target><target name=”tomcatshutdown”
description=”shutdown Tomcat” >
<!– Shutdown Tomcat –>
<exec dir=”${tomcat_home}/bin”
executable=”shutdown.bat”
vmlauncher=”false”
newenvironment=”true”
timeout=”1000″/>
</target><target name=”tomcatdeploy” depends=”dist”
description=”Deploy files to Tomcat” >
<!– Copy the files in the ${web} directory to the –>
<!– ${tomcat_home}/webapps/project directory –>
<copy todir=”${tomcat_home}/webapps/project”>
<fileset dir=”${web}”/>
</copy>
</target><target name=”tomcatrun”
description=”run Tomcat” >
<!– Run Tomcat –>
<exec dir=”${tomcat_home}/bin”
executable=”catalina.bat”
vmlauncher=”false”
newenvironment=”true”
timeout=”1000″>
<arg line=”run”/>
</exec>
</target><target name=”tomcatdebug”
description=”debug Tomcat” >
<!– Debug Tomcat –>
<java classname=”org.apache.catalina.startup.Bootstrap”
fork=”true”
failonerror=”true”
maxmemory=”512m”>
<arg value=”start”/>
<jvmarg value=”-Xdebug”/>
<jvmarg value=”-Xrunjdwp:transport=dt_socket,address=18080,server=y,suspend=n”/>
<jvmarg value=”-Djava.endorsed.dirs=${tomcat_home}/common/endorsed”/>
<jvmarg value=”-Dcatalina.base=${tomcat_home}”/>
<jvmarg value=”-Dcatalina.home=${tomcat_home}”/>
<jvmarg value=”-Djava.io.tmpdir=${tomcat_home}/temp”/>
<classpath>
<pathelement location=”${java_home}/lib/tools.jar”/>
<pathelement location=”${tomcat_home}/bin/bootstrap.jar”/>
</classpath>
</java>
</target><target name=”tomcat”
description=”shutdown Tomcat, refresh web context, run Tomcat” >
<!– Shutdown Tomcat –>
<antcall target=”tomcatshutdown”/><!– Deploy to Tomcat –>
<antcall target=”tomcatdeploy”/><!– Run Tomcat –>
<antcall target=”tomcatdebug”/>
</target><target name=”all”
depends=”dist,tomcat”
description=”perform all of the targets in proper order “/>
</project>This script has been written for Windows, but could be modified to run on Linux too. Also I had to include targets for deployment to Tomcat and running Tomcat for those not using MyEclipse. You will also notice that we have a seperate JAR that is created for the project and placed in the WEB-INF/lib directory. The following is the build.properties that we use:
tomcat_home = C:/Tomcat4_1
java_home = C:/j2sdk1_4_2Everybody has there Tomcat and JDK in different directories; and I had problems accessing the Windows XP environment variables from within ANT, so we added these variables to the build.properites file.
I hope that this helps you.
Eric
Bob EdmonstonMemberGreat – thank you! This will be a big help to me (and most likely others). I will be sure and post some additions I intend to make including JUnit testing target and a javadoc target. Thanks again for sharing this – good luck to you.
GeoffMemberHi, I am also in a position where many others are using Netbeans. The problem here is I do not have control over telling them to use ant. What I really need is a directory structure that can be sent to and from CVS that works with both NetBeans and MyEclipse.
I thought I was really close, but I keep running into problems.
The basic setup is this:
the root of the web source is the root of the project
the java source files go into the WEB-INF/classes directory.Did I miss anything?
Anyway I can handle the WEB-INF/classes issue easily enough. The problem I have is when I try to set the root of the web to be the root of the project. I can’t even get the dialog boxes to close.
Does anybody have this working? Have I missed something?
I am using 2.6.4 (MyEclipse) and 2.1.2 (Eclipse)
Thanks,
Geoff
GeoffMemberSpecifically I think what I am talking about is to allow / as the web root folder in the preferences -> MyEclipse -> MyEclipse-Web
But when it is set to /, or set to blank the dialog box will not close.
Is there anything I can do to support their structure?
support-michaelKeymasterSee https://www.genuitec.com/forums/topic/netbeans-cvs-projects/ for a continuation of this new topic.
Michael
MyEclipse Support -
AuthorPosts