facebook

Generate build.xml for ant from MyEclipse web project

  1. MyEclipse IDE
  2.  > 
  3. General Development
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #233786 Reply

    Ed Thompson
    Member

    Is there a way to generate build.xml for ant from MyEclipse web project.

    I have yused this feature in jBuilder to migrate to Eclipse for other Java projects, but if I want to use ant for a project I started in MyEclipse, do I need to build by hand, or is there a way to gernerayte a starter build.xml?

    #233935 Reply

    Riyad Kalla
    Member

    There is currently no way to generate a build file because MyEclipse supports features that cannot be (easily?) translated into a build script.

    #253210 Reply

    Jason
    Member

    To generate a build.xml for your project:

    1) Right-click on your project, select Export…
    2) Select Ant Buildfiles under the General Folder, click Next
    3) Select your project, click Finish

    This will create a build.xml file at the root of your project.

    To run the build, right-click on the build.xml file and select Run As > Ant Build

    #266258 Reply

    aha
    thanks dude.

    #266405 Reply

    jhm
    Member

    The way jcowley suggested is the Eclipse-built-in way. I am not sure (especially after the comment from Riyad) that it would do all the stuff …

    @Riyad: you could provide Ant-Tasks (in an AntLib) as a facade to the MyEclipse features. In that way you could invoke all the stuff to existing MyEclipse code.

    <myeclipse:uml2java umlrepo="myrepo.umr" dest="${build.dir}/gen-src"/>
    <myeclipse:ear destfile="application.ear" ... />
    
    #266413 Reply

    Riyad Kalla
    Member

    jhm,
    That’s a good suggestion, the issue is when we get down to the wire and management has to allocated developer time and support resources (which directly translates to money) is doing something like this more effective, or adding Facelets support?

    It’s always a balancing act.

    #266490 Reply

    jhm
    Member

    Yes, I know …. But I think it’s worth to spend 1 hr to check, if you could write the Ant tasks. It’s not difficult and the main work is already done (in the existing implentation of MyEclipse). After 1hr testing you should know how much time you need for product hardening/development.

    #294518 Reply

    corneel
    Member

    I have a ticket open with MyEclipse but I have to post this question here too:

    I am trying to build my EAR project with ANT. I have an EJB and a Web projects that are referenced by the EAR. In the EJB I create POJO files using the Hibernate reverse engineering wizard. In the Web project I create a JAX-RPC Web Service using the Web Service creation wizard.

    Problem is that one of the objects I pass back as a response – is the POJO object created in the EJB. Well the JAX-RPC wizard creates a class in the Web that has the same name (!) as the POJO. MyEclipse is able to deploy the EAR to WAS but when I attempt to create the same process using ANT – WAS chokes on the two classes having the same name.

    It might be a class loading problem but so far I have not received much direction from the support team. IBM is fanning their nose at me because they say it is a MyEclipse problem.

    If I change the package name in the EJB then the Web Services creation mimics that package in the Web project!

    I have now spend over a month on this problem! Has anybody had this problem before and does somebody know how MyEclipse is able to bypass the problem when they deploy the EAR with the War and the EJB each having the same named class?

    Sorry for sounding upset but one glaring omission that I see in MyEclipse is gearing for a big Enterprise where people build for production from a build server using ANT. I have IBM crawling all over this enterprise trying to ram RAD down everybody’s throat and the only way I am keeping them at bay is with the price difference between the two IDE’s. But if MyEclipse cannot step up to the plate and prove they can provide the ANT build scripts to build and deploy an EAR file – then price will not make the difference in the end. MyEclipse will be seen as lightweight and not in touch with the enterprise.

    My last hope is now to try this recommendation and have Eclipse generate the ANT script and see if that works.

    <Rant mode off/> Ok so can someone please help me with this problem.
    Thanks.
    Corneel.

    I include my current ANT script below but as I mentioned it builds/deploys the EAR but the deployed application does not work.

    <project name=”DemoApp” default=”” basedir=”.”>

    <taskdef resource=”net/sf/antcontrib/antcontrib.properties”>
    <classpath>
    <pathelement location=”/apache-ant-1.7.0/lib/ant-contrib-1.0b3.jar”/>
    </classpath>
    </taskdef>

    <!– ********************************************************************************************************* –>
    <property name=”root” value=”/MyEclipseBlue/workspace” />
    <property name=”project.name” value=”DemoEAR” />
    <property name=”ANT.project.name” value=”${root}/DemoANT” />
    <property name=”EAR.project.name” value=”${root}/DemoEAR” />
    <property name=”EJB.project.name” value=”${root}/DemoEJB” />
    <property name=”WAR.project.name” value=”${root}/DemoWeb” />
    <property name=”TopANT.project.name” value=”${root}/TopANT” />
    <property name=”jar.name” value=”DemoEJB.jar” />
    <property name=”war.name” value=”DemoWeb.war” />
    <property name=”ear.name” value=”DemoEAR.ear” />
    <property name=”build.dir” value=”${ANT.project.name}/build” />
    <property name=”jar.build.dir” value=”${build.dir}/jar” />
    <property name=”war.build.dir” value=”${build.dir}/war” />
    <property name=”package.dir” value=”${ANT.project.name}/package” />
    <property name=”ear.package.dir” value=”${package.dir}/DemoEAR” />
    <property name=”jar.package.dir” value=”${package.dir}/DemoEJB” />
    <property name=”war.package.dir” value=”${package.dir}/DemoWeb” />
    <property name=”EJB.src.dir” value=”${EJB.project.name}/src” />
    <property name=”WAR.src.dir” value=”${WAR.project.name}/src” />
    <property name=”doc.dir” value=”${ANT.project.name}/doc” />
    <property name=”lib.dir” value=”${TopANT.project.name}/lib” />

    <property name=”was.home” value=”/WebSphere/AppServer” />
    <property name=”was.server” value=”server1″ />
    <property name=”was.profilename” value=”AppSrv02″ />
    <property name=”was.cellname” value=”WKS-HDQ-LKRBNM3Node06Cell” />
    <property name=”was.nodename” value=”WKS-HDQ-LKRBNM3Node06″ />
    <property name=”conntype” value=”SOAP” />
    <property name=”host” value=”localhost” />
    <property name=”port” value=”8887″ />
    <property name=”user” value=”admin” />
    <property name=”password” value=”admin” />

    <target name=”clean”>
    <delete dir=”${build.dir}” />
    <delete dir=”${package.dir}” />
    </target>

    <!– ********************************************************************************************************* –>
    <target name=”prepare”>
    <mkdir dir=”${build.dir}” />
    <mkdir dir=”${jar.build.dir}” />
    <mkdir dir=”${war.build.dir}” />
    <mkdir dir=”${package.dir}” />
    <mkdir dir=”${jar.package.dir}” />
    <mkdir dir=”${war.package.dir}” />
    <mkdir dir=”${ear.package.dir}” />
    </target>

    <!– ********************************************************************************************************* –>
    <target name=”buildEJB” depends=”prepare”>
    <javac destdir=”${jar.build.dir}”
    debug=”on”
    verbose=”on”
    listfiles=”yes”
    includeAntRuntime=”no”
    target=”1.5″>
    <src path=”${EJB.src.dir}” />
    <include name=”sample/**” />
    <classpath>
    <pathelement location=”${lib.dir}/javaee.jar” />
    <pathelement location=”WebSphere/AppServer/plugins/com.ibm.ws.runtime_6.1.0.jar” />
    <pathelement location=”WebSphere/AppServer/java/lib/*.jar” />
    <pathelement location=”WebSphere/AppServer/java/jre/lib/*.jar” />
    <pathelement location=”WebSphere/AppServer/lib/*.jar” />
    </classpath>
    </javac>
    </target>

    <!– ********************************************************************************************************* –>
    <target name=”buildWAR” depends=”prepare”>
    <echo message=”About to build to ${war.build.dir}” />
    <javac destdir=”${war.build.dir}”
    debug=”on” verbose=”on”
    listfiles=”yes”
    includeAntRuntime=”no”
    target=”1.5″>
    <src path=”${WAR.src.dir}” />
    <include name=”sample/**” />
    <classpath>
    <pathelement location=”${lib.dir}/javaee.jar” />
    <pathelement location=”${lib.dir}/com.ibm.ws.webservices.thinclient_6.1.0.jar” />
    <pathelement location=”${jar.build.dir}” />
    </classpath>
    </javac>
    </target>

    <!– ********************************************************************************************************* –>
    <target name=”build” depends=”prepare”>
    <antcall target=”buildEJB” />
    <antcall target=”buildWAR” />
    </target>

    <!– ********************************************************************************************************* –>
    <target name=”package” depends=”build”>
    <echo message=”About to package for ${envlong}” />
    <copy file=”${EAR.project.name}/deployment.xml”
    tofile=”${ear.package.dir}/deployment.xml” />
    <copy todir=”${ear.package.dir}/META-INF”>
    <fileset dir=”${EAR.project.name}/META-INF/” />
    </copy>
    <antcall target=”packageEJB” />
    <antcall target=”packageWAR” />
    <echo message=”EJB and War successfully created – about to create EAR file” />
    <ear destfile=”${package.dir}/${ear.name}”
    appxml=”${ear.package.dir}/META-INF/application.xml”
    manifest=”${EAR.project.name}/META-INF/MANIFEST.MF”>
    <fileset dir=”${ear.package.dir}” includes=”*.war,*.jar,*.xml”/>
    </ear>
    </target>

    <!– ********************************************************************************************************* –>
    <target name=”packageEJB” depends=”build”>
    <echo message=”About to package EJB” />
    <copy todir=”${jar.package.dir}/sample”>
    <fileset dir=”${jar.build.dir}/sample” />
    </copy>
    <jar destfile=”${ear.package.dir}/${jar.name}”
    basedir=”${jar.package.dir}”
    manifest=”${EJB.src.dir}/META-INF/MANIFEST.MF”/>
    </target>

    <!– ********************************************************************************************************* –>
    <target name=”packageWAR” depends=”build”>
    <echo message=”About to package WAR” />
    <copy todir=”${war.package.dir}/META-INF”>
    <fileset dir=”${WAR.project.name}/WebRoot/META-INF” />
    </copy>
    <copy todir=”${war.package.dir}/WEB-INF/wsdl”>
    <fileset dir=”${WAR.project.name}/WebRoot/WEB-INF/wsdl” />
    </copy>
    <copy todir=”${war.package.dir}/WEB-INF/classes”>
    <fileset dir=”${war.build.dir}” />
    </copy>
    <copy file=”${WAR.project.name}/WebRoot/index.jsp”
    todir=”${war.package.dir}” />
    <copy file=”${WAR.project.name}/WebRoot/WEB-INF/MySampleWebServiceEntry_mapping.xml”
    todir=”${war.package.dir}/WEB-INF/” />
    <copy file=”${WAR.project.name}/WebRoot/WEB-INF/web.xml”
    todir=”${war.package.dir}/WEB-INF/” />
    <copy file=”${WAR.project.name}/WebRoot/WEB-INF/webservices.xml”
    todir=”${war.package.dir}/WEB-INF/” />
    <copy file=”${WAR.project.name}/WebRoot/WEB-INF/ibm-webservices-bnd.xmi”
    todir=”${war.package.dir}/WEB-INF/” />
    <copy file=”${WAR.project.name}/WebRoot/WEB-INF/ibm-webservices-ext.xmi”
    todir=”${war.package.dir}/WEB-INF/” />
    <war destfile=”${ear.package.dir}/${war.name}”
    basedir=”${war.package.dir}”
    manifest=”${WAR.project.name}/WebRoot/META-INF/MANIFEST.MF”/>
    </target>

    <!– ********************************************************************************************************* –>
    <target name=”deploy” depends=””>
    <antcall target=”uninstallapp” />
    <antcall target=”installapp” />
    <antcall target=”listapps” />
    <antcall target=”startapp” />
    </target>

    <!– ********************************************************************************************************* –>
    <target name=”installapp” depends=””>
    <taskdef name=”wsInstallApp” classname=”com.ibm.websphere.ant.tasks.InstallApplication”/>
    <wsInstallApp
    wasHome=”${was.home}/”
    profilename=”${was.profilename}”
    ear=”${package.dir}/${ear.name}”
    failonerror=”true”
    options=”-MapWebModToVH {{DemoWeb DemoWeb.war,WEB-INF/web.xml default_host}}
    -MapModulesToServers {{DemoWeb DemoWeb.war,WEB-INF/web.xml WebSphere:cell=WKS-HDQ-LKRBNM3Node06Cell,node=WKS-HDQ-LKRBNM3Node06,server=server1 }}
    -MapRolesToUsers {{WDRead No no WDRead WDRead}{WDUpdate No no WDUpdate WDUpdate}}”
    conntype=”${conntype}”
    host=”${host}”
    port=”${port}”
    user=”$corneel”
    password=”${password}”/>
    </target>

    <!– ********************************************************************************************************* –>
    <target name=”listapps” depends=””>
    <taskdef name=”wsListApps” classname=”com.ibm.websphere.ant.tasks.ListApplications”/>
    <wsListApps
    wasHome=”${was.home}/”
    profilename=”${was.profilename}”
    conntype=”${conntype}”
    host=”${host}”
    port=”${port}”
    user=”$corneel”
    password=”${password}”/>
    </target>

    <!– ********************************************************************************************************* –>
    <target name=”startapp” depends=””>
    <taskdef name=”wsStartApp” classname=”com.ibm.websphere.ant.tasks.StartApplication”/>
    <wsStartApp
    wasHome=”${was.home}/”
    application=”${project.name}”
    server=”${was.server}”
    conntype=”${conntype}”
    host=”${host}”
    port=”${port}”
    user=”$corneel”
    password=”${password}”/>
    </target>

    <!– ********************************************************************************************************* –>
    <target name=”uninstallapp” depends=””>
    <taskdef name=”wsUninstallApp” classname=”com.ibm.websphere.ant.tasks.UninstallApplication”/>
    <wsUninstallApp
    wasHome=”${was.home}/”
    application=”${project.name}”
    failonerror=”false”
    profilename=”${was.profilename}”
    conntype=”${conntype}”
    host=”${host}”
    port=”${port}”
    user=”$corneel”
    password=”${password}”/>
    </target>

    <!– ********************************************************************************************************* –>

    </project>

    #294701 Reply

    Riyad Kalla
    Member

    corneel,

    We followed up in the ticket after doing quite a bit of investigation. As it turns out, there were two problems:

    1. We were doing the generation incorrectly (we *always* generated the new beans, even if that meant you already had a bean) — this is why you got the class mis-match on deployment.
    2. Because of #1, when you generated *out* of your EJB project into your Web Project, even though the EJB project is already on the classpath of the Web Project and has access to it’s classes, we were still re-creating the Bean classes, not just the serializers/deserializers/helpers like we should have been.

    This will be fixed in 7.1 for you as mentioned in the ticket. I’m just replying here for anyone else running into the issue.

Viewing 9 posts - 1 through 9 (of 9 total)
Reply To: Generate build.xml for ant from MyEclipse web project

You must be logged in to post in the forum log in