Import Ant build.xml into Gradle and use old compile of servlets in Gradle

to be able to use/reuse Ant targets where task has not been implemented in Gradle build.
- use the import to include the compile of htroot as first important task

  ! it is possible that first build fails an compile of GitRevTask.jar !
  ! solution/workaround -> use "ant all" once to compile GitRevTask.jar !

- adjusted build.xml a little
   - split compile-core into compile-core and compile-htroot to have a target for htroot comp. only
   - set build-path to reuse Gradles build directory
   - (fix javadoc failure)

- changed the filtered-copy of yacyBuildProperties.java to ! the build path :-(
  as current (copy,delete,exclude) is complicated and not migration worthy,
  used simple/straigt forward approach (using a yacyBuildProperties.java.template file as copy source)
pull/442/head
reger24 3 years ago
parent 426c47013c
commit 3e34f7c596

1
.gitignore vendored

@ -21,3 +21,4 @@ yacy.log
/javadoc/ /javadoc/
/build/ /build/
.gradle .gradle
source/net/yacy/peers/operation/yacyBuildProperties.java

@ -109,3 +109,29 @@ task copyDependenciesToLib(type: Copy) {
} }
build.dependsOn(copyDependenciesToLib) build.dependsOn(copyDependenciesToLib)
} }
/** -----------------------------------------------------------
* Settings during the migration from Ant to Gradle build
* importing Ant targets and to use them within this Gradle build
* until/where functionality has not been migrated yet
* ------------------------------------------------------------
*/
// Import Ant build and prefix all task names with 'ant_' to prevent naming conflict with Gradle tasks.
ant.importBuild('build.xml') { antTaskName -> "ant_${antTaskName}".toString() }
// Set group property for all Ant tasks.
tasks.matching { task -> task.name.startsWith('ant_') }*.group = 'Ant'
// include compile of htroot servlets in Gradle lifecycle somewhere after compileJava
startScripts.dependsOn("ant_compile-htroot")
tasks.named('ant_buildGitRevTask') {
doFirst {
println '====================================='
println 'In case this imported Ant task fails'
println '(stop ant jvm which on failure keeps a lock on libbuild/GitRevTask.jar (making supsequent builds fail too)'
println '- run the normal ant build "ant all" ONCE (to complile the libbuild/GitRevTask.jar)'
println '- after this Gradle build should work'
println '====================================='
}
}

