Skip to content

Commit

Permalink
Update build files, make build system more robust to changes in bundl…
Browse files Browse the repository at this point in the history
…e.dest

git-svn-id: http://svn.bigcat.unimaas.nl/bridgedb/trunk@658 e3f1d335-44b1-4163-9530-9b341189ae98
  • Loading branch information
martijn committed Oct 10, 2012
1 parent 996c987 commit e782bee
Show file tree
Hide file tree
Showing 19 changed files with 161 additions and 224 deletions.
83 changes: 15 additions & 68 deletions benchmarking/build.xml
Original file line number Diff line number Diff line change
@@ -1,77 +1,24 @@
<?xml version="1.0"?>
<project name="org.bridgedb.tools.benchmarking" default="jar" basedir=".">

<path id="project.class.path">
<pathelement location="build"/>
<fileset dir="lib">
<include name="*.jar"/>
</fileset>
<pathelement location="../dist/org.bridgedb.jar"/>
<pathelement location="../dist/derby.jar"/>
<!--TODO make sure corelib build is called first -->
</path>

<path id="class.path">
<fileset dir="../dist">
<include name="*.jar"/>
<import file="../build-common.xml" />

<path id="absolute.deps">
<fileset dir="${bundle.dest}">
<include name="org.bridgedb.jar"/>
<include name="org.bridgedb.bio.jar"/>
<include name="org.bridgedb.server.jar"/>
<include name="derby.jar"/>
</fileset>
<fileset dir="lib">
<include name="*.jar"/>
<fileset dir="../common-bundles">
<include name="com.google.collect*.jar"/>
</fileset>
</path>

<target name="prepare">
<mkdir dir="build"/>
</target>

<target name="clean" description="Remove all generated files.">
<delete dir="${build.dir}"/>
</target>

<target name="build" depends="prepare" description="Compile all sources">
<javac srcdir="src"
debug="true"
destdir="build">
<classpath refid="class.path"/>
</javac>
</target>

<target name="jar" depends="build">
<mkdir dir="dist"/>
<jar jarfile="dist/checker.jar">
<manifest>
<attribute name="Main-Class" value="org.bridgedb.checker.Checker"/>
<attribute name="Class-Path" value="bridgedb.jar google-collect-snapshot-20080820.jar"/>
</manifest>
<fileset dir="build" includes="**/*.class"/>
</jar>
</target>

<target name="dist" depends="jar"/>

<target name="test" depends="build">
<path id="test.classpath">
<path refid="class.path"/>
<pathelement location="build"/>
<pathelement location="../corelib/build-lib/junit.jar"/>
<pathelement location="../corelib/build-lib/measure.jar"/>
<pathelement location="../corelib/build-lib/derbyclient.jar"/>
</path>
<javac srcdir="test" debug="true"
includes="**"
destdir="build"
source="1.5">
<classpath refid="test.classpath"/>
</javac>
<junit printsummary="on" haltonfailure="false" fork="true">
<formatter type="brief" usefile="false"/>
<classpath refid="test.classpath"/>
<batchtest>
<fileset dir="test">
<include name="**/*Test*.java"/>
</fileset>
</batchtest>
</junit>
</target>
<path id="test.deps">
<pathelement location="../corelib/build-lib/junit.jar"/>
<pathelement location="../corelib/build-lib/measure.jar"/>
<pathelement location="../corelib/build-lib/derbyclient.jar"/>
</path>

</project>
41 changes: 26 additions & 15 deletions build-common.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@

<property file="version.props"/>

<!-- Override this to put the jars in a different target directory -->
<property name="bundle.dest" value="../dist"/>

<target name="prepare-jar-name">
<!-- the name of the plug-in jar uses the project name of the calling build file -->
<!-- the name of the plug-in jar is the project name of the calling build file with '.jar' appended -->
<property name="jar.name" value="${bundle.dest}/${ant.project.name}.jar"/>
</target>

<target name="prepare-common">
<target name="prepare-common" depends="prepare-jar-name">
<mkdir dir="build"/>

<!-- the following property is used to skip the "test" target if there is no test subdirectory -->
Expand All @@ -28,7 +29,7 @@

<target name="prepare"/> <!-- designed to be overriden by project build file -->

<target name="build" depends="prepare, prepare-common, prepare-jar-name">
<target name="build" depends="prepare, prepare-common">
<javac srcdir="src"
includes="**"
debug="true"
Expand All @@ -37,7 +38,7 @@
</javac>
</target>

<!-- if the embed.jars property is specified, unjar those jars into the build directory -->
<!-- if the embed.jars property is specified, those jars will be unjarred into the build directory -->
<target name="unjar-embedded" depends="build">
<unjar dest="build">
<path refid="embed.jars"/>
Expand All @@ -46,15 +47,23 @@

<target name="jar-common" depends="build, unjar-embedded">
<echo>Creating JAR: ${jar.name}</echo>
<manifestclasspath property="manifest.cp" jarfile="${jar.name}">
<classpath>
<path refid="absolute.deps"/>
<path refid="transient.deps"/>
</classpath>
</manifestclasspath>

