JAL-3633 Memory only proxy auth password storage. Open Preferences->Connection tab...
[jalview.git] / build.gradle
index 48c83a3..d7382cb 100644 (file)
@@ -111,7 +111,7 @@ ext {
   }
   ////
   // Set JALVIEW_VERSION if it is not already set
-  if (findProperty(JALVIEW_VERSION)==null || "".equals(JALVIEW_VERSION)) {
+  if (findProperty("JALVIEW_VERSION")==null || "".equals(JALVIEW_VERSION)) {
     JALVIEW_VERSION = releaseProps.get("jalview.version")
   }
   
@@ -444,16 +444,16 @@ ext {
     install4jHomeDir = System.getProperty("user.home") + install4jHomeDir.substring(1)
   }
 
-  resourceBuildDir = string("${buildDir}/resource")
-  resourcesBuildDir = string("${resourceBuildDir}/resources")
-  helpBuildDir = string("${resourceBuildDir}/${help_dir}")
-  docBuildDir = string("${resourceBuildDir}/${doc_dir}")
+  resourceBuildDir = string("${buildDir}/resources")
+  resourcesBuildDir = string("${resourceBuildDir}/resources_build")
+  helpBuildDir = string("${resourceBuildDir}/help_build")
+  docBuildDir = string("${resourceBuildDir}/doc_build")
 
   buildProperties = string("${resourcesBuildDir}/${build_properties_file}")
   buildingHTML = string("${jalviewDir}/${doc_dir}/building.html")
   helpParentDir = string("${jalviewDir}/${help_parent_dir}")
   helpSourceDir = string("${helpParentDir}/${help_dir}")
-  helpFile = string("${helpBuildDir}/help.jhm")
+  helpFile = string("${helpBuildDir}/${help_dir}/help.jhm")
 
 
   relativeBuildDir = file(jalviewDirAbsolutePath).toPath().relativize(buildDir.toPath())
@@ -491,13 +491,14 @@ sourceSets {
     }
 
     resources {
-      srcDirs resourcesBuildDir
+      srcDirs = [ resourcesBuildDir, docBuildDir, helpBuildDir ]
     }
 
     compileClasspath = files(sourceSets.main.java.outputDir)
     compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
 
     runtimeClasspath = compileClasspath
+    runtimeClasspath += files(sourceSets.main.resources.srcDirs)
   }
 
   clover {
@@ -534,6 +535,7 @@ sourceSets {
     compileClasspath += fileTree(dir: "${jalviewDir}/${utils_dir}/testnglibs", include: ["**/*.jar"])
 
     runtimeClasspath = compileClasspath
+    runtimeClasspath += files(sourceSets.test.resources.srcDirs)
   }
 
 }
@@ -1009,20 +1011,6 @@ def getDate(format) {
 }
 
 
-clean {
-  doFirst {
-    delete buildProperties
-  }
-}
-
-
-task cleanBuildingHTML(type: Delete) {
-  doFirst {
-    delete buildingHTML
-  }
-}
-
-
 def convertMdToHtml (FileTree mdFiles, File cssFile) {
   MutableDataSet options = new MutableDataSet()
 
@@ -1096,14 +1084,45 @@ def convertMdToHtml (FileTree mdFiles, File cssFile) {
 
     def htmlFilePath = mdFile.getPath().replaceAll(/\..*?$/, ".html")
     def htmlFile = file(htmlFilePath)
+    println("Creating ${htmlFilePath}")
     htmlFile.text = htmlText
   }
 }
 
 
