How can I create a JAR-File with IntelliJ 4.5 ?

Am I so stupid, or is it that hard?
I spend hours reading manuals, forums etc. but I just can't find out, how it works :(
HELP! Is there any Tutorial for a dummy like me???

3 comments
Comment actions Permalink

Try using ANT.

Support for ANT is built into IDEA and ANT scripts are pretty straightforward.

Below I have the ANT build script for one of my modules. The "deliver" target creates the JAR file.

Donald
-


]]>

<property name="src" value="$"/> <property name="classdir" value="$/classes"/>
]]>
<property name="classesJar" value="$.jar"/> <property name="sourceJar" value="$-Source.jar"/>

<property name="apt" value="$/.."/> <property name="libraries" value="$/Libraries"/> <property name="plugins" value="$/Plug-Ins"/> <property name="deprecation" value="off"/> <!-- ============================================================================ ============================================================================ Set deliverClassesJarTo value to the delivery place for jar files. It should be either $ or $. Note, that the source jar file will be delivered to $/Source. ============================================================================ --> <property name="deliverClassesJarTo" value="$"/> <property name="deliverSourceJarTo" value="$/Source"/> <!-- ============================================================================ ============================================================================ The value of sources is a comma delimited list of the source directories such is "edu/*,gov/*". ============================================================================ --> <property name="sources" value="edu/**,gov/**"/> <!-- ========================================================================== --> <!-- ============================================================================ ============================================================================ Make buildClasspath semi-colon delimited. It should include $ and only those jars necessary for building this subsystem ============================================================================ --> <property name="buildClasspath" value=" $; $/advisor.jar; $/diva.jar; $/fits.jar; $/jai_codec.jar; $/jai_core.jar; $/jcchart.jar; $/jdom.jar; $/jsky-overrides.jar; $/jsky.jar; $/jspike.jar; $/OCM.jar; $/Spectrum.jar; $/Utilities.jar "/> <!-- ========================================================================== --> <!-- ============================================================================ ============================================================================ Add any tasks to the init target which should be done before anything else. ============================================================================ --> <target name="init"> <tstamp/> <mkdir dir="$"/> </target> <!-- ========================================================================== --> <!-- ============================================================================ ============================================================================ Customize how the subsystem is built in the compile target. ============================================================================ --> <target name="compile" depends="init"> <javac srcdir="$" optimize="on" destdir="$" deprecation="$" includes="$"> <classpath path="$"/> </javac> </target> <!-- ========================================================================== --> <!-- ============================================================================ ============================================================================ Customize how the subsystem is built in the compiledebug target. ============================================================================ --> <target name="compiledebug" depends="init"> <javac srcdir="$" debug="on" destdir="$" deprecation="$" includes="$"> <classpath path="$"/> </javac> </target> <!-- ========================================================================== --> <!-- ============================================================================ ============================================================================ This copies resources (all files except java and CVS) to the classes tree. You can add more copy tasks to copy other files to the classes tree so they'll be jarred up at delivery time. ============================================================================ --> <target name="copyresources" depends="init"> <copy todir="$/edu"> <fileset dir="$/edu">
]]>
<copy todir="$/gov"> <fileset dir="$/gov"> <exclude name="*/.java"/> <exclude name="**/CVS"/> </fileset> </copy> <copy todir="$/datafiles">
<fileset dir="$/datafiles"> <exclude name="**/*.java"/> <exclude name="**/CVS"/> </fileset> </copy> </target> <!-- ========================================================================== --> <!-- ============================================================================ ============================================================================ The building, delivering and cleaning targets shouldn't be modified as the top level build.xml file for APT depends upon them. ============================================================================ --> <target name="build" depends="compile,copyresources"/> <target name="builddebug" depends="compiledebug, copyresources"/> <target name="rebuild" depends="clean,build"/> <target name="rebuilddebug" depends="clean,builddebug"/> <target name="deliver" depends="build"> <jar jarfile="$/$" basedir="$"/> <jar jarfile="$/$" basedir="$" includes="$"/> </target> <target name="redeliver" depends="cleanall,deliver"/> <target name="deliverdebug" depends="builddebug"> <jar jarfile="$/$" basedir="$"/> <jar jarfile="$/$" basedir="$" includes="$"/>
]]>
<mkdir dir="$"/> <delete includeEmptyDirs="true"> <fileset dir="$" excludes="CVS"/>
</delete>
<delete file="$"/> <delete file="$"/> </target> <target name="cleandelivery"> <delete file="$/$"/>
<delete file="$/$"/>
]]>

0
Comment actions Permalink

I tried the ANT Tool, but it seems that i did something wrong!

I tried: "Build->Generate Ant Build". With the generated *.xml-File I ran the "Ant Build"-Tool. Then the Tool did it's work(I think), but where is the JAR-File??????

0
Comment actions Permalink

Hello Flokati,

I tried the ANT Tool, but it seems that i did something wrong!

I tried: "Build->Generate Ant Build". With the generated *.xml-File I
ran the "Ant Build"-Tool. Then the Tool did it's work(I think), but
where is the JAR-File??????


You need to make such target manually. Please check this small sample IDEA
project:
ftp://intellij.net/pub/.idea/antjar/AntJar.zip

--
Serge Baranov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"


0

Please sign in to leave a comment.