JAL-3289 Ehancements to ARCHIVE building and script to show how to batch build and...
[jalview.git] / build.gradle
index 5c6a36c..2183543 100644 (file)
@@ -51,15 +51,17 @@ def compile_source_compatibility
 def compile_target_compatibility
 
 ext {
-
        getdownWebsiteDir = jalviewDir + '/' + getdown_website_dir + '/' + JAVA_VERSION
        getdownDir = ""
        reportRsyncCmd = false
-       switch (CHANNEL) {
+        buildDist = true
+        buildProperties = buildPropertiesFile
+        switch (CHANNEL) {
 
                case "BUILD":
                // TODO: get bamboo build artifact URL for getdown artifacts
                getdown_app_dir = getdown_app_dir_alt
+                buildProperties = jalviewDir + "/" + classesDir +"/" + buildPropertiesFile
                break
 
                case "RELEASE":
@@ -67,6 +69,7 @@ ext {
                getdownDir = getdown_channel_name + "/" + JAVA_VERSION
                getdown_app_base = getdown_channel_base + "/" + getdownDir
                getdown_app_dir = getdown_app_dir_release
+                buildProperties = jalviewDir + "/" + classesDir +"/" + buildPropertiesFile
                reportRsyncCommand = true
                break
 
@@ -75,6 +78,30 @@ ext {
                getdownDir = getdown_channel_name + "/" + JAVA_VERSION
                getdown_app_base = getdown_channel_base + "/" + getdownDir
                getdown_app_dir = getdown_app_dir_alt
+                if (!file(ARCHIVEDIR+"/"+packageDir).exists()) {
+                  print "Must provide an ARCHIVEDIR value to produce an archive distribution"
+                  exit
+                } else {
+                  packageDir = ARCHIVEDIR + "/" + packageDir
+                  buildProperties = ARCHIVEDIR +"/" + classesDir + "/" + buildPropertiesFile
+                  buildDist = false
+                }
+               reportRsyncCommand = true
+               break
+    
+               case "ARCHIVELOCAL":
+               getdown_channel_name = "archive" + "/" + JALVIEW_VERSION
+               getdownDir = getdown_channel_name + "/" + JAVA_VERSION
+               getdown_app_base = file(getdownWebsiteDir).toURI().toString()
+               getdown_app_dir = getdown_app_dir_alt
+                if (!file(ARCHIVEDIR+"/"+packageDir).exists()) {
+                  print "Must provide an ARCHIVEDIR value to produce an archive distribution"
+                  exit
+                } else {
+                  packageDir = ARCHIVEDIR + "/" + packageDir
+                  buildProperties = ARCHIVEDIR +"/" + classesDir + "/" + buildPropertiesFile
+                  buildDist = false
+                }
                reportRsyncCommand = true
                break
 
@@ -83,6 +110,7 @@ ext {
                getdownDir = getdown_channel_name + "/" + JAVA_VERSION
                getdown_app_base = getdown_channel_base + "/" + getdownDir
                getdown_app_dir = getdown_app_dir_alt
+                buildProperties = jalviewDir + "/" + classesDir +"/" + buildPropertiesFile
                reportRsyncCommand = true
                break
 
@@ -91,6 +119,7 @@ ext {
                getdownDir = getdown_channel_name + "/" + JAVA_VERSION
                getdown_app_base = getdown_channel_base + "/" + getdownDir
                getdown_app_dir = getdown_app_dir_alt
+                buildProperties = jalviewDir + "/" + classesDir +"/" + buildPropertiesFile
                reportRsyncCommand = true
                break
                
@@ -99,17 +128,19 @@ ext {
                getdownDir = getdown_channel_name + "/" + JAVA_VERSION
                getdown_app_base = getdown_channel_base + "/" + getdownDir
                getdown_app_dir = getdown_app_dir_alt
+                buildProperties = jalviewDir + "/" + classesDir +"/" + buildPropertiesFile
                reportRsyncCommand = true
                break
                
                case "LOCAL":
                getdown_app_base = file(getdownWebsiteDir).toURI().toString()
                getdown_app_dir = getdown_app_dir_alt
+                buildProperties = jalviewDir + "/" + classesDir +"/" + buildPropertiesFile
                break
                
                default: // something wrong specified
                print("CHANNEL must be one of BUILD, RELEASE, ARCHIVE, DEVELOP, TEST-RELEASE, SCRATCH-..., LOCAL [default]")
-               exit(1)
+               exit
                break
 
        }
@@ -526,7 +557,7 @@ task createBuildProperties(type: WriteProperties) {
        inputs.dir("$jalviewDir/$sourceDir")
        inputs.dir("$classes")
        inputs.dir("$jalviewDir/$resourceDir")
-       outputFile "$classes/$buildPropertiesFile"
+       outputFile (buildProperties)
        // taking time specific comment out to allow better incremental builds
        comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd HH:mm:ss")
        //comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd")
@@ -637,7 +668,9 @@ test {
                dependsOn cloverInstr
        }
 
-       print("Running tests " + (use_clover?"WITH":"WITHOUT") + " clover [clover="+use_clover+"]\n")
+        if (use_clover) {
+          print("Running tests " + (use_clover?"WITH":"WITHOUT") + " clover [clover="+use_clover+"]\n")
+        }
 
        useTestNG() {
                includeGroups testngGroups
@@ -764,20 +797,27 @@ task cleanDist {
 
 shadowJar {
        group = "distribution"
-       dependsOn makeDist
+        if (buildDist) {
+          dependsOn makeDist
+        }
        from ("$jalviewDir/$libDistDir") {
                include("*.jar")
        }
+       manifest {
+               attributes 'Implementation-Version': JALVIEW_VERSION
+       }
        mainClassName = shadowJarMainClass
        mergeServiceFiles()
-       classifier = "all-"+JAVA_VERSION
+       classifier = "all-"+JALVIEW_VERSION+"-j"+JAVA_VERSION
        minimize()
 }
 
 task getdownWebsite() {
        group = "distribution"
        description = "Create the getdown minimal app folder, and website folder for this version of jalview. Website folder also used for offline app installer"
-       dependsOn makeDist
+        if (buildDist) {
+          dependsOn makeDist
+        }
        def getdownWebsiteResourceFilenames = []
        def getdownTextString = ""
        def getdownResourceDir = project.ext.getdownResourceDir
@@ -786,7 +826,7 @@ task getdownWebsite() {
 
        doFirst {
                copy {
-                       from "$classes/$buildPropertiesFile"
+                       from buildProperties
                        rename(buildPropertiesFile, getdown_build_properties)
                        into project.ext.getdownWebsiteDir
                }
@@ -842,7 +882,7 @@ task getdownWebsite() {
                }
 
                def codeFiles = []
-               makeDist.outputs.files.each{ f ->
+               fileTree(file(packageDir)).each{ f ->
                        if (f.isDirectory()) {
                                def files = fileTree(dir: f, include: ["*"]).getFiles()
                                codeFiles += files
@@ -895,14 +935,21 @@ task getdownWebsite() {
                        from getdownLauncher
                        into project.ext.getdownWebsiteDir
                }
-               
-               copy {
-                       from getdown_txt
-                       from getdownLauncher
-                       from getdownWebsiteDir+"/"+getdown_build_properties
-                       into getdownInstallDir
-               }
-               
+                
+                if (! (CHANNEL.startsWith("ARCHIVE") || CHANNEL.startsWith("DEVELOP"))) {
+                  copy {
+                          from getdown_txt
+                          from getdownLauncher
+                          from getdownWebsiteDir+"/"+getdown_build_properties
+                          into getdownInstallDir
+                  }
+                  
+                  copy {
+                          from getdownInstallDir
+                          into getdownFilesInstallDir
+                  }
+                }
+       
                copy {
                        from getdown_txt
                        from launch_jvl
@@ -912,11 +959,6 @@ task getdownWebsite() {
                }
 
                copy {
-                       from getdownInstallDir
-                       into getdownFilesInstallDir
-               }
-               
-               copy {
                        from jalviewDir + '/' + project.getProperty('getdown_txt_ui.background_image')
                        from jalviewDir + '/' + project.getProperty('getdown_txt_ui.error_background')
                        from jalviewDir + '/' + project.getProperty('getdown_txt_ui.progress_image')
@@ -926,7 +968,9 @@ task getdownWebsite() {
                }
        }
 
-       inputs.dir(jalviewDir + '/' + packageDir)
+        if (buildDist) {
+          inputs.dir(jalviewDir + '/' + packageDir)
+        }
        outputs.dir(project.ext.getdownWebsiteDir)
        outputs.dir(project.ext.getdownFilesDir)
 }
@@ -949,8 +993,17 @@ task getdown() {
        doLast {
                if (reportRsyncCommand) {
                        def fromDir = getdownWebsiteDir + (getdownWebsiteDir.endsWith("/")?"":"/")
-                       def toDir = getdown_smb_mount + "/" + getdownDir + (getdownDir.endsWith("/")?"":"/")
-                       println "rsync -avh --delete '$fromDir' '$toDir'"
+                       def toDir = getdown_rsync_dest + "/" + getdownDir + (getdownDir.endsWith("/")?"":"/")
+                       println "LIKELY RSYNC COMMAND:"
+                        println "rsync -avh --delete '$fromDir' '$toDir'"
+                        if (RUNRSYNC == "true") {
+                          exec {
+                                  commandLine "mkdir", "-p", toDir
+                          }
+                          exec {
+                                  commandLine "rsync", "-avh", "--delete", fromDir, toDir
+                          }
+                        }
                }
        }
 }
@@ -1010,7 +1063,9 @@ task copyInstall4jTemplate(type: Copy) {
                        'INSTALL4JINFOPLISTFILEASSOCIATIONS': install4jInfoPlistFileAssociations,
                        'COPYRIGHT_MESSAGE': install4jCopyrightMessage,
                        'MACOS_BUNDLE_ID': install4jMacOSBundleId,
+                       'GETDOWN_RESOURCE_DIR': getdown_resource_dir,
                        'GETDOWN_DIST_DIR': getdown_app_dir,
+                       'GETDOWN_ALT_DIR': getdown_app_dir_alt,
                        'GETDOWN_INSTALL_DIR': getdown_install_dir
                ]
                )