JAL-1929 JAL-3224 java 8 and java 11 specific getdown jre sets
[jalview.git] / build.gradle
index 45a757e..577d616 100644 (file)
@@ -28,33 +28,40 @@ mainClassName = launcherClass
 def cloverInstrDir = file("$buildDir/$cloverSourcesInstrDir")
 def classes = "$jalviewDir/$classesDir"
 if (clover.equals("true")) {
-  clover = true
+  use_clover = true
   classes = "$buildDir/$cloverClassesDir"
 } else {
-  clover = false
+  use_clover = false
   classes = "$jalviewDir/$classesDir"
 }
 
+// configure classpath/args for j8/j11 compilation
+
 def libDir
 def libDistDir
 def compile_source_compatibility
 def compile_target_compatibility
 def additional_compiler_args = []
+// these are getdown.txt properties defined dependent on the JAVA_VERSION 
 def getdown_alt_java_min_version
+// this property is assigned below and expanded to multiple lines in the getdown task
+def getdown_alt_multi_java_location
 if (JAVA_VERSION.equals("1.8")) {
   libDir = j11libDir
   libDistDir = j8libDir
   compile_source_compatibility = 1.8
   compile_target_compatibility = 1.8
   getdown_alt_java_min_version = getdown_alt_java8_min_version
+  getdown_alt_multi_java_location = getdown_alt_java8_txt_multi_java_location
 } else if (JAVA_VERSION.equals("11")) {
   libDir = j11libDir
   libDistDir = j11libDir
   compile_source_compatibility = 11
   compile_target_compatibility = 11
   getdown_alt_java_min_version = getdown_alt_java11_min_version
+  getdown_alt_multi_java_location = getdown_alt_java11_txt_multi_java_location
   additional_compiler_args += [
-    '--module-path', sourceSets.modules.compileClasspath.asPath,
+    '--module-path', file("$jalviewDir/$j11modDir").getAbsolutePath(),
     '--add-modules', j11modules
   ]
 } else {
@@ -71,7 +78,7 @@ sourceSets {
 
     resources {
       srcDirs "$jalviewDir/$resourceDir"
-      srcDirs "$jalviewDir/$libDir"
+      srcDirs "$jalviewDir/$libDistDir"
     }
 
     jar.destinationDir = file("$jalviewDir/$packageDir")
@@ -81,12 +88,6 @@ sourceSets {
 
     runtimeClasspath = compileClasspath
   }
-
-  modules {
-    compileClasspath = fileTree(dir: "$jalviewDir/$j11modDir", include: ["*.jar"])
-
-    runtimeClasspath = compileClasspath
-  }
   
   clover {
     java {
@@ -115,10 +116,11 @@ sourceSets {
     }
 
     compileClasspath = files( sourceSets.test.java.outputDir ) 
-    if (clover) {
+    if (use_clover) {
       compileClasspath += sourceSets.clover.compileClasspath
     } else {
       compileClasspath += sourceSets.main.compileClasspath
+      compileClasspath += files(sourceSets.main.java.outputDir)
     }
     compileClasspath += files( sourceSets.main.resources.srcDirs)
     compileClasspath += fileTree(dir: "$jalviewDir/$utilsDir", include: ["**/*.jar"])
@@ -130,7 +132,7 @@ sourceSets {
 
 // clover bits
 dependencies {
-  if (clover) {
+  if (use_clover) {
     cloverCompile 'org.openclover:clover:4.3.1'
     testCompile 'org.openclover:clover:4.3.1'
   }
@@ -194,9 +196,12 @@ compileJava {
 }
 
 compileTestJava {
-  if (clover) {
+
+  if (use_clover) {
     dependsOn compileCloverJava
     classpath += configurations.cloverRuntime
+  } else {
+    classpath += sourceSets.main.runtimeClasspath
   }
   doFirst {
     sourceCompatibility = compile_source_compatibility
@@ -296,8 +301,8 @@ task copyHelp(type: Copy) {
 }
 
 task syncLib(type: Sync) {
-  def syncDir = "$classes/$libDir"
-  from fileTree("$jalviewDir/$libDir")
+  def syncDir = "$classes/$libDistDir"
+  from fileTree("$jalviewDir/$libDistDir")
   into syncDir
 }
 
@@ -321,10 +326,11 @@ task prepare {
 //testReportDirName = "test-reports" // note that test workingDir will be $jalviewDir
 test {
   dependsOn prepare
-  if (clover) {
+  dependsOn compileJava
+  if (use_clover) {
     dependsOn cloverInstr
   }
-  print("Running tests " + (clover?"WITH":"WITHOUT") + " clover [clover="+clover+"]\n") 
+  print("Running tests " + (use_clover?"WITH":"WITHOUT") + " clover [clover="+use_clover+"]\n") 
   
   useTestNG() {
     includeGroups testngGroups
@@ -421,7 +427,7 @@ task copyJars(type: Copy) {
 
 // doing a Sync instead of Copy as Copy doesn't deal with "outputs" very well
 task syncJars(type: Sync) {
-  from fileTree("$jalviewDir/$libDir").include("**/*.jar").include("*.jar").files
+  from fileTree("$jalviewDir/$libDistDir").include("**/*.jar").include("*.jar").files
   into "$jalviewDir/$packageDir"
   preserve {
     include jar.archiveName
@@ -446,19 +452,19 @@ task cleanDist {
 
 shadowJar {
   dependsOn makeDist
-  if (JAVA_VERSION.equals("11")) {
-    from ("$jalviewDir/$j11libDir") {
+  from ("$jalviewDir/$libDistDir") {
       include("*.jar")
-    }
   }
   mainClassName = shadowJarMainClass
   mergeServiceFiles()
-  classifier = "all"
+  classifier = "all-"+JAVA_VERSION
   minimize()
 }
 
 ext {
-  getdownWebsiteDir = jalviewDir + '/' + getdown_website_dir
+  // where the getdown channel will be built. 
+  // TODO: consider allowing this expression to  be overrriden by -P arg
+  getdownWebsiteDir = jalviewDir + '/' + getdown_website_dir + '/' + JAVA_VERSION + '/'
   getdownAppDir = getdownWebsiteDir + '/' + getdown_app_dir
   getdownJ11libDir = getdownWebsiteDir + '/' + getdown_j11lib_dir
   getdownResourceDir = getdownWebsiteDir + '/' + getdown_resource_dir
@@ -469,7 +475,7 @@ ext {
   if (getdown_channel_name.equals("COMMIT")) {
     getdownChannel = getGitHash()
   }
-  getdown_app_base = getdown_channel_base+"/"+JAVA_VERSION+"/"+getdownChannel+"/"
+  getdown_app_base = getdown_channel_base+"/"+getdownChannel+"/"+JAVA_VERSION+"/"
 }
 
 task getdownWebsite() {
@@ -483,6 +489,8 @@ task getdownWebsite() {
     // go through properties looking for getdown_txt_...
     def props = project.properties.sort { it.key }
     props.put("getdown_txt_java_min_version", getdown_alt_java_min_version)
+    props.put("getdown_txt_multi_java_location", getdown_alt_multi_java_location)
+    
     props.put("getdown_txt_appbase", getdown_app_base)
     props.each{ prop, val ->
       if (prop.startsWith("getdown_txt_") && val != null) {
@@ -639,9 +647,11 @@ install4j {
 def install4jConf
 def macosJavaVMDir
 def windowsJavaVMDir
+def install4jDir = "$jalviewDir/$install4jResourceDir"
+def install4jConfFile = "jalview-installers-java"+JAVA_VERSION+".install4j"
+install4jConf = "$install4jDir/$install4jConfFile"
+  
 task copyInstall4jTemplate(type: Copy) {
-  def install4jDir = "$jalviewDir/$install4jResourceDir"
-  def install4jConfFile = "jalview-installers-java"+JAVA_VERSION+".install4j"
   macosJavaVMDir = System.env.HOME+"/buildtools/jre/openjdk-java_vm/macos-jre"+JAVA_VERSION+"/java_vm"
   windowsJavaVMDir = System.env.HOME+"/buildtools/jre/openjdk-java_vm/windows-jre"+JAVA_VERSION+"/java_vm"
   from (install4jDir) {
@@ -651,7 +661,6 @@ task copyInstall4jTemplate(type: Copy) {
     filter(ReplaceTokens, beginToken: '$$', endToken: '$$', tokens: ['VERSION': JALVIEW_VERSION, 'MACOS_JAVA_VM_DIR': macosJavaVMDir, 'WINDOWS_JAVA_VM_DIR': windowsJavaVMDir])
   }
   into install4jDir
-  install4jConf = "$install4jDir/$install4jConfFile"
   inputs.files("$install4jDir/$install4jTemplate")
   outputs.files(install4jConf)
 }
@@ -659,15 +668,16 @@ task copyInstall4jTemplate(type: Copy) {
 task installers(type: com.install4j.gradle.Install4jTask) {
   dependsOn getdown
   dependsOn copyInstall4jTemplate
-  projectFile = install4jConf
+  projectFile = file(install4jConf)
+  println("Using projectFile "+projectFile)
   variables = [majorVersion: version.substring(2, 11), build: 001]
-  destination = "$jalviewDir/$install4jBuildDir"
+  destination = "$jalviewDir/$install4jBuildDir/$JAVA_VERSION"
   buildSelected = true
   inputs.dir(project.ext.getdownWebsiteDir)
   inputs.file(install4jConf)
   inputs.dir(macosJavaVMDir)
   inputs.dir(windowsJavaVMDir)
-  outputs.dir("$jalviewDir/$install4jBuildDir")
+  outputs.dir("$jalviewDir/$install4jBuildDir/$JAVA_VERSION")
 }
 
 clean {