@ -43,7 +43,7 @@
<property name="lib" location="lib"/> <property name="lib" location="lib"/>
<property name="libt" location="libt"/> <property name="libt" location="libt"/>
<property name="libbuild" location="libbuild"/> <property name="libbuild" location="libbuild"/>
<property name="build" location="classes"/> <property name="build" location="build/classes/java/main"/> <!-- reuse Gradle build path -->
<property name="javadoc" location="javadoc"/> <property name="javadoc" location="javadoc"/>
<property name="htroot" location="htroot"/> <property name="htroot" location="htroot"/>
<property name="test" location="test/java"/> <property name="test" location="test/java"/>
@ -81,7 +81,7 @@
</condition> </condition>
<target name="buildGitRevTask"> <target name="buildGitRevTask">
<delete file="${libbuild}/GitRevTask.jar" failonerror="false" /> <!-- <delete file="${libbuild}/GitRevTask.jar" failonerror="false" /> deleted via clean no need to do it all the time -->
<javac srcdir="${libbuild}/GitRevTask" includeantruntime="true" encoding="UTF-8"> <javac srcdir="${libbuild}/GitRevTask" includeantruntime="true" encoding="UTF-8">
<classpath> <classpath>
<pathelement location="${libbuild}/org.eclipse.jgit-4.5.0.201609210915-r.jar" /> <pathelement location="${libbuild}/org.eclipse.jgit-4.5.0.201609210915-r.jar" />
@ -146,11 +146,10 @@
<filter token="REPL_RESTARTCMD" value="${RESTARTCMD}"/> <filter token="REPL_RESTARTCMD" value="${RESTARTCMD}"/>
<!-- apply replacments --> <!-- apply replacments -->
<delete file="${build}/net/yacy/peers/operation/yacyBuildProperties.java" failonerror="false"/> <copy file="${src}/net/yacy/peers/operation/yacyBuildProperties.java.template" tofile="${src}/net/yacy/peers/operation/yacyBuildProperties.java" overwrite="true" filtering="true" />
<copy file="${src}/net/yacy/peers/operation/yacyBuildProperties.java" tofile="${build}/net/yacy/peers/operation/yacyBuildProperties.java" overwrite="true" filtering="true" />
<!-- copy log4j config file --> <!-- copy log4j config file -->
<copy file="${src}/log4j.properties" tofile="${build}/log4j.properties" overwrite="true" filtering="true" /> <copy file="${src}/log4j.properties" tofile="${build}/log4j.properties" overwrite="true" filtering="true" /> <!-- @TODO: obsolete, contains no replace/filter pattern -->
</target> </target>
@ -159,7 +158,8 @@
windowtitle="YaCy API: javadoc documentation" windowtitle="YaCy API: javadoc documentation"
encoding="UTF-8" encoding="UTF-8"
charset="UTF-8" charset="UTF-8"
access="private"> access="private"
useexternalfile="true">
<fileset dir="${src}"> <fileset dir="${src}">
<include name="**/*.java"/> <include name="**/*.java"/>
</fileset> </fileset>
@ -280,6 +280,7 @@
<target name="compile-core" depends="init" description="compile YaCy core"> <target name="compile-core" depends="init" description="compile YaCy core">
<!-- compile yacyBuildProperties.java --> <!-- compile yacyBuildProperties.java -->
<!-- *obsolete* - for Gradle migration process changed to use *.java.template file for filtered copy
<javac srcdir="${build}" destdir="${build}" sourcepath="${src}" <javac srcdir="${build}" destdir="${build}" sourcepath="${src}"
debug="true" debuglevel="lines,vars,source" includeantruntime="false" debug="true" debuglevel="lines,vars,source" includeantruntime="false"
includes="net/yacy/peers/operation/yacyBuildProperties.java" includes="net/yacy/peers/operation/yacyBuildProperties.java"
@ -288,11 +289,10 @@
<compilerarg value="-Xlint"/> <compilerarg value="-Xlint"/>
</javac> </javac>
<delete file="${build}/BuildProperties.java" /> <delete file="${build}/BuildProperties.java" />
-->
<!-- compile the core sources --> <!-- compile the core sources -->
<javac srcdir="${src}/" destdir="${build}" <javac srcdir="${src}/" destdir="${build}"
debug="true" debuglevel="lines,vars,source" includeantruntime="false" debug="true" debuglevel="lines,vars,source" includeantruntime="false"
excludes="net/yacy/peers/operation/yacyBuildProperties.java"
source="${javacSource}" target="${javacTarget}" encoding="UTF-8"> source="${javacSource}" target="${javacTarget}" encoding="UTF-8">
<classpath refid="project.class.path" /> <classpath refid="project.class.path" />
<compilerarg value="-Xlint"/> <compilerarg value="-Xlint"/>
@ -319,7 +319,7 @@
</target> </target>
<target name="compile" depends="compile-core" description="compile YaCy core and YaCy servlets"> <target name="compile-htroot" depends="init" description="compile YaCy servlets">
<!-- compile htroot, htroot/yacy and htroot/htdocsdefault --> <!-- compile htroot, htroot/yacy and htroot/htdocsdefault -->
<javac srcdir="${htroot}/" <javac srcdir="${htroot}/"
excludes="processing/**" excludes="processing/**"
@ -329,6 +329,8 @@
<compilerarg value="-Xlint"/> <compilerarg value="-Xlint"/>
</javac> </javac>
</target> </target>
<target name="compile" depends="compile-core, compile-htroot" description="compile YaCy core and YaCy servlets" />
<target name="all" depends="compile"> <target name="all" depends="compile">
</target> </target>
@ -538,18 +540,17 @@
<!-- make clean --> <!-- make clean -->
<target name="clean" description="make clean"> <target name="clean" description="make clean">
<delete dir="${release_main}" failonerror="false"/> <delete dir="${release_main}" failonerror="false"/>
<delete file="${build}/net/yacy/peers/operation/yacyBuildProperties.java" failonerror="false"/>
<delete file="${build}/log4j.properties" failonerror="false"/> <delete file="${build}/log4j.properties" failonerror="false"/>
<delete file="${lib}/yacycore.jar" failonerror="false"/> <delete file="${lib}/yacycore.jar" failonerror="false"/>
<delete file="${lib}/svnRevNr.jar" failonerror="false"/> <delete file="${lib}/svnRevNr.jar" failonerror="false"/> <!-- @TODO: obsolete, never generated -->
<delete file="${libbuild}/svnRevNr.jar" failonerror="false"/> <delete file="${libbuild}/svnRevNr.jar" failonerror="false"/> <!-- @TODO: obsolete, never generated -->
<delete file="${libbuild}/GitRevTask.jar" failonerror="false"/> <delete file="${libbuild}/GitRevTask.jar" failonerror="false"/>
<delete failonerror="false"> <delete failonerror="false">
<fileset dir="${src}" includes="**/*.class" /> <fileset dir="${src}" includes="**/*.class" />
<fileset dir="${build}" includes="**/*.class" /> <fileset dir="${build}" includes="**/*.class" />
<fileset dir="${htroot}" includes="**/*.class" /> <fileset dir="${htroot}" includes="**/*.class" />
<fileset dir="test/" includes="**/*.class" /> <fileset dir="test/" includes="**/*.class" />
<fileset dir="${libbuild}/svnRevNr" includes="**/*.class" /> <fileset dir="${libbuild}/svnRevNr" includes="**/*.class" /> <!-- @TODO: obsolete, never generated -->
<fileset dir="${libbuild}/GitRevTask" includes="**/*.class" /> <fileset dir="${libbuild}/GitRevTask" includes="**/*.class" />
<fileset dir="." includes="TEST-*" /> <fileset dir="." includes="TEST-*" />
</delete> </delete>

