Dev: Add Maven build files [#427]

pull/620/head
gnosygnu 5 years ago
parent bbbc14eb34
commit a5644dea07

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project default="create_jar" name="create runnable jar for XOWA">
<target name="create_jar" depends="">
<jar destfile="./xowa_maven.jar">
<manifest>
<attribute name="Main-Class" value="gplx.xowa.Xowa_main"/>
<attribute name="Class-Path" value=". bin/${plat_name}/swt/swt.jar bin/any/java/apache/commons-compress-1.5.jar bin/any/java/jdbc/sqlite/sqlite-jdbc-3.18.0.jar bin/any/java/luaj/luaj_xowa.jar bin/any/java/jtidy/jtidy_xowa.jar bin/any/java/vnu/vnu.jar bin/any/java/vnu/Saxon-HE-9.9.1-2.jar"/>
</manifest>
<fileset dir="target/classes/"/>
</jar>
</target>
</project>

@ -0,0 +1,270 @@
<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/maven-v4_0_0.xsd"
>
<modelVersion>4.0.0</modelVersion>
<groupId>gplx</groupId>
<artifactId>xowa_maven</artifactId>
<packaging>jar</packaging>
<version>0.1</version>
<name>xowa_maven</name>
<url>http://menmachinesmaterials.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.ibm.icu/icu4j -->
<dependency>
<groupId>com.ibm.icu</groupId>
<artifactId>icu4j</artifactId>
<version>63.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.xerial/sqlite-jdbc -->
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.18.0</version>
</dependency>
<dependency>
<groupId>xowa</groupId>
<artifactId>jtidy_xowa</artifactId>
<version>r938</version>
</dependency>
<dependency>
<groupId>xowa</groupId>
<artifactId>luaj_xowa</artifactId>
<version>2.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.github.veithen.cosmos.bootstrap/org.tukaani.xz -->
<dependency>
<groupId>com.github.veithen.cosmos.bootstrap</groupId>
<artifactId>org.tukaani.xz</artifactId>
<version>0.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.eclipse.swt/org.eclipse.swt.gtk.linux.x86_64 -->
<dependency>
<groupId>org.eclipse.swt</groupId>
<artifactId>org.eclipse.swt.gtk.linux.x86_64</artifactId>
<version>4.3</version>
</dependency>
<!--hack -->
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-analyzers-common-mobile</artifactId>
<version>5.3.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.lucene/lucene-core -->
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core-mobile</artifactId>
<version>5.3.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.lucene/lucene-highlighter -->
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-highlighter-mobile</artifactId>
<version>5.3.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.lucene/lucene-memory -->
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-memory-mobile</artifactId>
<version>5.3.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.lucene/lucene-queries -->
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queries-mobile</artifactId>
<version>5.3.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.lucene/lucene-queryparser -->
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queryparser-mobile</artifactId>
<version>5.3.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/nu.validator/validator -->
<dependency>
<groupId>nu.validator</groupId>
<artifactId>validator</artifactId>
<version>18.11.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/net.sf.saxon/Saxon-HE -->
<dependency>
<groupId>net.sf.saxon</groupId>
<artifactId>Saxon-HE</artifactId>
<version>9.9.1-2</version>
</dependency>
<!--
<dependency>
<groupId>xowa</groupId>
<artifactId>nnio</artifactId>
<version>0.2</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core-mobile</artifactId>
<version>5.3.0</version>
</dependency>
-->
<!-- https://mvnrepository.com/artifact/org.json/json
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20180813</version>
</dependency>
-->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>create-jar</id>
<phase>package</phase>
<configuration>
<target>
<property name="compile_classpath" refid="maven.compile.classpath"/>
<property name="runtime_classpath" refid="maven.runtime.classpath"/>
<!-- <property name="test_classpath" refid="maven.test.classpath"/> -->
<property name="plugin_classpath" refid="maven.plugin.classpath"/>
<property name="outputDir" value="${project.build.outputDirectory}" />
<property name="sourceDir" value="${project.build.sourceDirectory}" />
<ant antfile="${basedir}/build.xml">
<target name="create_jar"/>
</ant>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<debug>true</debug>
<debuglevel>lines,vars,source</debuglevel>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<!-- <classpathPrefix>repo/</classpathPrefix> -->
<mainClass>gplx.xowa.Xowa_main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<version>2.8.1</version>
<!-- <configuration> -->
<!-- <directories> -->
<!-- <directory>${project.build.sourceDirectory}</directory> -->
<!-- <directory>${project.build.directory}/generated-sources</directory> -->
<!-- </directories> -->
<!-- </configuration> -->
<executions>
<execution>
<goals>
<goal>format</goal>
<goal>validate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

@ -0,0 +1,21 @@
# PLAT_NAME must be one of the following: windows_64,linux_64,macosx_64
export plat_name=windows_64
# ROOT_DIR should be created beforehand, and should be in "/" format
export root=c:/xowa_dev
# java settings should match your machine
export jdk=1.7
export JAVA_HOME=C:/000/100_bin/100_os/200_runtime/100_java/100_jdk_1_8_x64
# directories should be set to whatever exists on your machine
export ant=C:/000/100_bin/500_dev/110_java/200_apache_ant/bin/ant
export mvn=C:/000/100_bin/500_dev/110_java/210_apache_maven/bin/mvn
# set "verbose=y" or "verbose="
export verbose=
# run other shell scripts
sh xowa_maven_download.sh
sh xowa_maven_files.sh
sh xowa_maven_mvn.sh

@ -0,0 +1,20 @@
echo * XOWA: downloading latest xowa
cd $root
rm -rf ./src
mkdir src
cd src
git clone https://github.com/gnosygnu/xowa.git
cd ..
echo * XOWA: regen xowa_maven root
rm -rf ./src/xowa_maven
mkdir -p ./src/xowa_maven
echo * XOWA: copying maven files to root
cp -rf ./src/xowa/res/dev/make/maven/*.xowa_maven_download.sh ./
cp -rf ./src/xowa/res/dev/make/maven/*.xowa_maven_files.sh ./
cp -rf ./src/xowa/res/dev/make/maven/*.xowa_maven_mvn.sh ./
cp -rf ./src/xowa/res/dev/make/maven/*.txt ./
echo * XOWA: copying maven pom.xml and build.xml
cp -rf ./src/xowa/res/dev/make/maven/*.xml ./src/xowa_maven

@ -0,0 +1,58 @@
echo * XOWA: copy res to xowa_maven
cp -R$verbose ./src/xowa/res ./src/xowa_maven
echo * XOWA: copy user / bin to runtime locations
cp -R$verbose ./src/xowa_maven/res/user ./src/xowa_maven
cp -R$verbose ./src/xowa_maven/res/bin ./src/xowa_maven
echo * XOWA: prepare source directories
mkdir -p ./src/xowa_maven/src/main/java/gplx
mkdir -p ./src/xowa_maven/src/test/java/gplx
echo * XOWA: create mavenize_xowa function
mavenize_xowa ()
{
echo * XOWA: mavenizing $1
# main <- all non test files
find $1 -depth -type f \
\( ! -name '*_tst.java' \
-a ! -name '*_fxt.java' \
-a ! -name '*_mok.java' \
-a ! -name '*Test.java' \
\) \
-exec cp --parents -pr$verbose '{}' './src/xowa_maven/src/main/java/gplx/' ';'
# main <- all test files
find $1 -depth -type f \
\( -name '*_tst.java' \
-o -name '*_fxt.java' \
-o -name '*_mok.java' \
-o -name '*Test.java' \
\) \
-exec cp --parents -pr$verbose '{}' './src/xowa_maven/src/test/java/gplx/' ';'
}
# package: core
mavenize_xowa ./src/xowa/100_core/
# package: gfml
mavenize_xowa ./src/xowa/110_gfml/src_100_tkn/gplx/
mavenize_xowa ./src/xowa/110_gfml/src_200_type/gplx/
mavenize_xowa ./src/xowa/110_gfml/src_300_gdoc/gplx/
mavenize_xowa ./src/xowa/110_gfml/src_400_pragma/gplx/
mavenize_xowa ./src/xowa/110_gfml/src_500_build/gplx/
mavenize_xowa ./src/xowa/110_gfml/src_600_rdrWtr/gplx/
mavenize_xowa ./src/xowa/110_gfml/tst/gplx/
# package: 140_dbs
mavenize_xowa ./src/xowa/140_dbs/src/gplx/
# mavenize_xowa ./src/xowa/140_dbs/tst/gplx/ # tests in this folder require mysql and postgres server
# package: gfui
mavenize_xowa ./src/xowa/150_gfui/src/gplx/
# package: xowa
mavenize_xowa ./src/xowa/400_xowa/src/gplx/
# package: gflucene
mavenize_xowa ./src/xowa/gplx.gflucene/src/gplx/

@ -0,0 +1,24 @@
cd ./src/xowa_maven
# install files from xowa.git to local repo; note that these files aren't in any maven repository
echo * XOWA: installing non-Maven repo artifacts
$mvn install:install-file -Dfile=bin/any/java/jtidy/jtidy_xowa.jar -DgroupId=xowa -DartifactId=jtidy_xowa -Dversion=r938 -Dpackaging=jar
$mvn install:install-file -Dfile=bin/any/java/luaj/luaj_xowa.jar -DgroupId=xowa -DartifactId=luaj_xowa -Dversion=2.0 -Dpackaging=jar
$mvn install:install-file -Dfile=bin/any/java/lucene/5.3.0.drd/lucene-analyzers-common-5.3.0-mobile-2.jar -DgroupId=org.apache.lucene -DartifactId=lucene-analyzers-common-mobile -Dversion=5.3.0 -Dpackaging=jar
$mvn install:install-file -Dfile=bin/any/java/lucene/5.3.0.drd/lucene-core-5.3.0-mobile-2.jar -DgroupId=org.apache.lucene -DartifactId=lucene-core-mobile -Dversion=5.3.0 -Dpackaging=jar
$mvn install:install-file -Dfile=bin/any/java/lucene/5.3.0.drd/lucene-highlighter-5.3.0-mobile-2.jar -DgroupId=org.apache.lucene -DartifactId=lucene-highlighter-mobile -Dversion=5.3.0 -Dpackaging=jar
$mvn install:install-file -Dfile=bin/any/java/lucene/5.3.0.drd/lucene-memory-5.3.0-mobile-2.jar -DgroupId=org.apache.lucene -DartifactId=lucene-memory-mobile -Dversion=5.3.0 -Dpackaging=jar
$mvn install:install-file -Dfile=bin/any/java/lucene/5.3.0.drd/lucene-queries-5.3.0-mobile-2.jar -DgroupId=org.apache.lucene -DartifactId=lucene-queries-mobile -Dversion=5.3.0 -Dpackaging=jar
$mvn install:install-file -Dfile=bin/any/java/lucene/5.3.0.drd/lucene-queryparser-5.3.0-mobile-2.jar -DgroupId=org.apache.lucene -DartifactId=lucene-queryparser-mobile -Dversion=5.3.0 -Dpackaging=jar
$mvn install:install-file -Dfile=bin/any/java/jdbc/sqlite/sqlite-jdbc-3.18.0.jar -DgroupId=xowa -DartifactId=sqllite -Dversion=3.18.0 -Dpackaging=jar
$mvn install:install-file -Dfile=bin/any/java/vnu/vnu.jar -DgroupId=xowa -DartifactId=validator -Dversion=18.11.5 -Dpackaging=jar
echo * XOWA: running
$mvn clean
$mvn formatter:format
$mvn compile
$mvn -Dtest="gplx.**" test
$ant -v -buildfile build.xml -Dplat_name=$plat_name
echo * XOWA: launching xowa
java -jar xowa_maven.jar

@ -0,0 +1,73 @@
== Reading this file ==
To view this file with formatting, do the following:
* Go to https://en.wikipedia.org/w/index.php?title=Wikipedia:Sandbox&action=edit
* Paste this entire file into the box
* Press "Show Preview"
== Purpose ==
The xowa_maven.sh script will do the following:
* Download the latest source code of XOWA
* Compile the code
* Run the unit tests
* Build a runnable jar
== Requirements ==
The shell script requires 4 applications:
* Git 2.21+
* Java 1.7+ JDK
* Maven 3.6+
* Apache Ant 1.9+
The shell script also requires an internet connection for the following:
* Download necessary binaries
* Download XOWA git repository
* Download Maven repositories
== Setup ==
Windows instructions are listed below.
* Java will come installed on most Linux / Mac OS X system
* Git / Maven / Ant can downloaded / set-up
In addition, file paths in this README follow the Windows convention (C:\xowa\ instead of C:/xowa/)
However, the shell script uses the Unix convention (C:/xowa/)
Finally, note that directories are given for example purposes only. Feel free to change C:\xowa_dev to D:\whatever_you_want
=== Binaries ===
==== Git ====
===== Windows =====
* Download "Git for Windows Portable" from https://git-scm.com/download/win
* Unzip it to C:\xowa_dev\bin\git
==== Java 1.8 JDK ====
* Download "Java SE Development Kit 8u###" from https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
* Install it
* Confirm the JAVA_HOME variable exists
* echo %JAVA_HOME%
* EX: C:\xowa_dev\bin\java_jdk_1_8
==== Maven ====
* Download "apache-maven-#.#.#-bin.zip" https://maven.apache.org/download.cgi
* Unzip it to C:\xowa_dev\bin\maven
==== Apache Ant ====
* Download "#.#.##.zip" https://ant.apache.org/bindownload.cgi
* Unzip it to C:\xowa_dev\bin\ant
==== Minttyrc (Optional: for Ctrl+V) ====
* Open $HOME/.minttyrc
* Add $CtrlExchangeShift=yes
https://github.com/mintty/mintty/issues/602
=== Boot ===
* Copy xowa_maven_boot.sh to C:\xowa_dev\xowa_maven_boot.sh
* Review all the exports and make sure they match
** The platform type (windows vs linux vs macosx)
** The directories on your machine
== Launch Git ==
* Run C:\xowa_dev\bin\git\git-bash.exe
* Run git config --global core.autocrlf false
* autocrlf needs to be disabled on Windows boxes, or else, Git will change all .txt to \r\n . This will break xowa.gfs
* Run xowa_maven_boot.sh

@ -54,5 +54,5 @@ find ./src -type f -name '*_fxt.java' -delete
find ./src -type f -name '*_mok.java' -delete
# == BUILD XOWA ==
$ANT_BINARY -v -buildfile ./dev/make/xowa_compile.xml -Droot_dir=$ROOT_DIR -Djdk=$JAVA_JDK_VERSION
$ANT_BINARY -v -buildfile ./dev/make/xowa_make_jar.xml -Droot_dir=$ROOT_DIR -Dplat_name=$PLAT_NAME -Dxowa_jar_path=$ROOT_DIR/xowa_dev.jar
$ANT_BINARY -v -buildfile ./dev/make/ant/xowa_compile.xml -Droot_dir=$ROOT_DIR -Djdk=$JAVA_JDK_VERSION
$ANT_BINARY -v -buildfile ./dev/make/ant/xowa_make_jar.xml -Droot_dir=$ROOT_DIR -Dplat_name=$PLAT_NAME -Dxowa_jar_path=$ROOT_DIR/xowa_dev.jar

Loading…
Cancel
Save