<!-- convert classpath to a flat list/string for use as manifest classpath.
We want a flat list, assuming all jars will end up in the same destination dir.
We can't use the manifestclasspath task for this, because it will try to figure
out relative paths, which is not what we want because the jars are not in their
final location -->
<pathconvert property="manifest.cp" pathsep=" ">
<path refid="absolute.deps"/>
<path refid="transient.deps"/>
<flattenmapper />
</pathconvert>
<!-- In eclipse, you need create a Bundle-ClassPath entry in MANIFEST.MF for each non-OSGI jar.
This causes trouble if we are running outside eclipse, because the jars usually end up in a different location.
The trick is to remove the bundle-classpath used by eclipse, we embed these jars instead -->
<copy file="META-INF/MANIFEST.MF" toDir="build/META-INF"/>
<!-- The trick is to ignore the bundle-classpath used by eclipse, we embed these jars instead -->
<replaceregexp file="build/META-INF/MANIFEST.MF" match="^Bundle-ClassPath:" replace="Ignore-this:" flags="m"/>
<!-- Finally, create the jar file. Include all resources, build results, and manifest. -->
<jar jarfile="${jar.name}" manifest="META-INF/MANIFEST.MF">
<manifest>
<attribute name="Class-Path" value="${manifest.cp}"/>
Expand All @@ -70,22 +79,24 @@

<target name="jar" depends="jar-common"/> <!-- may be overriden by project build file -->

<!-- just removes class files -->
<target name="clean">
<delete dir="build"/>
</target>

<!-- removes class files and generated jar -->
<target name="dist-clean" depends="clean, prepare-jar-name">
<delete file="${jar.name}"/>
</target>

<!-- creates the jar, and also places all dependencies in the bundle dest directory -->
<target name="dist" depends="jar">
<copy todir="../dist">
<fileset dir="lib" erroronmissingdir="false">
<include name="*.jar"/>
</fileset>
<copy todir="${bundle.dest}">
<path refid="absolute.deps"/>
</copy>
</target>

<!-- run all junit tests found in the test directory -->
<target name="test" depends="build" if="test.dir.exists">
<path id="test.classpath">
<path refid="absolute.deps"/>
Expand Down
19 changes: 10 additions & 9 deletions dbbuilder/build.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
<?xml version="1.0"?>
<project name="org.bridgedb.tools.dbbuilder" default="jar" basedir=".">

<import file="../build-common.xml" />

<!-- absolute deps are used for building, testing and in the manifest classpath -->
<path id="absolute.deps">
<pathelement location="../dist/org.bridgedb.jar"/>
<pathelement location="../dist/org.bridgedb.bio.jar"/>
<pathelement location="../dist/org.bridgedb.rdb.jar"/>
<pathelement location="../dist/org.bridgedb.rdb.construct.jar"/>
</path>
<path id="absolute.deps">
<fileset dir="${bundle.dest}">
<include name="org.bridgedb.jar"/>
<include name="org.bridgedb.bio.jar"/>
<include name="org.bridgedb.rdb.jar"/>
<include name="org.bridgedb.rdb.construct.jar"/>
</fileset>
</path>

<!-- embedded jars are embedded in the resulting bundle -->
<path id="embed.jars">
<!-- None -->
</path>

<import file="../build-common.xml" />


</project>
8 changes: 4 additions & 4 deletions org.bridgedb.bio/build.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?xml version="1.0"?>
<project name="org.bridgedb.bio" default="dist" basedir=".">


<import file="../build-common.xml" />

<!-- absolute deps are used for building, testing and in the manifest classpath -->
<path id="absolute.deps">
<pathelement location="../dist/org.bridgedb.jar"/>
<pathelement location="${bundle.dest}/org.bridgedb.jar"/>
</path>

<!-- transient deps are optional, they are used only in the manifest classpath -->
Expand All @@ -22,6 +24,4 @@
<pathelement location="../org.bridgedb/build-lib/hamcrest-core.jar"/>
</path>

<import file="../build-common.xml" />

</project>
6 changes: 3 additions & 3 deletions org.bridgedb.file.orthoxml/build.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?xml version="1.0"?>
<project name="org.bridgedb.file.orthoxml" default="dist" basedir=".">

<import file="../build-common.xml" />

<!-- absolute deps are used for building, testing and in the manifest classpath -->
<path id="absolute.deps">
<fileset dir="../dist">
<fileset dir="${bundle.dest}">
<include name="org.bridgedb.jar"/>
<include name="org.bridgedb.bio.jar"/>
</fileset>
Expand All @@ -24,6 +26,4 @@
<pathelement location="../org.bridgedb/build-lib/junit4.jar"/>
</path>

<import file="../build-common.xml" />

</project>
8 changes: 4 additions & 4 deletions org.bridgedb.gui/build.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?xml version="1.0"?>
<project name="org.bridgedb.gui" default="dist" basedir=".">


