1 /* Convention for properties. Read from gradle.properties, use lower_case_underlines for property names.
2 * For properties set within build.gradle, use camelCaseNoSpace.
4 import org.apache.tools.ant.filters.ReplaceTokens
15 // in ext the values are cast to Object. Ensure string values are cast as String (and not GStringImpl) for later use
16 def string(Object o) {
17 return o == null ? "" : o.toString()
22 jalviewDirAbsolutePath = file(jalviewDir).getAbsolutePath()
23 jalviewDirRelativePath = jalviewDir
27 // Import releaseProps from the RELEASE file
28 // or a file specified via JALVIEW_RELEASE_FILE if defined
29 // Expect jalview.version and target release branch in jalview.release
30 def releaseProps = new Properties();
31 def releasePropFile = findProperty("JALVIEW_RELEASE_FILE");
32 def defaultReleasePropFile = "${jalviewDirAbsolutePath}/RELEASE";
34 (new File(releasePropFile!=null ? releasePropFile : defaultReleasePropFile)).withInputStream {
37 } catch (Exception fileLoadError) {
38 throw new Error("Couldn't load release properties file "+(releasePropFile==null ? defaultReleasePropFile : "from custom location: releasePropFile"),fileLoadError);
41 // Set JALVIEW_VERSION if it is not already set
42 if (findProperty("JALVIEW_VERSION")==null || "".equals(JALVIEW_VERSION)) {
43 JALVIEW_VERSION = releaseProps.get("jalview.version")
48 bareSourceDir = string(source_dir)
49 sourceDir = string("${jalviewDir}/${bareSourceDir}")
50 resourceDir = string("${jalviewDir}/${resource_dir}")
51 bareTestSourceDir = string(test_source_dir)
52 testDir = string("${jalviewDir}/${bareTestSourceDir}")
54 classesDir = string("${jalviewDir}/${classes_dir}")
57 resourceClassesDir = classesDir
59 testSourceDir = testDir
60 testClassesDir = "${jalviewDir}/${test_output_dir}"
62 buildProperties = string("${classesDir}/${build_properties_file}")
64 gitBranch = string("")
66 println("Using a ${CHANNEL} profile.")
68 additional_compiler_args = []
69 // configure classpath/args for j8/j11 compilation
70 if (JAVA_VERSION.equals("1.8")) {
71 JAVA_INTEGER_VERSION = string("8")
75 compile_source_compatibility = 1.8
76 compile_target_compatibility = 1.8
77 } else if (JAVA_VERSION.equals("11")) {
78 JAVA_INTEGER_VERSION = string("11")
80 libDistDir = j11libDir
81 compile_source_compatibility = 11
82 compile_target_compatibility = 11
83 } else if (JAVA_VERSION.equals("12") || JAVA_VERSION.equals("13")) {
84 JAVA_INTEGER_VERSION = JAVA_VERSION
86 libDistDir = j11libDir
87 compile_source_compatibility = JAVA_VERSION
88 compile_target_compatibility = JAVA_VERSION
90 throw new GradleException("JAVA_VERSION=${JAVA_VERSION} not currently supported by Jalview")
96 buildingHTML = string("${jalviewDir}/${doc_dir}/building.html")
97 helpFile = string("${resourceClassesDir}/${help_dir}/help.jhm")
98 helpParentDir = string("${jalviewDir}/${help_parent_dir}")
99 helpSourceDir = string("${helpParentDir}/${help_dir}")
110 outputDir = file(classesDir)
115 srcDirs += helpParentDir
118 jar.destinationDir = file("${jalviewDir}/${package_dir}")
120 compileClasspath = files(sourceSets.main.java.outputDir)
121 compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
123 runtimeClasspath = compileClasspath
128 srcDirs testSourceDir
129 outputDir = file(testClassesDir)
133 srcDirs = sourceSets.main.resources.srcDirs
136 compileClasspath = files( sourceSets.test.java.outputDir )
137 compileClasspath += sourceSets.main.compileClasspath
138 compileClasspath += fileTree(dir: "${jalviewDir}/${utils_dir}/testnglibs", include: ["**/*.jar"])
140 runtimeClasspath = compileClasspath
151 sourceCompatibility = compile_source_compatibility
152 targetCompatibility = compile_target_compatibility
153 options.compilerArgs = additional_compiler_args
154 print ("Setting target compatibility to "+targetCompatibility+"\n")
162 sourceCompatibility = compile_source_compatibility
163 targetCompatibility = compile_target_compatibility
164 options.compilerArgs = additional_compiler_args
165 print ("Setting target compatibility to "+targetCompatibility+"\n")
172 delete sourceSets.main.java.outputDir
179 delete sourceSets.test.java.outputDir
184 // format is a string like date.format("dd MMMM yyyy")
185 def getDate(format) {
186 def date = new Date()
187 return date.format(format)
192 def hashStdOut = new ByteArrayOutputStream()
194 commandLine "git", "rev-parse", "--short", "HEAD"
195 standardOutput = hashStdOut
199 def branchStdOut = new ByteArrayOutputStream()
201 commandLine "git", "rev-parse", "--abbrev-ref", "HEAD"
202 standardOutput = branchStdOut
206 gitHash = hashStdOut.toString().trim()
207 gitBranch = branchStdOut.toString().trim()
209 outputs.upToDateWhen { false }
213 task createBuildProperties(type: WriteProperties) {
215 inputs.dir(sourceDir)
216 inputs.dir(resourceDir)
217 file(buildProperties).getParentFile().mkdirs()
218 outputFile (buildProperties)
219 // taking time specific comment out to allow better incremental builds
220 comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd HH:mm:ss")
221 //comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd")
222 property "BUILD_DATE", getDate("HH:mm:ss dd MMMM yyyy")
223 property "VERSION", JALVIEW_VERSION
224 property "INSTALLATION", INSTALLATION+" git-commit:"+gitHash+" ["+gitBranch+"]"
225 outputs.file(outputFile)
229 task cleanBuildingHTML(type: Delete) {
236 task convertBuildingMD(type: Exec) {
237 dependsOn cleanBuildingHTML
238 def buildingMD = "${jalviewDir}/${doc_dir}/building.md"
239 def css = "${jalviewDir}/${doc_dir}/github.css"
242 pandoc_exec.split(",").each {
243 if (file(it.trim()).exists()) {
249 def hostname = "hostname".execute().text.trim()
250 def buildtoolsPandoc = System.getProperty("user.home")+"/buildtools/pandoc/bin/pandoc"
251 if ((pandoc == null || ! file(pandoc).exists()) && file(buildtoolsPandoc).exists()) {
252 pandoc = System.getProperty("user.home")+"/buildtools/pandoc/bin/pandoc"
256 if (pandoc != null && file(pandoc).exists()) {
257 commandLine pandoc, '-s', '-o', buildingHTML, '--metadata', 'pagetitle="Building Jalview from Source"', '--toc', '-H', css, buildingMD
259 println("Cannot find pandoc. Skipping convert building.md to HTML")
260 throw new StopExecutionException("Cannot find pandoc. Skipping convert building.md to HTML")
266 inputs.file(buildingMD)
268 outputs.file(buildingHTML)
279 task syncDocs(type: Sync) {
280 dependsOn convertBuildingMD
281 def syncDir = "${resourceClassesDir}/${doc_dir}"
282 from fileTree("${jalviewDir}/${doc_dir}")
288 task copyHelp(type: Copy) {
289 def inputDir = helpSourceDir
290 def outputDir = "${resourceClassesDir}/${help_dir}"
295 filter(ReplaceTokens,
299 'Version-Rel': JALVIEW_VERSION,
300 'Year-Rel': getDate("yyyy")
312 outputs.files(helpFile)
313 outputs.dir(outputDir)
317 task syncResources(type: Sync) {
320 into "${resourceClassesDir}"
328 dependsOn syncResources
334 //testReportDirName = "test-reports" // note that test workingDir will be $jalviewDir
337 //dependsOn compileJava ////? DELETE
339 dependsOn compileJava //?
342 includeGroups testng_groups
343 excludeGroups testng_excluded_groups
345 useDefaultListeners=true
348 maxHeapSize = "1024m"
350 workingDir = jalviewDir
351 //systemProperties 'clover.jar' System.properties.clover.jar
352 def testLaf = project.findProperty("test_laf")
353 if (testLaf != null) {
354 println("Setting Test LaF to '${testLaf}'")
355 systemProperty "laf", testLaf
357 def testHiDPIScale = project.findProperty("test_HiDPIScale")
358 if (testHiDPIScale != null) {
359 println("Setting Test HiDPI Scale to '${testHiDPIScale}'")
360 systemProperty "sun.java2d.uiScale", testHiDPIScale
362 sourceCompatibility = compile_source_compatibility
363 targetCompatibility = compile_target_compatibility
364 jvmArgs += additional_compiler_args
371 task buildIndices(type: JavaExec) {
373 classpath = sourceSets.main.compileClasspath
374 main = "com.sun.java.help.search.Indexer"
375 workingDir = "${classesDir}/${help_dir}"
378 inputs.dir("${workingDir}/${argDir}")
380 outputs.dir("${classesDir}/doc")
381 outputs.dir("${classesDir}/help")
382 outputs.file("${workingDir}/JavaHelpSearch/DOCS")
383 outputs.file("${workingDir}/JavaHelpSearch/DOCS.TAB")
384 outputs.file("${workingDir}/JavaHelpSearch/OFFSETS")
385 outputs.file("${workingDir}/JavaHelpSearch/POSITIONS")
386 outputs.file("${workingDir}/JavaHelpSearch/SCHEMA")
387 outputs.file("${workingDir}/JavaHelpSearch/TMAP")
391 task compileLinkCheck(type: JavaCompile) {
393 classpath = files("${jalviewDir}/${utils_dir}")
394 destinationDir = file("${jalviewDir}/${utils_dir}")
395 source = fileTree(dir: "${jalviewDir}/${utils_dir}", include: ["HelpLinksChecker.java", "BufferedLineReader.java"])
397 inputs.file("${jalviewDir}/${utils_dir}/HelpLinksChecker.java")
398 inputs.file("${jalviewDir}/${utils_dir}/HelpLinksChecker.java")
399 outputs.file("${jalviewDir}/${utils_dir}/HelpLinksChecker.class")
400 outputs.file("${jalviewDir}/${utils_dir}/BufferedLineReader.class")
404 task linkCheck(type: JavaExec) {
405 dependsOn prepare, compileLinkCheck
407 def helpLinksCheckerOutFile = file("${jalviewDir}/${utils_dir}/HelpLinksChecker.out")
408 classpath = files("${jalviewDir}/${utils_dir}")
409 main = "HelpLinksChecker"
410 workingDir = jalviewDir
411 args = [ "${classesDir}/${help_dir}", "-nointernet" ]
413 def outFOS = new FileOutputStream(helpLinksCheckerOutFile, false) // false == don't append
415 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
418 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
422 inputs.dir("${classesDir}/${help_dir}")
423 outputs.file(helpLinksCheckerOutFile)
426 // import the pubhtmlhelp target
427 ant.properties.basedir = "${jalviewDir}"
428 ant.properties.helpBuildDir = "${jalviewDirAbsolutePath}/${classes_dir}/${help_dir}"
429 ant.importBuild "${utils_dir}/publishHelp.xml"
432 task cleanPackageDir(type: Delete) {
434 delete fileTree(dir: "${jalviewDir}/${package_dir}", include: "*.jar")
440 dependsOn buildIndices
441 dependsOn createBuildProperties
444 attributes "Main-Class": main_class,
445 "Permissions": "all-permissions",
446 "Application-Name": "Jalview Desktop",
447 "Codebase": application_codebase
450 destinationDir = file("${jalviewDir}/${package_dir}")
451 archiveName = rootProject.name+".jar"
459 inputs.dir(classesDir)
460 outputs.file("${jalviewDir}/${package_dir}/${archiveName}")