Author: Olivier Sallou
Last-Update: 2018-05-04 06:03:41 +0000
Description: Adapt build to Debian packaging needs
Forwarded: not-needed
--- a/build.gradle
+++ b/build.gradle
@@ -1,8 +1,5 @@
 plugins {
     id 'java'
-    id 'maven-publish'
-    id 'signing'
-    id 'com.palantir.git-version' version '0.5.2'
 }
 
 compileJava {
@@ -93,6 +90,7 @@
     }
     useTestNG {
     }
+    scanForTestClasses = false
     // propagate system properties to test JVM
     systemProperties = System.getProperties()
 
@@ -123,22 +121,32 @@
 //===================================================================
 
 final isRelease = project.hasProperty("release")
-version = (isRelease ? gitVersion() : gitVersion() + "-SNAPSHOT").replaceAll(".dirty", "")
+def getDebianVersion() {
+    def dpkgStdOut = new ByteArrayOutputStream()
+    exec {
+        commandLine "dpkg-parsechangelog", "-S", "Version"
+        standardOutput = dpkgStdOut
+    }
+    return dpkgStdOut.toString().trim().replaceFirst(/(-gradle)?([+]dfsg[.0-9]*)?-[^-]+$/, "")
+}
+
+version = getDebianVersion()
+// version = (isRelease ? gitVersion() : gitVersion() + "-SNAPSHOT").replaceAll(".dirty", "")
 
 jar {
-    archiveBaseName = "gkl"
+    baseName = "gkl"
     // include LICENSE file in jar
     from "LICENSE"
 }
 
 task javadocJar(type: Jar, dependsOn: javadoc) {
-    archiveClassifier = 'javadoc'
+    classifier = 'javadoc'
     from 'build/docs/javadoc'
 }
 
 task sourcesJar(type: Jar) {
     from sourceSets.main.allSource
-    archiveClassifier = 'sources'
+    classifier = 'sources'
 }
 
 artifacts {
@@ -146,87 +154,3 @@
     archives javadocJar
     archives sourcesJar
 }
-
-publishToMavenLocal.doFirst  { println "Version: $version" }
-
-publishing {
-    publications {
-
-        mavenJava(MavenPublication) {
-
-            groupId = 'com.intel.gkl'
-            artifactId = 'gkl'
-            from components.java
-
-            artifact sourcesJar
-            artifact javadocJar
-
-            pom {
-                name = 'Intel Genomics Kernel Library (GKL)'
-                description = 'Genomics compute kernels optimized for Intel Architecture'
-                url = 'https://github.com/Intel-HLS/GKL'
-                licenses {
-                    license {
-                        name = 'Apache License 2.0'
-                        url = 'https://opensource.org/license/apache-2-0'
-                    }
-                    license {
-                        name = 'MIT License'
-                        url = 'https://opensource.org/licenses/MIT'
-                    }
-                    license {
-                        name = 'BSD 3-Clause'
-                        url = 'https://opensource.org/licenses/BSD-3-Clause'
-                    }
-                    license {
-                        name = 'Zlib License'
-                        url = 'https://opensource.org/licenses/Zlib'
-                    }
-                }
-                developers {
-                    developer {
-                        name = "Venkata Kranthi Kumar Dhanala"
-                        email = "venkata.kranthi.kumar.dhanala@intel.com"
-                    }
-                    developer {
-                        name = "Urszula Golowicz"
-                        email = "urszula.golowicz@intel.com"
-                    }
-                    developer {
-                        name = "Mateusz S. Nowak"
-                        email = "mateusz.s.nowak@intel.com"
-                    }
-                    developer {
-                        name = "Priya Vaidya"
-                        email = "priya.n.vaidya@intel.com"
-                    }
-                }
-                scm {
-                    connection = 'scm:git@github.com:Intel-HLS/GKL.git'
-                    developerConnection = 'scm:git@github.com:Intel-HLS/GKL.git'
-                    url = 'scm:git@github.com:Intel-HLS/GKL.git'
-                }
-            }
-        }
-    }
-
-    repositories {
-        maven {
-            def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
-            def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
-            url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
-            credentials {
-                username = project.properties["sonatypeUsername"]
-                password = project.properties["sonatypePassword"]
-            }
-        }
-    }
-}
-
-signing {
-    sign publishing.publications.mavenJava
-}
-
-tasks.withType(Sign) {
-    onlyIf { !project.version.endsWith('SNAPSHOT') }
-}