+task copyDocs(type: Copy) {
+  def inputDir = "${jalviewDir}/${doc_dir}"
+  def outputDir = "${docBuildDir}/${doc_dir}"
+  from(inputDir) {
+    include('**/*.txt')
+    include('**/*.md')
+    include('**/*.html')
+    include('**/*.xml')
+    filter(ReplaceTokens,
+      beginToken: '$$',
+      endToken: '$$',
+      tokens: [
+        'Version-Rel': JALVIEW_VERSION,
+        'Year-Rel': getDate("yyyy")
+      ]
+    )
+  }
+  from(inputDir) {
+    exclude('**/*.txt')
+    exclude('**/*.md')
+    exclude('**/*.html')
+    exclude('**/*.xml')
+  }
+  into outputDir
+
+  inputs.dir(inputDir)
+  outputs.dir(outputDir)
+}
+
+
 task convertMdFiles {
-  dependsOn cleanBuildingHTML
-  def mdFiles = fileTree(dir: "${jalviewDir}/${doc_dir}", include: "*.md")
+  dependsOn copyDocs
+  def mdFiles = fileTree(dir: docBuildDir, include: "**/*.md")
   def cssFile = file("${jalviewDir}/${flexmark_css}")
 
   doLast {
@@ -1122,33 +1141,16 @@ task convertMdFiles {
 }
 
 
-task copyDocs(type: Copy) {
-  dependsOn convertMdFiles
-  def syncDir = "${docBuildDir}"
-  from ("${jalviewDir}/${doc_dir}") {
-    exclude '**/*.gif'
-    exclude '**/*.jpg'
-    exclude '**/*.png'
-    filter(ReplaceTokens,
-      beginToken: '$$',
-      endToken: '$$',
-      tokens: [
-        'Version-Rel': JALVIEW_VERSION,
-        'Year-Rel': getDate("yyyy")
-      ]
-    )
-  }
-  into syncDir
-}
-
-
 task copyHelp(type: Copy) {
   def inputDir = helpSourceDir
-  def outputDir = "${helpBuildDir}"
+  def outputDir = "${helpBuildDir}/${help_dir}"
   from(inputDir) {
-    exclude '**/*.gif'
-    exclude '**/*.jpg'
-    exclude '**/*.png'
+    include('**/*.txt')
+    include('**/*.md')
+    include('**/*.html')
+    include('**/*.hs')
+    include('**/*.xml')
+    include('**/*.jhm')
     filter(ReplaceTokens,
       beginToken: '$$',
       endToken: '$$',
@@ -1159,9 +1161,12 @@ task copyHelp(type: Copy) {
     )
   }
   from(inputDir) {
-    include '**/*.gif'
-    include '**/*.jpg'
-    include '**/*.png'
+    exclude('**/*.txt')
+    exclude('**/*.md')
+    exclude('**/*.html')
+    exclude('**/*.hs')
+    exclude('**/*.xml')
+    exclude('**/*.jhm')
   }
   into outputDir
 
@@ -1172,7 +1177,13 @@ task copyHelp(type: Copy) {
 
 
 task copyResources(type: Copy) {
-  from(resourceDir) {
+  def inputDir = resourceDir
+  def outputDir = resourcesBuildDir
+  from(inputDir) {
+    include('**/*.txt')
+    include('**/*.md')
+    include('**/*.html')
+    include('**/*.xml')
     filter(ReplaceTokens,
       beginToken: '$$',
       endToken: '$$',
@@ -1182,11 +1193,16 @@ task copyResources(type: Copy) {
       ]
     )
   }
-  include "**/*.*"
-  into "${resourcesBuildDir}"
-  //preserve {
-  //  include "**"
-  //}
+  from(inputDir) {
+    exclude('**/*.txt')
+    exclude('**/*.md')
+    exclude('**/*.html')
+    exclude('**/*.xml')
+  }
+  into outputDir
+
+  inputs.dir(inputDir)
+  outputs.dir(outputDir)
 }
 
 
@@ -1197,10 +1213,6 @@ task createBuildProperties(type: WriteProperties) {
   
   inputs.dir(sourceDir)
   inputs.dir(resourcesBuildDir)
-//println("MKDIRS "+file(buildProperties).getParentFile().toString())
-//  doFirst {
-//    file(buildProperties).getParentFile().mkdirs()
-//  }
   outputFile (buildProperties)
   // taking time specific comment out to allow better incremental builds
   comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd HH:mm:ss")
@@ -1212,23 +1224,49 @@ task createBuildProperties(type: WriteProperties) {
 }
 
 
+task buildIndices(type: JavaExec) {
+  dependsOn copyHelp
+  classpath = sourceSets.main.compileClasspath
+  main = "com.sun.java.help.search.Indexer"
+  workingDir = "${helpBuildDir}/${help_dir}"
+  def argDir = "html"
+  args = [ argDir ]
+  inputs.dir("${workingDir}/${argDir}")
+
+  outputs.dir("${classesDir}/doc")
+  outputs.dir("${classesDir}/help")
+  outputs.file("${workingDir}/JavaHelpSearch/DOCS")
+  outputs.file("${workingDir}/JavaHelpSearch/DOCS.TAB")
+  outputs.file("${workingDir}/JavaHelpSearch/OFFSETS")
+  outputs.file("${workingDir}/JavaHelpSearch/POSITIONS")
+  outputs.file("${workingDir}/JavaHelpSearch/SCHEMA")
+  outputs.file("${workingDir}/JavaHelpSearch/TMAP")
+}
+
+
 task prepare {
   dependsOn copyResources
   dependsOn copyDocs
   dependsOn copyHelp
+  dependsOn createBuildProperties
+  dependsOn convertMdFiles
+  dependsOn buildIndices
 }
-jar.dependsOn prepare
+
+
+compileJava.dependsOn prepare
+run.dependsOn compileJava
+//run.dependsOn prepare
 
 
 //testReportDirName = "test-reports" // note that test workingDir will be $jalviewDir
 test {
   dependsOn prepare
-  //dependsOn compileJava ////? DELETE
 
   if (useClover) {
     dependsOn cloverClasses
    } else { //?
-     dependsOn compileJava //?
+    dependsOn compileJava //?
   }
 
   useTestNG() {
@@ -1241,12 +1279,16 @@ test {
   maxHeapSize = "1024m"
 
   workingDir = jalviewDir
-  //systemProperties 'clover.jar' System.properties.clover.jar
   def testLaf = project.findProperty("test_laf")
   if (testLaf != null) {
     println("Setting Test LaF to '${testLaf}'")
     systemProperty "laf", testLaf
   }
+  def testHiDPIScale = project.findProperty("test_HiDPIScale")
+  if (testHiDPIScale != null) {
+    println("Setting Test HiDPI Scale to '${testHiDPIScale}'")
+    systemProperty "sun.java2d.uiScale", testHiDPIScale
+  }
   sourceCompatibility = compile_source_compatibility
   targetCompatibility = compile_target_compatibility
   jvmArgs += additional_compiler_args
@@ -1259,26 +1301,6 @@ test {
 }
 
 
-task buildIndices(type: JavaExec) {
-  dependsOn copyHelp
-  classpath = sourceSets.main.compileClasspath
-  main = "com.sun.java.help.search.Indexer"
-  workingDir = "${helpBuildDir}"
-  def argDir = "html"
-  args = [ argDir ]
-  inputs.dir("${workingDir}/${argDir}")
-
-  outputs.dir("${classesDir}/doc")
-  outputs.dir("${classesDir}/help")
-  outputs.file("${workingDir}/JavaHelpSearch/DOCS")
-  outputs.file("${workingDir}/JavaHelpSearch/DOCS.TAB")
-  outputs.file("${workingDir}/JavaHelpSearch/OFFSETS")
-  outputs.file("${workingDir}/JavaHelpSearch/POSITIONS")
-  outputs.file("${workingDir}/JavaHelpSearch/SCHEMA")
-  outputs.file("${workingDir}/JavaHelpSearch/TMAP")
-}
-
-
 task compileLinkCheck(type: JavaCompile) {
   options.fork = true
   classpath = files("${jalviewDir}/${utils_dir}")
@@ -1293,14 +1315,14 @@ task compileLinkCheck(type: JavaCompile) {
 
 
 task linkCheck(type: JavaExec) {
-  dependsOn prepare, compileLinkCheck
+  dependsOn prepare
+  dependsOn compileLinkCheck
 
   def helpLinksCheckerOutFile = file("${jalviewDir}/${utils_dir}/HelpLinksChecker.out")
   classpath = files("${jalviewDir}/${utils_dir}")
   main = "HelpLinksChecker"
   workingDir = jalviewDir
-  def helpBuildDir = "${helpBuildDir}"
-  args = [ helpBuildDir, "-nointernet" ]
+  args = [ "${helpBuildDir}/${help_dir}", "-nointernet" ]
 
   def outFOS = new FileOutputStream(helpLinksCheckerOutFile, false) // false == don't append
   def errFOS = outFOS
@@ -1315,9 +1337,10 @@ task linkCheck(type: JavaExec) {
   outputs.file(helpLinksCheckerOutFile)
 }
 
+
 // import the pubhtmlhelp target
 ant.properties.basedir = "${jalviewDir}"
-ant.properties.helpBuildDir = "${jalviewDirAbsolutePath}/${helpBuildDir}"
+ant.properties.helpBuildDir = "${helpBuildDir}/${help_dir}"
 ant.importBuild "${utils_dir}/publishHelp.xml"
 
 
@@ -1329,9 +1352,8 @@ task cleanPackageDir(type: Delete) {
 
 
 jar {
+  dependsOn prepare
   dependsOn linkCheck
-  dependsOn buildIndices
-  dependsOn createBuildProperties
 
   manifest {
     attributes "Main-Class": main_class,
@@ -1350,8 +1372,11 @@ jar {
   exclude "**/*.jar"
   exclude "**/*.jar.*"
 
-  inputs.dir(classesDir)
-  outputs.file("${jalviewDir}/${package_dir}/${archiveFileName}")
+  inputs.dir(sourceSets.main.java.outputDir)
+  sourceSets.main.resources.srcDirs.each{ dir ->
+    inputs.dir(dir)
+  }
+  outputs.file("${destinationDirectory}/${archiveFileName}")
 }
 
 
@@ -1391,6 +1416,7 @@ task cleanDist {
   dependsOn clean
 }
 
+
 shadowJar {
   group = "distribution"
   description = "Create a single jar file with all dependency libraries merged. Can be run with java -jar"
@@ -1965,7 +1991,7 @@ task helppages {
   dependsOn copyHelp
   dependsOn pubhtmlhelp
   
-  inputs.dir("${helpBuildDir}")
+  inputs.dir("${helpBuildDir}/${help_dir}")
   outputs.dir("${buildDir}/distributions/${help_dir}")
 }