2010-03-11 14:44:17 +00:00
|
|
|
{ stdenv
|
|
|
|
, name
|
|
|
|
, src
|
|
|
|
, doTest ? true
|
|
|
|
, doTestCompile ? true
|
|
|
|
, doJavadoc ? false
|
|
|
|
, doCheckstyle ? false
|
|
|
|
, doRelease ? false
|
|
|
|
, includeTestClasses ? true
|
2010-04-20 15:32:07 +01:00
|
|
|
, extraMvnFlags ? ""
|
2010-03-11 14:44:17 +00:00
|
|
|
, ...
|
|
|
|
} @ args :
|
|
|
|
|
|
|
|
let
|
2010-04-20 15:32:07 +01:00
|
|
|
mvnFlags = "-Dmaven.repo.local=$M2_REPO ${if doTest then "" else "-Dmaven.test.skip.exec=true"} ${extraMvnFlags}";
|
2010-03-11 14:44:17 +00:00
|
|
|
in
|
|
|
|
|
|
|
|
stdenv.mkDerivation ( rec {
|
|
|
|
inherit name src;
|
2010-08-18 10:55:34 +01: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 14:44:17 +00:00
|
|
|
|
|
|
|
setupPhase = ''
|
|
|
|
runHook preSetupPhase
|
|
|
|
|
|
|
|
ensureDir $out/nix-support
|
|
|
|
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}
|
|
|
|
'';
|
|
|
|
|
|
|
|
mvnTestCompile = ''
|
|
|
|
mvn test-compile ${mvnFlags}
|
|
|
|
'';
|
|
|
|
|
|
|
|
mvnTestJar = ''
|
|
|
|
mvn jar:test-jar ${mvnFlags}
|
|
|
|
'';
|
|
|
|
|
|
|
|
mvnTest = ''
|
|
|
|
mvn test ${mvnFlags}
|
2010-08-18 10:55:34 +01:00
|
|
|
|
|
|
|
if [ -d target/site/cobertura ] ; then
|
|
|
|
cp -R target/site/cobertura $out/cobertura
|
2010-08-19 13:24:14 +01:00
|
|
|
echo "report coverage $out/cobertura" >> $out/nix-support/hydra-build-products
|
2010-08-18 10:55:34 +01:00
|
|
|
fi
|
|
|
|
|
2010-08-18 12:48:35 +01:00
|
|
|
if [ -d target/surefire-reports ] ; then
|
2010-08-19 13:24:14 +01:00
|
|
|
mvn surefire-report:report-only
|
|
|
|
cp -vR target/surefire-reports $out/surefire
|
|
|
|
cp -v target/site/surefire-report.html $out/surefire/index.html
|
|
|
|
echo "report coverage $out/surefire/index.html" >> $out/nix-support/hydra-build-products
|
2010-08-18 10:55:34 +01:00
|
|
|
fi
|
2010-03-11 14:44:17 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
mvnJavadoc = ''
|
|
|
|
mvn javadoc:javadoc ${mvnFlags}
|
|
|
|
cp -R target/site/apidocs $out/apidocs
|
|
|
|
echo "report javadoc $out/apidocs" >> $out/nix-support/hydra-build-products
|
|
|
|
'';
|
|
|
|
|
|
|
|
mvnCheckstyle = ''
|
|
|
|
mvn checkstyle:checkstyle ${mvnFlags}
|
|
|
|
ensureDir $out/checkstyle
|
|
|
|
cp -R target/site/checkstyle.* $out/checkstyle/
|
|
|
|
cp -R target/site/images $out/checkstyle/images
|
|
|
|
echo "report checkstyle $out/checkstyle/checkstyle.html" >> $out/nix-support/hydra-build-products
|
|
|
|
'';
|
|
|
|
|
|
|
|
mvnJar = ''
|
|
|
|
mvn jar:jar ${mvnFlags}
|
|
|
|
'';
|
|
|
|
|
|
|
|
mvnAssembly = ''
|
2010-08-19 14:36:57 +01:00
|
|
|
mvn assembly:single ${mvnFlags}
|
2010-03-11 14:44:17 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
mvnRelease = ''
|
|
|
|
ensureDir $out/release
|
|
|
|
ls -l target/
|
|
|
|
zip=$(ls target/*.zip| head -1)
|
|
|
|
releaseName=$(basename $zip .zip)
|
|
|
|
releaseName="$releaseName-r${toString src.rev}"
|
|
|
|
cp $zip $out/release/$releaseName.zip
|
|
|
|
|
|
|
|
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 ""}
|
|
|
|
'';
|
|
|
|
|
|
|
|
finalPhase = ''
|
|
|
|
ensureDir $out/site
|
|
|
|
cp -R src/test/site/* $out/site
|
|
|
|
'';
|
|
|
|
} // args
|
|
|
|
)
|