<import file="../build-common.xml" />

<!-- absolute deps are used for building, testing and in the manifest classpath -->
<path id="absolute.deps">
<fileset dir="../dist">
<fileset dir="${bundle.dest}">
<include name="org.bridgedb.jar"/>
<include name="org.bridgedb.webservice.bridgerest.jar"/>
<include name="org.bridgedb.rdb.jar"/>
Expand All @@ -26,6 +28,4 @@
<pathelement location="../org.bridgedb/build-lib/hamcrest-core.jar"/>
</path>

<import file="../build-common.xml" />

</project>
10 changes: 6 additions & 4 deletions org.bridgedb.rdb.construct/build.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?xml version="1.0"?>
<project name="org.bridgedb.rdb.construct" default="dist" basedir=".">

<import file="../build-common.xml" />

<!-- absolute deps are used for building, testing and in the manifest classpath -->
<path id="absolute.deps">
<fileset dir="../dist">
<fileset dir="${bundle.dest}">
<include name="org.bridgedb.jar"/>
<include name="org.bridgedb.bio.jar"/>
<include name="org.bridgedb.rdb.jar"/>
Expand All @@ -12,7 +14,9 @@

<!-- transient deps are optional, they are used only in the manifest classpath -->
<path id="transient.deps">
<pathelement location="lib/derby.jar"/>
<fileset dir="${bundle.dest}">
<include name="derby.jar"/>
</fileset>
</path>

<!-- embedded jars are embedded in the resulting bundle -->
Expand All @@ -25,6 +29,4 @@
<!-- nothing yet... -->
</path>

<import file="../build-common.xml" />

</project>
10 changes: 6 additions & 4 deletions org.bridgedb.rdb/build.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
<?xml version="1.0"?>
<project name="org.bridgedb.rdb" default="dist" basedir=".">

<import file="../build-common.xml" />

<!-- absolute deps are used for building, testing and in the manifest classpath -->
<path id="absolute.deps">
<fileset dir="../dist">
<fileset dir="${bundle.dest}">
<include name="org.bridgedb.jar"/>
<include name="org.bridgedb.bio.jar"/>
</fileset>
</path>

<!-- transient deps are optional, they are used only in the manifest classpath -->
<path id="transient.deps">
<pathelement location="lib/derby.jar"/>
<fileset dir="${bundle.dest}">
<include name="derby.jar"/>
</fileset>
</path>

<!-- embedded jars are embedded in the resulting bundle -->
Expand All @@ -27,6 +31,4 @@
<pathelement location="build-lib/derbyclient.jar"/>
</path>

<import file="../build-common.xml" />

</project>
30 changes: 16 additions & 14 deletions org.bridgedb.server/build.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
<?xml version="1.0"?>
<project name="org.bridgedb.server" default="dist" basedir=".">

<import file="../build-common.xml" />

<!-- absolute deps are used for building, testing and in the manifest classpath -->
<path id="absolute.deps">
<pathelement location="../dist/org.bridgedb.jar"/>
<pathelement location="../dist/org.bridgedb.bio.jar"/>
<pathelement location="../dist/org.bridgedb.rdb.jar"/>
<fileset dir="${bundle.dest}">
<include name="org.bridgedb.jar"/>
<include name="org.bridgedb.bio.jar"/>
<include name="org.bridgedb.rdb.jar"/>
</fileset>
</path>

<!-- transient deps are optional, they are used only in the manifest classpath -->
Expand All @@ -24,16 +28,16 @@
<pathelement location="../org.bridgedb/build-lib/junit.jar"/>
</path>

<!-- override main class and classpath in manifest -->
<target name="jar" depends="jar-common">
<jar jarfile="${jar.name}" update="true">
<manifest>
<attribute name="Main-Class" value="org.bridgedb.server.Server"/>
<attribute name="Class-Path" value="derby.jar org.bridgedb.jar org.bridgedb.bio.jar org.bridgedb.rdb.jar org.restlet.jar commons-cli-1.2.jar"/>
</manifest>
</jar>
</target>

<target name="jar" depends="build">
<jar jarfile="${jar.name}" update="true">
<manifest>
<attribute name="Main-Class" value="org.bridgedb.server.Server"/>
<attribute name="Class-Path" value="derby.jar org.bridgedb.jar org.bridgedb.bio.jar org.bridgedb.rdb.jar org.restlet.jar commons-cli-1.2.jar"/>
</manifest>
</jar>
</target>

<target name="war" depends="jar">
<fail message="You must specify the bridgedb config file that specifies the database locations for the web application. Example: ant war -Dbridge.config=/home/thomas/data/bridgedb/bridge.config.">
<condition>
Expand Down Expand Up @@ -61,6 +65,4 @@
<!-- Disabled for now... -->
</target>

<import file="../build-common.xml" />

</project>
Loading

0 comments on commit e782bee

Please sign in to comment.