update Maven build script

- use current YaCy version number
- make use of libbuild\GitRevMavenTask (maven-plugin-gitrevisionnumber)
- make yacyBuildProperties.java available for source filtering by Maven-plugin (copy to libbuild\java-templates)
- update assembly definition to include lib\yacycore.jar without version number (needed this way by startupscript)
pull/1/head
reger 11 years ago
parent 62c591ffd1
commit 9da87c0c7f

@ -73,6 +73,19 @@
<dependencySets>
<dependencySet>
<!-- adds the main yacycore.jar to the lib directory of zip package with defined name (yacycore.jar)
hint: the standard Maven output name (yacycore-version.jar) can not be used as the std. startup script uses a classpath lib\yacycore.jar -->
<useProjectArtifact>true</useProjectArtifact>
<includes>
<include>net.yacy:yacycore</include>
</includes>
<scope>runtime</scope>
<outputDirectory>lib</outputDirectory>
<outputFileNameMapping>${artifact.artifactId}.${artifact.extension}</outputFileNameMapping>
</dependencySet>
<dependencySet>
<useProjectArtifact>false</useProjectArtifact>
<unpack>false</unpack>
<scope>runtime</scope>
<outputDirectory>lib</outputDirectory>

@ -0,0 +1,78 @@
package net.yacy.peers.operation;
import java.util.Locale;
import java.util.regex.Pattern;
/**
* Attention: this is a template file (a 1:1 copy of net/yacy/peers/operation/yacyBuildProperties.java
* to produce a genrated source filtered by the Maven build to replace the placeholder variables (like "@REPL_REVISION_NR@")
* with current build values.
*
*/
/**
* 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@";
}
}

@ -4,7 +4,7 @@
<groupId>net.yacy</groupId>
<artifactId>yacycore</artifactId>
<version>1.64</version>
<version>1.65</version>
<packaging>jar</packaging>
<description>YaCy - a Peer to Peer Web Search Engine</description>
<name>YaCy</name>
@ -35,6 +35,15 @@
<maven.compiler.target>1.6</maven.compiler.target>
<!-- the Solr version used in dependency section for all related dependencies -->
<solr.version>4.5.0</solr.version>
<!-- properties used for filtering yacyBuildProperties.java -->
<REPL_DATE>${DSTAMP}</REPL_DATE>
<REPL_RELEASE>yacy_v${project.version}_${DSTAMP}_${releaseNr}.tar.gz</REPL_RELEASE>
<REPL_VERSION>${project.version}</REPL_VERSION>
<REPL_REVISION_NR>${releaseNr}</REPL_REVISION_NR>
<REPL_YACY_ROOT_DIR>.</REPL_YACY_ROOT_DIR>
<REPL_PKGMANAGER>false</REPL_PKGMANAGER>
<REPL_RESTARTCMD>/etc/init.d/yacy restart</REPL_RESTARTCMD>
</properties>
<build>
@ -58,6 +67,17 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<excludes>
<!-- special exclude for compatibility with ant build script
note: the ant build uses a tricky source filtering to filter yacyBuildProperties.java
for the Maven build the original source for filtering has been copied to
libbuild/java-templates
and for maven the files in libbuild/java-templates are used for filtering to produce generated-sources.
For the ant build script the yacyBuildProperties.java must be at it's origianl location,
thus it is excluded here to prevent Maven compile error "duplicate source"
-->
<exclude>**/net/yacy/peers/operation/yacyBuildProperties.java</exclude>
</excludes>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
@ -75,7 +95,7 @@
<addClasspath>true</addClasspath>
</manifest>
<manifestEntries>
<Implementation-Build>${project.version}-${buildNumber}</Implementation-Build>
<Implementation-Build>${project.version}-${releaseNr}</Implementation-Build>
</manifestEntries>
</archive>
</configuration>
@ -88,7 +108,7 @@
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
<finalName>yacy_v${project.version}_${buildNumber}</finalName>
<finalName>yacy_v${project.version}_${DSTAMP}_${releaseNr}</finalName>
<outputDirectory>RELEASE</outputDirectory>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
@ -143,70 +163,58 @@
</configuration>
</plugin>
<!-- custom plugin to add YaCy release number from local Git clone
sets property <releaseNr>9nnn</releasNr> <DSTAMP>yyyyMMdd</DSTAMP>
! run sub project in libbuild to install the plugin ! -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.2</version>
<groupId>net.yacy</groupId>
<artifactId>maven-plugin-gitrevisionnumber</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>1</id>
<!-- phase must be after phase initialize, as used property releaseNr only available after initialize -->
<phase>generate-sources</phase>
<phase>initialize</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<!-- optional parameter to set/change the propertyName
<configuration>
<doCheck>false</doCheck>
<doUpdate>false</doUpdate>
<shortRevisionLength>5</shortRevisionLength>
<revisionOnScmFailure>9000</revisionOnScmFailure>
<!-- creates a string e.g. 20130131-1fd45 -->
<format>{0,date,yyyyMMdd}_{1}</format>
<items>
<item>timestamp</item>
<item>${releaseNr}</item> <!-- custom releaseNr read as property from child project GitRevTask -->
<item>scmVersion</item> <!-- Git short version - from remote archive CURRENTLY NOT USED -->
</items>
<branchPropertyName>branch</branchPropertyName>
<buildNumberPropertyName>releasNr</buildNumberPropertyName>
<commitDatePropertyName>DSTAMP</commitDatePropertyName>
</configuration>
-->
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<groupId>org.codehaus.mojo</groupId>
<artifactId>templating-maven-plugin</artifactId>
<version>1.0-alpha-3</version>
<executions>
<execution>
<phase>generate-resources</phase>
<id>filter-src</id>
<goals>
<goal>build-classpath</goal>
<goal>filter-sources</goal>
</goals>
<configuration>
<!--attach>true</attach-->
<outputFilterFile>true</outputFilterFile>
<outputFile>${project.build.directory}/classpath.properties</outputFile>
<!--fileSeparator>\\\\</fileSeparator-->
<sourceDirectory>${basedir}/libbuild/java-templates</sourceDirectory>
<outputDirectory>${project.build.directory}/generated-sources</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<phase>initialize</phase>
<phase>generate-resources</phase>
<goals>
<goal>read-project-properties</goal>
<goal>build-classpath</goal>
</goals>
<configuration>
<files>
<file>libbuild/gitbuildnumber.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>

Loading…
Cancel
Save