Skip to content
Commits on Source (4)
......@@ -6,6 +6,7 @@
package Debian::Debhelper::Buildsystem::gradle;
use strict;
use Debian::Debhelper::Dh_Lib;
use Dpkg::Control;
use base 'Debian::Debhelper::Buildsystem';
......@@ -53,20 +54,24 @@ sub new {
sub build {
my $this=shift;
# Copy the init script under .gradle/init.d to work around a bug with the --init-script parameter (GRADLE-3197)
$this->doit_in_builddir("mkdir", "-p", ".gradle/init.d");
$this->doit_in_builddir("cp", "/usr/share/gradle-debian-helper/init.gradle", ".gradle/init.d/");
if (!@_) {
push(@_, "jar");
}
# Add the hook to the classpath
my $hookClasspath = "/usr/share/java/gradle-helper-hook.jar:/usr/share/java/maven-repo-helper.jar";
$ENV{JAVA_OPTS} .= " -Xbootclasspath/a:$hookClasspath";
$ENV{JAVA_OPTS} .= " -Dorg.gradle.jvmargs=-Xbootclasspath/a:$hookClasspath";
$this->doit_in_builddir(@{$this->{gradle_cmd}}, @_);
$this->_execute_gradle_task(@_);
}
sub test {
my $this=shift;
# Running tests automatically for debhelper compat levels > 12 only to prevent unexpected FTBFSes of old packages
return if compat(12, 1);
if (!@_) {
push(@_, "test");
}
$this->_execute_gradle_task(@_);
}
sub clean {
......@@ -77,4 +82,21 @@ sub clean {
$this->doit_in_builddir("rm", "-Rf", "$this->{cwd}/.gradle", "$this->{cwd}/buildSrc/.gradle", ".m2");
}
# Private methods
sub _execute_gradle_task {
my $this=shift;
# Copy the init script under .gradle/init.d to work around a bug with the --init-script parameter (GRADLE-3197)
$this->doit_in_builddir("mkdir", "-p", ".gradle/init.d");
$this->doit_in_builddir("cp", "/usr/share/gradle-debian-helper/init.gradle", ".gradle/init.d/");
# Add the hook to the classpath
my $hookClasspath = "/usr/share/java/gradle-helper-hook.jar:/usr/share/java/maven-repo-helper.jar";
$ENV{JAVA_OPTS} .= " -Xbootclasspath/a:$hookClasspath";
$ENV{JAVA_OPTS} .= " -Dorg.gradle.jvmargs=-Xbootclasspath/a:$hookClasspath";
$this->doit_in_builddir(@{$this->{gradle_cmd}}, @_);
}
1