It's all about the answers!

Ask a question

How do I create a jar file using the RTC build definition?


Bob Ferguson (891544) | asked Oct 12 '17, 9:41 a.m.

I am using RTC 6.0.3 and I am trying to create a Jar file using the RTC build definition.

I have searched the forum and found an answer the said to refer to  https://jazz.net/library/article/1286  for a discussion.  I have done this and still cannot find out how to create a Jar file using the RTC build definition.

Let me start by saying I am very new to ant and java.  I was able to use the RTC build definition to compile java source and create class files.  What I am trying to do now is create a jar file containing the class files produced.

I did view the build.xml file and noticed that it state that the file could not be modified, it stated that all modifications would have to be done in another file and imported into the build.xml file.  I don't know if this new file needs to contain the modifications only or an entire build definition.

If there is a way to use the RTC build definition to create a build xml file that would compile java source to produce class files and then take those class files and put them into a new jar file, I would love to know how.

Please when answering this question be very verbose (like I stated previously, I am new to ant and java).

Please let me know all the steps needed in the RTC build definition to create a build xml file that would compile java source to produce class files and then take those class files and put them into a new jar file.

If I have to modify the build.xml file please let me know what all the modifications would be and how to import into the build.xml file (if needed).

Please let me thank you in advance for all your help.

Bob

Accepted answer


permanent link
Alan Sampson (93749) | answered Oct 12 '17, 1:43 p.m.
JAZZ DEVELOPER

By "noticed that it state that the file could not be modified" I assume you mean this comment:

<!-- WARNING: Eclipse auto-generated file.
              Any modifications will be overwritten.
              To include a user specific buildfile here, simply create one in the same
              directory with the processing instruction <?eclipse.ant.import?>
              as the first entry and export the buildfile again. -->

This is more to do with Eclipse than RTC and to answer your question; the new file should only contain the modifications:
e.g in a new file build_l00.xml:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse.ant.import?>
<project>
  <echo message="Local Build Settings" />
  <property name="dist.filename.srcjar" value="project.src.jar" />

  <target name="create-src-jar">   <echo message="Creating ${dist.filename.srcjar}" level="info" />   <jar destfile="${dist.output.dir}/${dist.filename.srcjar}" compress="true" >     <fileset dir="${basedir}" includes="src/" />     <fileset dir="${basedir}" includes="script/" />     <fileset dir="${basedir}" includes="tools/" />     <fileset dir="${basedir}">       <include name=".xml" />       <include name=".jardesc" />     </fileset>    </jar>   </target>

  <!--  more targets etc. -->

</project>


When you export the build.xml again Eclipse inserts an "import" element into the build.xml file, e.g:
...
  <import file="build_l00.xml"/>
...

For your JBE needs though it may be simpler to copy build.xml into another file and add the appropriate ant targets into one file. There is no requirement that the file be called build.xml

Bob Ferguson selected this answer as the correct answer

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.