Start to migrate refine script to use maven

This commit is contained in:
Antonin Delpeuch 2018-08-14 16:45:14 +01:00
parent bc47653c99
commit f371e50217
2 changed files with 62 additions and 44 deletions

94
refine
View File

@ -298,34 +298,41 @@ tools_prepare() {
fi fi
} }
ant_prepare() { mvn_prepare() {
tools_prepare tools_prepare
ANT_VERSION="1.9.0" MVN_VERSION="3.2.2"
ANT_URL="http://archive.apache.org/dist/ant/binaries/apache-ant-${ANT_VERSION}-bin.tar.gz" MVN_URL="https://archive.apache.org/dist/maven/binaries/apache-maven-${MVN_VERSION}-bin.tar.gz"
ANT_FILE=`echo $ANT_URL | sed 's|.*/||'` MVN_FILE=`echo $MVN_URL | sed 's|.*/||'`
ANT_DIR="apache-ant-${ANT_VERSION}" MVN_DIR="apache-maven-${MVN_VERSION}"
ANT="`which ant 2> /dev/null`" MVN="`which mvn 2> /dev/null`"
if [ -z "$ANT" ] ; then
if [ -z "$ANT_HOME" ] ; then if [ -z "$MVN" ] ; then
if [ -z "$MVN_HOME" ] ; then
cd $REFINE_TOOLS_DIR cd $REFINE_TOOLS_DIR
if [ ! -f "$ANT_FILE" ] ; then if [ ! -f "$MVN_FILE" ] ; then
download $ANT_URL $ANT_FILE download $MVN_URL $MVN_FILE
fi fi
if [ ! -d "$ANT_DIR" ] ; then if [ ! -d "$MVN_DIR" ] ; then
tar xzf $ANT_FILE -C . || error "Error while expanding $ANT_FILE" tar xzf $MVN_FILE -C . || error "Error while expanding $MVN_FILE"
fi fi
export ANT_HOME="`pwd`/$ANT_DIR" export MVN_HOME="`pwd`/$MVN_DIR"
if [ "$OS" = "windows" ] ; then if [ "$OS" = "windows" ] ; then
export ANT_HOME=`cygpath --unix "$ANT_HOME"` export MVN_HOME=`cygpath --unix "$MVN_HOME"`
fi fi
cd .. cd ..
fi fi
ANT="$ANT_HOME/bin/ant" MVN="$MVN_HOME/bin/mvn"
fi fi
} }
classpath_prepare() {
mvn_prepare
$MVN -pl server dependency:build-classpath
}
appengine_prepare() { appengine_prepare() {
if [ -z "$APPENGINE_HOME" ] ; then if [ -z "$APPENGINE_HOME" ] ; then
error "You have to have the APPENGINE_HOME environment variable set and pointing to the local installation of the Google AppEngine SDK." error "You have to have the APPENGINE_HOME environment variable set and pointing to the local installation of the Google AppEngine SDK."
@ -450,12 +457,10 @@ jslint_prepare() {
# ---------------------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------------------
ant() { mvn() {
ant_prepare mvn_prepare
#export ANT_OPTS="-Xmx1024M" "$MVN" $MVN_PARAMS -Dversion="$VERSION" -Dfull_version="$FULL_VERSION" $1 || error "Error while running maven task '$1'"
"$ANT" -f build.xml $ANT_PARAMS -Dversion="$VERSION" -Dfull_version="$FULL_VERSION" $1 || error "Error while running ant task '$1'"
} }
# ---------------------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------------------
@ -489,8 +494,9 @@ windows_dist() {
launch4j_prepare launch4j_prepare
ANT_PARAMS="-Dlaunch4j.dir=${REFINE_TOOLS_DIR}/${LAUNCH4J_DIR}" MVN_PARAMS="-Dlaunch4j.dir=${REFINE_TOOLS_DIR}/${LAUNCH4J_DIR}"
ant windows # TODO update this for Maven
mvn windows
} }
linux_dist() { linux_dist() {
@ -498,10 +504,12 @@ linux_dist() {
get_version $1 get_version $1
get_revision get_revision
ant linux # TODO update this for Maven
mvn linux
} }
mac_dist() { mac_dist() {
# TODO update this for Maven, maybe with https://github.com/federkasten/appbundle-maven-plugin ?
check_macosx check_macosx
dist_prepare dist_prepare
get_version $1 get_version $1
@ -572,9 +580,7 @@ mac_dist() {
} }
test() { test() {
server_test $1 mvn test
ui_test $1
extensions_test $1
} }
ui_test() { ui_test() {
@ -616,11 +622,11 @@ ui_test() {
} }
server_test() { server_test() {
ant server_test mvn test -pl main
} }
extensions_test() { extensions_test() {
ant extensions_test mvn test -pl extensions
} }
run() { run() {
@ -635,7 +641,7 @@ run() {
if [ ! -d $REFINE_CLASSES_DIR ] ; then if [ ! -d $REFINE_CLASSES_DIR ] ; then
IS_JAR=`ls $REFINE_LIB_DIR | grep openrefine` IS_JAR=`ls $REFINE_LIB_DIR | grep openrefine`
if [ -z "$IS_JAR" ] ; then if [ -z "$IS_JAR" ] ; then
ant build mvn compile dependency:build-classpath
echo "" echo ""
fi fi
fi fi
@ -672,12 +678,13 @@ run() {
add_option "-Drefine.autosave=$REFINE_AUTOSAVE_PERIOD" add_option "-Drefine.autosave=$REFINE_AUTOSAVE_PERIOD"
fi fi
CLASSPATH="$REFINE_CLASSES_DIR${SEP}$REFINE_LIB_DIR/*" LIB_PATHS=`cat server/classpath.txt`
CLASSPATH="$REFINE_CLASSES_DIR${SEP}$LIB_PATHS"
RUN_CMD="$JAVA -cp $CLASSPATH $OPTS com.google.refine.Refine" RUN_CMD="$JAVA -cp $CLASSPATH $OPTS com.google.refine.Refine"
#echo "$RUN_CMD" echo "$RUN_CMD"
#echo "" echo ""
echo "Starting OpenRefine at 'http://${REFINE_HOST}:${REFINE_PORT}/'" echo "Starting OpenRefine at 'http://${REFINE_HOST}:${REFINE_PORT}/'"
echo "" echo ""
@ -693,7 +700,8 @@ run() {
broker_build() { broker_build() {
build_prepare build_prepare
get_revision get_revision
ant prepare_broker # TODO migrate to Maven
mvn prepare_broker
} }
broker_run() { broker_run() {
@ -715,7 +723,8 @@ broker_run() {
add_option "-Drefine.port=$REFINE_PORT" add_option "-Drefine.port=$REFINE_PORT"
add_option "-Drefine.host=0.0.0.0" add_option "-Drefine.host=0.0.0.0"
CLASSPATH="$REFINE_CLASSES_DIR${SEP}$REFINE_LIB_DIR/*" LIB_PATHS=`cat server/classpath.txt`
CLASSPATH="$REFINE_CLASSES_DIR${SEP}$LIB_PATHS"
RUN_CMD="$JAVA -cp $CLASSPATH $OPTS com.google.refine.Refine" RUN_CMD="$JAVA -cp $CLASSPATH $OPTS com.google.refine.Refine"
@ -738,17 +747,18 @@ broker_appengine_build() {
appengine_prepare appengine_prepare
get_revision get_revision
ANT_PARAMS="-Dappengine.sdk.dir=${APPENGINE_HOME}" MVN_PARAMS="-Dappengine.sdk.dir=${APPENGINE_HOME}"
if [ "$1" ] ; then if [ "$1" ] ; then
ANT_PARAMS="$ANT_PARAMS -Dappengine.app_id=$1" MVN_PARAMS="$MVN_PARAMS -Dappengine.app_id=$1"
fi fi
if [ "$2" ] ; then if [ "$2" ] ; then
ANT_PARAMS="$ANT_PARAMS -Dappengine.version=$2" MVN_PARAMS="$MVN_PARAMS -Dappengine.version=$2"
fi fi
ant prepare_broker_appengine # TODO migrate this to Maven
mvn prepare_broker_appengine
} }
broker_appengine_upload() { broker_appengine_upload() {
@ -764,7 +774,7 @@ broker_appengine_run() {
findbugs() { findbugs() {
findbugs_prepare findbugs_prepare
ANT_PARAMS="-Dfindbugs.dir=${REFINE_TOOLS_DIR}/${FINDBUGS_DIR}" MVN_PARAMS="-Dfindbugs.dir=${REFINE_TOOLS_DIR}/${FINDBUGS_DIR}"
ant findbugs ant findbugs
display "$REFINE_BUILD_DIR/reports/findbugs.html" display "$REFINE_BUILD_DIR/reports/findbugs.html"
@ -997,10 +1007,10 @@ add_option "-Dpython.cachedir=$HOME/.local/share/google/refine/cachedir"
# ----- Respond to the action given -------------------------------------------- # ----- Respond to the action given --------------------------------------------
case "$ACTION" in case "$ACTION" in
build) build_prepare; ant build;; build) build_prepare; mvn compile;;
clean) ant clean;; clean) mvn clean;;
whitespace) whitespace $1;; whitespace) whitespace $1;;
distclean) ant distclean;; distclean) mvn distclean;;
test) test $1;; test) test $1;;
tests) test $1;; tests) test $1;;
ui_test) ui_test $1;; ui_test) ui_test $1;;

View File

@ -86,6 +86,14 @@
</plugins> </plugins>
<pluginManagement> <pluginManagement>
<plugins> <plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<outputFile>classpath.txt</outputFile>
</configuration>
</plugin>
</plugins> </plugins>
</pluginManagement> </pluginManagement>
</build> </build>