Skip to content

Commit

Permalink
Merge pull request #2 from fabiooliveira72/develop
Browse files Browse the repository at this point in the history
v1.0.0.0 - Updated build.xml to create .jar application for XB2
  • Loading branch information
fabiooliveira72 authored Sep 2, 2022
2 parents 8923874 + bcf0580 commit 8498683
Showing 1 changed file with 34 additions and 52 deletions.
86 changes: 34 additions & 52 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,67 +7,49 @@
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="XBuild" default="default" basedir=".">
<description>Builds, tests, and runs the project XBuild.</description>
<import file="nbproject/build-impl.xml"/>
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:

-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-jar: called before JAR building
-post-jar: called after JAR building
-post-clean: called after cleaning build products
(Targets beginning with '-' are not intended to be called on their own.)
<project name="XBuild" default="main" basedir=".">
<!-- Netbeans build -->
<import file="nbproject/build-impl.xml"/>

Example of inserting an obfuscator after compilation could look like this:
<description>Create XBuild2 Java app for DSSAT</description>

<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
<!-- Version -->
<property name="version" value="v1.0.0.0" />

For list of available properties check the imported
nbproject/build-impl.xml file.
<target name="-post-jar" depends="compile" description="package, output to JAR">
<property name="store.jar.name" value="XBuild2" />

<!-- Java sources -->
<property name="src.dir" location="src" />

Another way to customize the build is by overriding existing main targets.
The targets of interest are:
<!-- Java classes -->
<property name="store.dir" location="build" />

-init-macrodef-javac: defines macro for javac compilation
-init-macrodef-junit: defines macro for junit execution
-init-macrodef-debug: defines macro for class debugging
-init-macrodef-java: defines macro for class execution
-do-jar: JAR building
run: execution of project
-javadoc-build: Javadoc generation
test-report: JUnit report generation
<!-- Output, Jar -->
<tstamp/>
<property name="store.jar" location="${build.dir}/${store.jar.name}-${version}-64-bit.jar" />

An example of overriding the target for project execution could look like this:
<jar destfile="${build.dir}/tmp_build.jar" filesetmanifest="skip">
<zipgroupfileset dir="dist" includes="*.jar"/>
<zipgroupfileset dir="dist/lib" includes="*.jar"/>
<manifest>
<attribute name="Main-Class" value="${main.class}"/>
</manifest>

<target name="run" depends="XBuild-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
</jar>
<zip destfile="${store.jar}">
<zipfileset src="${build.dir}/tmp_build.jar"
excludes="META-INF/*.SF, META-INF/*.DSA, META-INF/*.RSA"/>
</zip>
<delete file="${store.dir}/tmp_build.jar"/>
</target>

Notice that the overridden target depends on the jar target and not only on
the compile target as the regular run target does. Again, for a list of available
properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file.
<target name="clean" description="clean up">
<delete dir="${store.dir}" />
<delete dir="${sotre.jar}" />
</target>

-->
<!-- Default, run this -->
<target name="main" depends="clean, compile, jar" />
</project>

0 comments on commit 8498683

Please sign in to comment.