@ -0,0 +1,72 @@
package net.yacy.peers.operation;
import java.util.Locale;
import java.util.regex.Pattern;
/**
* Properties set when compiling this release/version
*/
public final class yacyBuildProperties {
private yacyBuildProperties() {
}
/**
* returns the SVN-Revision Number as a String
*/
public static String getSVNRevision() {
final String revision = "@REPL_REVISION_NR@";
if (revision.contains("@") || revision.contains("$")) {
return "0";
}
return revision;
}
/**
* returns the version String (e. g. 0.9)
*/
public static String getVersion() {
if ("@REPL_VERSION@".contains("@") ) {
return "0.1";
}
return "@REPL_VERSION@";
}
public static final Pattern versionMatcher = Pattern.compile("\\A(\\d+\\.\\d{1,3})(\\d{0,5})\\z");
/**
* returns the long version String (e. g. 0.9106712)
*/
public static String getLongVersion() {
return String.format(Locale.US, "%.3f%05d", Float.valueOf(getVersion()), Integer.valueOf(getSVNRevision()));
}
/**
* returns the date, when this release was build
*/
public static String getBuildDate() {
if ("@REPL_DATE@".contains("@")) {
return "19700101";
}
return "@REPL_DATE@";
}
/**
* determines, if this release was compiled and installed
* by a package manager
*/
public static boolean isPkgManager() {
return "@REPL_PKGMANAGER@".equals("true");
}
/**
* returns command to use to restart the YaCy daemon,
* when YaCy was installed with a packagemanger
*/
public static String getRestartCmd() {
if ("@REPL_RESTARTCMD@".contains("@")) {
return "echo 'error'";
}
return "@REPL_RESTARTCMD@";
}
}
Loading…
Cancel
Save