From ce6cc028cc9a08cf4ece4a462a540101f28f1512 Mon Sep 17 00:00:00 2001 From: Tomasz Grabiec <tgrabiec@cloudius-systems.com> Date: Mon, 20 Jan 2014 09:36:24 +0100 Subject: [PATCH] java: use maven to build runjava module It will allow to use automatic dependency management. It slows down the build a bit. Incremental build takes 3 seconds longer than previously. First build takes longer due to downloading of maven artifacts. This is once per machine. --- Makefile | 1 + build.mk | 14 +++++++------- java/cloudius/build.xml | 28 --------------------------- java/cloudius/pom.xml | 19 +++++++++++++++++++ java/pom.xml | 35 ++++++++++++++++++++++++++++++++++ java/runjava/build.xml | 31 ------------------------------ java/runjava/pom.xml | 40 +++++++++++++++++++++++++++++++++++++++ modules/java/usr.manifest | 4 ++-- 8 files changed, 104 insertions(+), 68 deletions(-) delete mode 100644 java/cloudius/build.xml create mode 100644 java/cloudius/pom.xml create mode 100644 java/pom.xml delete mode 100644 java/runjava/build.xml create mode 100644 java/runjava/pom.xml diff --git a/Makefile b/Makefile index 85fb46858..7d9716943 100644 --- a/Makefile +++ b/Makefile @@ -36,6 +36,7 @@ $(submake) $(modulemk): Makefile clean: $(call quiet, rm -rf build/$(mode), CLEAN) $(call only-if, $(mgmt), $(call quiet, cd mgmt && ./gradlew --daemon clean >> /dev/null, GRADLE CLEAN)) + $(call quiet, cd java && mvn clean -q, MVN CLEAN) check: export image ?= tests diff --git a/build.mk b/build.mk index 3c1d8a0a1..31bd0806a 100644 --- a/build.mk +++ b/build.mk @@ -244,11 +244,11 @@ tests += tests/tst-hello.so tests/hello/Hello.class: javabase=tests/hello -java-jars = java/runjava.jar java/cloudius.jar -$(java-jars): - $(call quiet, $(silentant) ant -Dmode=$(mode) -Dout=$(out) \ - -e -f $(src)/$(basename $@)/build.xml jar $(if $V,,-q), ANT $@) -.PHONY: $(java-jars) +java-targets = java-jars java/java.so + +java-jars: + $(call quiet, cd $(src)/java && mvn package -q -DskipTests=true, MVN $@) +.PHONY: java-jars tools/%.o: COMMON += -fPIC tools := tools/ifconfig/ifconfig.so @@ -693,8 +693,8 @@ usr.img: bare.img $(out)/usr.manifest $(out)/cmdline $(jni): INCLUDES += -I /usr/lib/jvm/java/include -I /usr/lib/jvm/java/include/linux/ -bootfs.bin: scripts/mkbootfs.py $(out)/bootfs.manifest $(tests) $(java_tests) $(tools) \ - tests/testrunner.so java/java.so $(java-jars) \ +bootfs.bin: scripts/mkbootfs.py $(java-targets) $(out)/bootfs.manifest $(tests) $(java_tests) $(tools) \ + tests/testrunner.so \ zpool.so zfs.so $(call quiet, $(src)/scripts/mkbootfs.py -o $@ -d $@.d -m $(out)/bootfs.manifest \ -D jdkbase=$(jdkbase) -D gccbase=$(gccbase) -D \ diff --git a/java/cloudius/build.xml b/java/cloudius/build.xml deleted file mode 100644 index aba321ca4..000000000 --- a/java/cloudius/build.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project name="cloudius" default="jar" basedir="."> - <property name="build-dir" location="${out}/java/cloudius"/> - <property name="dist-dir" location="${out}/java"/> - <property name="jar-file" location="${dist-dir}/cloudius.jar"/> - - <target name="compile"> - <mkdir dir="${build-dir}"/> - <javac debug="true" - includeantruntime="false" - srcdir="src/main/java" - includes="**/*.java" - destdir="${build-dir}" - source="1.7" - target="1.7"/> - </target> - - <target name="jar" depends="compile"> - <jar jarfile="${jar-file}"> - <fileset dir="${build-dir}"/> - </jar> - </target> - - <target name="clean"> - <delete dir="${build-dir}"/> - <delete dir="${jar-file}"/> - </target> -</project> diff --git a/java/cloudius/pom.xml b/java/cloudius/pom.xml new file mode 100644 index 000000000..52542e8c4 --- /dev/null +++ b/java/cloudius/pom.xml @@ -0,0 +1,19 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 + http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>io.osv</groupId> + <artifactId>java-parent</artifactId> + <version>${version}</version> + </parent> + + <artifactId>cloudius</artifactId> + <packaging>jar</packaging> + + <build> + <finalName>cloudius</finalName> + </build> +</project> diff --git a/java/pom.xml b/java/pom.xml new file mode 100644 index 000000000..05370d8b8 --- /dev/null +++ b/java/pom.xml @@ -0,0 +1,35 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 + http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <properties> + <version>1.0-SNAPSHOT</version> + </properties> + + <groupId>io.osv</groupId> + <artifactId>java-parent</artifactId> + <version>${version}</version> + <packaging>pom</packaging> + + <modules> + <module>cloudius</module> + <module>runjava</module> + </modules> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.1</version> + <configuration> + <source>1.7</source> + <target>1.7</target> + </configuration> + </plugin> + + </plugins> + </build> +</project> diff --git a/java/runjava/build.xml b/java/runjava/build.xml deleted file mode 100644 index a377e6eaa..000000000 --- a/java/runjava/build.xml +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project name="runjava" default="jar" basedir="."> - <property name="build-dir" location="${out}/java/runjava"/> - <property name="dist-dir" location="${out}/java"/> - <property name="jar-file" location="${dist-dir}/runjava.jar"/> - - <target name="compile"> - <mkdir dir="${build-dir}"/> - <javac debug="true" - includeantruntime="false" - srcdir="src/main/java" - includes="**/*.java" - destdir="${build-dir}" - source="1.7" - target="1.7"/> - </target> - - <target name="jar" depends="compile"> - <jar jarfile="${jar-file}"> - <fileset dir="${build-dir}"/> - <manifest> - <attribute name="Main-Class" value="io.osv.RunJava"/> - </manifest> - </jar> - </target> - - <target name="clean"> - <delete dir="${build-dir}"/> - <delete dir="${jar-file}"/> - </target> -</project> diff --git a/java/runjava/pom.xml b/java/runjava/pom.xml new file mode 100644 index 000000000..976e6ce26 --- /dev/null +++ b/java/runjava/pom.xml @@ -0,0 +1,40 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 + http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>io.osv</groupId> + <artifactId>java-parent</artifactId> + <version>${version}</version> + </parent> + + <artifactId>runjava</artifactId> + <packaging>jar</packaging> + + <build> + <plugins> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <configuration> + <descriptorRefs> + <descriptorRef>jar-with-dependencies</descriptorRef> + </descriptorRefs> + <finalName>runjava</finalName> + <appendAssemblyId>false</appendAssemblyId> + <classifier>jar</classifier> + </configuration> + <executions> + <execution> + <id>make-jar-with-dependencies</id> + <phase>package</phase> + <goals> + <goal>single</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> diff --git a/modules/java/usr.manifest b/modules/java/usr.manifest index 12e76356e..7a555f389 100644 --- a/modules/java/usr.manifest +++ b/modules/java/usr.manifest @@ -45,5 +45,5 @@ /&/etc/fonts/conf.d/59-liberation-sans.conf: %(miscbase)s/& /&/etc/fonts/conf.d/59-liberation-serif.conf: %(miscbase)s/& /java.so: java/java.so -/java/runjava.jar: java/runjava.jar -/java/cloudius.jar: java/cloudius.jar +/java/runjava.jar: ${OSV_BASE}/java/runjava/target/runjava.jar +/java/cloudius.jar: ${OSV_BASE}/java/cloudius/target/cloudius.jar -- GitLab