2010-03-11 15:44:17 +01:00
|
|
|
{ stdenv
|
|
|
|
, name
|
|
|
|
, src
|
|
|
|
, doTest ? true
|
|
|
|
, doTestCompile ? true
|
|
|
|
, doJavadoc ? false
|
|
|
|
, doCheckstyle ? false
|
|
|
|
, doRelease ? false
|
|
|
|
, includeTestClasses ? true
|
2010-04-20 16:32:07 +02:00
|
|
|
, extraMvnFlags ? ""
|
2010-03-11 15:44:17 +01:00
|
|
|
, ...
|
|
|
|
} @ args :
|
|
|
|
|
2020-03-22 01:15:09 +01:00
|
|
|
let
|
2010-04-20 16:32:07 +02:00
|
|
|
mvnFlags = "-Dmaven.repo.local=$M2_REPO ${if doTest then "" else "-Dmaven.test.skip.exec=true"} ${extraMvnFlags}";
|
2010-03-11 15:44:17 +01:00
|
|
|
in
|
|
|
|
|
2019-08-13 23:52:01 +02:00
|
|
|
stdenv.mkDerivation ( {
|
2020-03-22 01:15:09 +01:00
|
|
|
inherit name src;
|
2010-08-18 11:55:34 +02:00
|
|
|
phases = "setupPhase unpackPhase patchPhase mvnCompile ${if doTestCompile then "mvnTestCompile mvnTestJar" else ""} ${if doTest then "mvnTest" else ""} ${if doJavadoc then "mvnJavadoc" else ""} ${if doCheckstyle then "mvnCheckstyle" else ""} mvnJar mvnAssembly mvnRelease finalPhase";
|
2010-03-11 15:44:17 +01:00
|
|
|
|
|
|
|
setupPhase = ''
|
|
|
|
runHook preSetupPhase
|
|
|
|
|
2012-01-18 21:16:00 +01:00
|
|
|
mkdir -p $out/nix-support
|
2010-03-11 15:44:17 +01:00
|
|
|
export LANG="en_US.UTF-8"
|
|
|
|
export LOCALE_ARCHIVE=$glibcLocales/lib/locale/locale-archive
|
|
|
|
export M2_REPO=$TMPDIR/repository
|
|
|
|
|
|
|
|
runHook postSetupPhase
|
|
|
|
'';
|
|
|
|
|
|
|
|
mvnCompile = ''
|
|
|
|
mvn compile ${mvnFlags}
|
2020-03-22 01:15:09 +01:00
|
|
|
'';
|
2010-03-11 15:44:17 +01:00
|
|
|
|
|
|
|
mvnTestCompile = ''
|
|
|
|
mvn test-compile ${mvnFlags}
|
2020-03-22 01:15:09 +01:00
|
|
|
'';
|
2010-03-11 15:44:17 +01:00
|
|
|
|
|
|
|
mvnTestJar = ''
|
|
|
|
mvn jar:test-jar ${mvnFlags}
|
2020-03-22 01:15:09 +01:00
|
|
|
'';
|
2010-03-11 15:44:17 +01:00
|
|
|
|
|
|
|
mvnTest = ''
|
|
|
|
mvn test ${mvnFlags}
|
2010-08-18 11:55:34 +02:00
|
|
|
|
|
|
|
if [ -d target/site/cobertura ] ; then
|
2010-09-09 09:19:12 +02:00
|
|
|
echo "report coverage $out/site/cobertura" >> $out/nix-support/hydra-build-products
|
2010-08-18 11:55:34 +02:00
|
|
|
fi
|
|
|
|
|
2010-08-18 13:48:35 +02:00
|
|
|
if [ -d target/surefire-reports ] ; then
|
2010-08-19 14:24:14 +02:00
|
|
|
mvn surefire-report:report-only
|
2010-09-09 09:19:12 +02:00
|
|
|
echo "report coverage $out/site/surefire-report.html" >> $out/nix-support/hydra-build-products
|
2010-08-18 11:55:34 +02:00
|
|
|
fi
|
2020-03-22 01:15:09 +01:00
|
|
|
'';
|
2010-03-11 15:44:17 +01:00
|
|
|
|
|
|
|
mvnJavadoc = ''
|
|
|
|
mvn javadoc:javadoc ${mvnFlags}
|
2010-09-09 09:19:12 +02:00
|
|
|
echo "report javadoc $out/site/apidocs" >> $out/nix-support/hydra-build-products
|
2020-03-22 01:15:09 +01:00
|
|
|
'';
|
2010-03-11 15:44:17 +01:00
|
|
|
|
|
|
|
mvnCheckstyle = ''
|
|
|
|
mvn checkstyle:checkstyle ${mvnFlags}
|
2010-09-09 09:19:12 +02:00
|
|
|
echo "report checkstyle $out/site/checkstyle.html" >> $out/nix-support/hydra-build-products
|
2020-03-22 01:15:09 +01:00
|
|
|
'';
|
2010-03-11 15:44:17 +01:00
|
|
|
|
|
|
|
mvnJar = ''
|
|
|
|
mvn jar:jar ${mvnFlags}
|
2020-03-22 01:15:09 +01:00
|
|
|
'';
|
2010-03-11 15:44:17 +01:00
|
|
|
|
|
|
|
mvnAssembly = ''
|
2014-05-07 16:37:38 +02:00
|
|
|
mvn assembly:assembly -Dmaven.test.skip=true ${mvnFlags}
|
2010-03-11 15:44:17 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
mvnRelease = ''
|
2012-01-18 21:16:00 +01:00
|
|
|
mkdir -p $out/release
|
2010-09-09 09:19:12 +02:00
|
|
|
|
2010-03-11 15:44:17 +01:00
|
|
|
zip=$(ls target/*.zip| head -1)
|
|
|
|
releaseName=$(basename $zip .zip)
|
2014-01-24 15:52:19 +01:00
|
|
|
releaseName="$releaseName-r${toString src.rev or "0"}"
|
2010-03-11 15:44:17 +01:00
|
|
|
cp $zip $out/release/$releaseName.zip
|
2020-03-22 01:15:09 +01:00
|
|
|
|
2010-03-11 15:44:17 +01:00
|
|
|
echo "$releaseName" > $out/nix-support/hydra-release-name
|
|
|
|
|
|
|
|
${if doRelease then ''
|
|
|
|
echo "file zip $out/release/$releaseName.zip" >> $out/nix-support/hydra-build-products
|
|
|
|
'' else ""}
|
2020-03-22 01:15:09 +01:00
|
|
|
'';
|
2010-03-11 15:44:17 +01:00
|
|
|
|
|
|
|
finalPhase = ''
|
2010-09-09 09:22:45 +02:00
|
|
|
if [ -d target/site ] ; then
|
|
|
|
cp -R target/site $out/
|
2010-09-09 12:47:54 +02:00
|
|
|
echo "report site $out/site" >> $out/nix-support/hydra-build-products
|
2010-09-09 09:22:45 +02:00
|
|
|
fi
|
2010-03-11 15:44:17 +01:00
|
|
|
'';
|
2020-03-22 01:15:09 +01:00
|
|
|
} // args
|
2010-03-11 15:44:17 +01:00
|
|
|
)
|