/* Convention for properties. Read from gradle.properties, use lower_case_underlines for property names. * For properties set within build.gradle, use camelCaseNoSpace. */ import org.apache.tools.ant.filters.ReplaceTokens plugins { id 'java' } // in ext the values are cast to Object. Ensure string values are cast as String (and not GStringImpl) for later use def string(Object o) { return o == null ? "" : o.toString() } ext { jalviewDirAbsolutePath = file(jalviewDir).getAbsolutePath() jalviewDirRelativePath = jalviewDir // local build environment properties // can be "projectDir/local.properties" def localProps = "${projectDir}/local.properties" def propsFile = null; if (file(localProps).exists()) { propsFile = localProps } // or "../projectDir_local.properties" def dirLocalProps = projectDir.getParent() + "/" + projectDir.getName() + "_local.properties" if (file(dirLocalProps).exists()) { propsFile = dirLocalProps } if (propsFile != null) { try { def p = new Properties() def localPropsFIS = new FileInputStream(propsFile) p.load(localPropsFIS) localPropsFIS.close() p.each { key, val -> def oldval = findProperty(key) setProperty(key, val) if (oldval != null) { println("Overriding property '${key}' ('${oldval}') with ${file(propsFile).getName()} value '${val}'") } else { println("Setting unknown property '${key}' with ${file(propsFile).getName()}s value '${val}'") } } } catch (Exception e) { System.out.println("Exception reading local.properties") } } //// // Import releaseProps from the RELEASE file // or a file specified via JALVIEW_RELEASE_FILE if defined // Expect jalview.version and target release branch in jalview.release def releaseProps = new Properties(); def releasePropFile = findProperty("JALVIEW_RELEASE_FILE"); def defaultReleasePropFile = "${jalviewDirAbsolutePath}/RELEASE"; try { (new File(releasePropFile!=null ? releasePropFile : defaultReleasePropFile)).withInputStream { releaseProps.load(it) } } catch (Exception fileLoadError) { throw new Error("Couldn't load release properties file "+(releasePropFile==null ? defaultReleasePropFile : "from custom location: releasePropFile"),fileLoadError); } //// // Set JALVIEW_VERSION if it is not already set if (findProperty("JALVIEW_VERSION")==null || "".equals(JALVIEW_VERSION)) { JALVIEW_VERSION = releaseProps.get("jalview.version") } // this property set when running Eclipse headlessly j2sHeadlessBuildProperty = string("net.sf.j2s.core.headlessbuild") // this property set by Eclipse eclipseApplicationProperty = string("eclipse.application") // CHECK IF RUNNING FROM WITHIN ECLIPSE def eclipseApplicationPropertyVal = System.properties[eclipseApplicationProperty] IN_ECLIPSE = eclipseApplicationPropertyVal != null && eclipseApplicationPropertyVal.startsWith("org.eclipse.ui.") // BUT WITHOUT THE HEADLESS BUILD PROPERTY SET if (System.properties[j2sHeadlessBuildProperty].equals("true")) { println("Setting IN_ECLIPSE to ${IN_ECLIPSE} as System.properties['${j2sHeadlessBuildProperty}'] == '${System.properties[j2sHeadlessBuildProperty]}'") IN_ECLIPSE = false } if (IN_ECLIPSE) { println("WITHIN ECLIPSE IDE") } else { println("HEADLESS BUILD") } /* *-/ System.properties.sort { it.key }.each { key, val -> println("SYSTEM PROPERTY ${key}='${val}'") } /-* *-/ if (false && IN_ECLIPSE) { jalviewDir = jalviewDirAbsolutePath } */ // essentials bareSourceDir = string(source_dir) sourceDir = string("${jalviewDir}/${bareSourceDir}") resourceDir = string("${jalviewDir}/${resource_dir}") bareTestSourceDir = string(test_source_dir) testDir = string("${jalviewDir}/${bareTestSourceDir}") classesDir = string("${jalviewDir}/${classes_dir}") // clover useClover = clover.equals("true") cloverBuildDir = "${buildDir}/clover" cloverInstrDir = file("${cloverBuildDir}/clover-instr") cloverClassesDir = file("${cloverBuildDir}/clover-classes") cloverReportDir = file("${buildDir}/reports/clover") cloverTestInstrDir = file("${cloverBuildDir}/clover-test-instr") cloverTestClassesDir = file("${cloverBuildDir}/clover-test-classes") //cloverTestClassesDir = cloverClassesDir cloverDb = string("${cloverBuildDir}/clover.db") resourceClassesDir = useClover ? cloverClassesDir : classesDir testSourceDir = useClover ? cloverTestInstrDir : testDir testClassesDir = useClover ? cloverTestClassesDir : "${jalviewDir}/${test_output_dir}" getdownWebsiteDir = string("${jalviewDir}/${getdown_website_dir}/${JAVA_VERSION}") buildDist = true // the following values might be overridden by the CHANNEL switch getdownChannelName = CHANNEL.toLowerCase() getdownDir = string("${getdownChannelName}/${JAVA_VERSION}") getdownAppBase = string("${getdown_channel_base}/${getdownDir}") getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher}") getdownAppDistDir = getdown_app_dir_alt buildProperties = string("${classesDir}/${build_properties_file}") reportRsyncCommand = false jvlChannelName = CHANNEL.toLowerCase() install4jSuffix = CHANNEL.substring(0, 1).toUpperCase() + CHANNEL.substring(1).toLowerCase(); // BUILD -> Build install4jDSStore = "DS_Store-NON-RELEASE" install4jDMGBackgroundImage = "jalview_dmg_background-NON-RELEASE.png" install4jInstallerName = "${jalview_name} Non-Release Installer" install4jExecutableName = jalview_name.replaceAll("[^\\w]+", "_").toLowerCase() install4jExtraScheme = "jalviewx" switch (CHANNEL) { case "BUILD": // TODO: get bamboo build artifact URL for getdown artifacts getdown_channel_base = bamboo_channelbase getdownChannelName = string("${bamboo_planKey}/${JAVA_VERSION}") getdownAppBase = string("${bamboo_channelbase}/${bamboo_planKey}${bamboo_getdown_channel_suffix}/${JAVA_VERSION}") jvlChannelName += "_${getdownChannelName}" // automatically add the test group Not-bamboo for exclusion if ("".equals(testng_excluded_groups)) { testng_excluded_groups = "Not-bamboo" } install4jExtraScheme = "jalviewb" break case "RELEASE": getdownAppDistDir = getdown_app_dir_release reportRsyncCommand = true install4jSuffix = "" install4jDSStore = "DS_Store" install4jDMGBackgroundImage = "jalview_dmg_background.png" install4jInstallerName = "${jalview_name} Installer" break case "ARCHIVE": getdownChannelName = CHANNEL.toLowerCase()+"/${JALVIEW_VERSION}" getdownDir = string("${getdownChannelName}/${JAVA_VERSION}") getdownAppBase = string("${getdown_channel_base}/${getdownDir}") if (!file("${ARCHIVEDIR}/${package_dir}").exists()) { throw new GradleException("Must provide an ARCHIVEDIR value to produce an archive distribution") } else { package_dir = string("${ARCHIVEDIR}/${package_dir}") buildProperties = string("${ARCHIVEDIR}/${classes_dir}/${build_properties_file}") buildDist = false } reportRsyncCommand = true install4jExtraScheme = "jalviewa" break case "ARCHIVELOCAL": getdownChannelName = string("archive/${JALVIEW_VERSION}") getdownDir = string("${getdownChannelName}/${JAVA_VERSION}") getdownAppBase = file(getdownWebsiteDir).toURI().toString() if (!file("${ARCHIVEDIR}/${package_dir}").exists()) { throw new GradleException("Must provide an ARCHIVEDIR value to produce an archive distribution") } else { package_dir = string("${ARCHIVEDIR}/${package_dir}") buildProperties = string("${ARCHIVEDIR}/${classes_dir}/${build_properties_file}") buildDist = false } reportRsyncCommand = true getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}") install4jSuffix = "Archive" install4jExtraScheme = "jalviewa" break case "DEVELOP": reportRsyncCommand = true // DEVELOP-RELEASE is usually associated with a Jalview release series so set the version JALVIEW_VERSION=JALVIEW_VERSION+"-develop" install4jSuffix = "Develop" install4jDSStore = "DS_Store-DEVELOP" install4jDMGBackgroundImage = "jalview_dmg_background-DEVELOP.png" install4jExtraScheme = "jalviewd" install4jInstallerName = "${jalview_name} Develop Installer" break case "TEST-RELEASE": reportRsyncCommand = true // TEST-RELEASE is usually associated with a Jalview release series so set the version JALVIEW_VERSION=JALVIEW_VERSION+"-test" install4jSuffix = "Test" install4jDSStore = "DS_Store-TEST-RELEASE" install4jDMGBackgroundImage = "jalview_dmg_background-TEST.png" install4jExtraScheme = "jalviewt" install4jInstallerName = "${jalview_name} Test Installer" break case ~/^SCRATCH(|-[-\w]*)$/: getdownChannelName = CHANNEL getdownDir = string("${getdownChannelName}/${JAVA_VERSION}") getdownAppBase = string("${getdown_channel_base}/${getdownDir}") reportRsyncCommand = true install4jSuffix = "Scratch" break case "TEST-LOCAL": if (!file("${LOCALDIR}").exists()) { throw new GradleException("Must provide a LOCALDIR value to produce a local distribution") } else { getdownAppBase = file(file("${LOCALDIR}").getAbsolutePath()).toURI().toString() getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}") } JALVIEW_VERSION = "TEST" install4jSuffix = "Test-Local" install4jDSStore = "DS_Store-TEST-RELEASE" install4jDMGBackgroundImage = "jalview_dmg_background-TEST.png" install4jExtraScheme = "jalviewt" install4jInstallerName = "${jalview_name} Test Installer" break case "LOCAL": getdownAppBase = file(getdownWebsiteDir).toURI().toString() getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}") install4jExtraScheme = "jalviewl" break default: // something wrong specified throw new GradleException("CHANNEL must be one of BUILD, RELEASE, ARCHIVE, DEVELOP, TEST-RELEASE, SCRATCH-..., LOCAL [default]") break } // override getdownAppBase if requested if (findProperty("getdown_appbase_override") != null) { getdownAppBase = string(getProperty("getdown_appbase_override")) println("Overriding getdown appbase with '${getdownAppBase}'") } // sanitise file name for jalview launcher file for this channel jvlChannelName = jvlChannelName.replaceAll("[^\\w\\-]+", "_") // install4j application and folder names if (install4jSuffix == "") { install4jApplicationName = "${jalview_name}" install4jBundleId = "${install4j_bundle_id}" install4jWinApplicationId = install4j_release_win_application_id } else { install4jApplicationName = "${jalview_name} ${install4jSuffix}" install4jBundleId = "${install4j_bundle_id}-" + install4jSuffix.toLowerCase() // add int hash of install4jSuffix to the last part of the application_id def id = install4j_release_win_application_id def idsplitreverse = id.split("-").reverse() idsplitreverse[0] = idsplitreverse[0].toInteger() + install4jSuffix.hashCode() install4jWinApplicationId = idsplitreverse.reverse().join("-") } // sanitise folder and id names // install4jApplicationFolder = e.g. "Jalview Build" install4jApplicationFolder = install4jApplicationName .replaceAll("[\"'~:/\\\\\\s]", "_") // replace all awkward filename chars " ' ~ : / \ .replaceAll("_+", "_") // collapse __ install4jInternalId = install4jApplicationName .replaceAll(" ","_") .replaceAll("[^\\w\\-\\.]", "_") // replace other non [alphanumeric,_,-,.] .replaceAll("_+", "") // collapse __ //.replaceAll("_*-_*", "-") // collapse _-_ install4jUnixApplicationFolder = install4jApplicationName .replaceAll(" ","_") .replaceAll("[^\\w\\-\\.]", "_") // replace other non [alphanumeric,_,-,.] .replaceAll("_+", "_") // collapse __ .replaceAll("_*-_*", "-") // collapse _-_ .toLowerCase() getdownAppDir = string("${getdownWebsiteDir}/${getdownAppDistDir}") //getdownJ11libDir = "${getdownWebsiteDir}/${getdown_j11lib_dir}" getdownResourceDir = string("${getdownWebsiteDir}/${getdown_resource_dir}") getdownInstallDir = string("${getdownWebsiteDir}/${getdown_install_dir}") getdownFilesDir = string("${jalviewDir}/${getdown_files_dir}/${JAVA_VERSION}/") getdownFilesInstallDir = string("${getdownFilesDir}/${getdown_install_dir}") /* compile without modules -- using classpath libraries modules_compileClasspath = fileTree(dir: "${jalviewDir}/${j11modDir}", include: ["*.jar"]) modules_runtimeClasspath = modules_compileClasspath */ gitHash = string("") gitBranch = string("") println("Using a ${CHANNEL} profile.") additional_compiler_args = [] // configure classpath/args for j8/j11 compilation if (JAVA_VERSION.equals("1.8")) { JAVA_INTEGER_VERSION = string("8") //libDir = j8libDir libDir = j11libDir libDistDir = j8libDir digestonlyDir = j8digestonlyDir compile_source_compatibility = 1.8 compile_target_compatibility = 1.8 // these are getdown.txt properties defined dependent on the JAVA_VERSION getdownAltJavaMinVersion = string(findProperty("getdown_alt_java8_min_version")) getdownAltJavaMaxVersion = string(findProperty("getdown_alt_java8_max_version")) // this property is assigned below and expanded to multiple lines in the getdown task getdownAltMultiJavaLocation = string(findProperty("getdown_alt_java8_txt_multi_java_location")) // this property is for the Java library used in eclipse eclipseJavaRuntimeName = string("JavaSE-1.8") } else if (JAVA_VERSION.equals("11")) { JAVA_INTEGER_VERSION = string("11") libDir = j11libDir libDistDir = j11libDir digestonlyDir = j11digestonlyDir compile_source_compatibility = 11 compile_target_compatibility = 11 getdownAltJavaMinVersion = string(findProperty("getdown_alt_java11_min_version")) getdownAltJavaMaxVersion = string(findProperty("getdown_alt_java11_max_version")) getdownAltMultiJavaLocation = string(findProperty("getdown_alt_java11_txt_multi_java_location")) eclipseJavaRuntimeName = string("JavaSE-11") /* compile without modules -- using classpath libraries additional_compiler_args += [ '--module-path', modules_compileClasspath.asPath, '--add-modules', j11modules ] */ } else if (JAVA_VERSION.equals("12") || JAVA_VERSION.equals("13")) { JAVA_INTEGER_VERSION = JAVA_VERSION libDir = j11libDir libDistDir = j11libDir compile_source_compatibility = JAVA_VERSION compile_target_compatibility = JAVA_VERSION getdownAltJavaMinVersion = string(findProperty("getdown_alt_java11_min_version")) getdownAltJavaMaxVersion = string(findProperty("getdown_alt_java11_max_version")) getdownAltMultiJavaLocation = string(findProperty("getdown_alt_java11_txt_multi_java_location")) eclipseJavaRuntimeName = string("JavaSE-11") /* compile without modules -- using classpath libraries additional_compiler_args += [ '--module-path', modules_compileClasspath.asPath, '--add-modules', j11modules ] */ } else { throw new GradleException("JAVA_VERSION=${JAVA_VERSION} not currently supported by Jalview") } // for install4j JAVA_MIN_VERSION = JAVA_VERSION JAVA_MAX_VERSION = JAVA_VERSION def jreInstallsDir = string(jre_installs_dir) if (jreInstallsDir.startsWith("~/")) { jreInstallsDir = System.getProperty("user.home") + jreInstallsDir.substring(1) } macosJavaVMDir = string("${jreInstallsDir}/jre-${JAVA_INTEGER_VERSION}-mac-x64/jre") macosJavaVMTgz = string("${jreInstallsDir}/tgz/jre-${JAVA_INTEGER_VERSION}-mac-x64.tar.gz") windowsJavaVMDir = string("${jreInstallsDir}/jre-${JAVA_INTEGER_VERSION}-windows-x64/jre") windowsJavaVMTgz = string("${jreInstallsDir}/tgz/jre-${JAVA_INTEGER_VERSION}-windows-x64.tar.gz") linuxJavaVMDir = string("${jreInstallsDir}/jre-${JAVA_INTEGER_VERSION}-linux-x64/jre") linuxJavaVMTgz = string("${jreInstallsDir}/tgz/jre-${JAVA_INTEGER_VERSION}-linux-x64.tar.gz") install4jDir = string("${jalviewDir}/${install4j_utils_dir}") install4jConfFileName = string("jalview-install4j-conf.install4j") install4jConfFile = file("${install4jDir}/${install4jConfFileName}") install4jHomeDir = install4j_home_dir if (install4jHomeDir.startsWith("~/")) { install4jHomeDir = System.getProperty("user.home") + install4jHomeDir.substring(1) } buildingHTML = string("${jalviewDir}/${doc_dir}/building.html") helpFile = string("${resourceClassesDir}/${help_dir}/help.jhm") helpParentDir = string("${jalviewDir}/${help_parent_dir}") helpSourceDir = string("${helpParentDir}/${help_dir}") relativeBuildDir = file(jalviewDirAbsolutePath).toPath().relativize(buildDir.toPath()) jalviewjsBuildDir = string("${relativeBuildDir}/jalviewjs") jalviewjsSiteDir = string("${jalviewjsBuildDir}/${jalviewjs_site_dir}") if (IN_ECLIPSE) { jalviewjsTransferSiteJsDir = string(jalviewjsSiteDir) } else { jalviewjsTransferSiteJsDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_js") } jalviewjsTransferSiteLibDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_lib") jalviewjsTransferSiteSwingJsDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_swingjs") jalviewjsTransferSiteCoreDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_core") jalviewjsJalviewCoreHtmlFile = string("") jalviewjsJalviewCoreName = string(jalviewjs_core_name) jalviewjsCoreClasslists = [] jalviewjsJalviewTemplateName = string(jalviewjs_name) jalviewjsJ2sSettingsFileName = string("${jalviewDir}/${jalviewjs_j2s_settings}") jalviewjsJ2sProps = null eclipseWorkspace = null eclipseBinary = string("") eclipseVersion = string("") eclipseDebug = false // ENDEXT } sourceSets { main { java { srcDirs sourceDir outputDir = file(classesDir) } resources { srcDirs resourceDir srcDirs += helpParentDir } jar.destinationDir = file("${jalviewDir}/${package_dir}") compileClasspath = files(sourceSets.main.java.outputDir) compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"]) runtimeClasspath = compileClasspath } test { java { srcDirs testSourceDir outputDir = file(testClassesDir) } resources { srcDirs = sourceSets.main.resources.srcDirs } compileClasspath = files( sourceSets.test.java.outputDir ) compileClasspath += sourceSets.main.compileClasspath compileClasspath += fileTree(dir: "${jalviewDir}/${utils_dir}/testnglibs", include: ["**/*.jar"]) runtimeClasspath = compileClasspath } } compileJava { doFirst { sourceCompatibility = compile_source_compatibility targetCompatibility = compile_target_compatibility options.compilerArgs = additional_compiler_args print ("Setting target compatibility to "+targetCompatibility+"\n") } } compileTestJava { doFirst { sourceCompatibility = compile_source_compatibility targetCompatibility = compile_target_compatibility options.compilerArgs = additional_compiler_args print ("Setting target compatibility to "+targetCompatibility+"\n") } } clean { doFirst { delete sourceSets.main.java.outputDir } } cleanTest { doFirst { delete sourceSets.test.java.outputDir } } // format is a string like date.format("dd MMMM yyyy") def getDate(format) { def date = new Date() return date.format(format) } task setGitVals { def hashStdOut = new ByteArrayOutputStream() exec { commandLine "git", "rev-parse", "--short", "HEAD" standardOutput = hashStdOut ignoreExitValue true } def branchStdOut = new ByteArrayOutputStream() exec { commandLine "git", "rev-parse", "--abbrev-ref", "HEAD" standardOutput = branchStdOut ignoreExitValue true } gitHash = hashStdOut.toString().trim() gitBranch = branchStdOut.toString().trim() outputs.upToDateWhen { false } } task createBuildProperties(type: WriteProperties) { dependsOn setGitVals inputs.dir(sourceDir) inputs.dir(resourceDir) 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") //comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd") property "BUILD_DATE", getDate("HH:mm:ss dd MMMM yyyy") property "VERSION", JALVIEW_VERSION property "INSTALLATION", INSTALLATION+" git-commit:"+gitHash+" ["+gitBranch+"]" outputs.file(outputFile) } task cleanBuildingHTML(type: Delete) { doFirst { delete buildingHTML } } task convertBuildingMD(type: Exec) { dependsOn cleanBuildingHTML def buildingMD = "${jalviewDir}/${doc_dir}/building.md" def css = "${jalviewDir}/${doc_dir}/github.css" def pandoc = null pandoc_exec.split(",").each { if (file(it.trim()).exists()) { pandoc = it.trim() return true } } def hostname = "hostname".execute().text.trim() def buildtoolsPandoc = System.getProperty("user.home")+"/buildtools/pandoc/bin/pandoc" if ((pandoc == null || ! file(pandoc).exists()) && file(buildtoolsPandoc).exists()) { pandoc = System.getProperty("user.home")+"/buildtools/pandoc/bin/pandoc" } doFirst { if (pandoc != null && file(pandoc).exists()) { commandLine pandoc, '-s', '-o', buildingHTML, '--metadata', 'pagetitle="Building Jalview from Source"', '--toc', '-H', css, buildingMD } else { println("Cannot find pandoc. Skipping convert building.md to HTML") throw new StopExecutionException("Cannot find pandoc. Skipping convert building.md to HTML") } } ignoreExitValue true inputs.file(buildingMD) inputs.file(css) outputs.file(buildingHTML) } clean { doFirst { delete buildingHTML } } task syncDocs(type: Sync) { dependsOn convertBuildingMD def syncDir = "${resourceClassesDir}/${doc_dir}" from fileTree("${jalviewDir}/${doc_dir}") into syncDir } task copyHelp(type: Copy) { def inputDir = helpSourceDir def outputDir = "${resourceClassesDir}/${help_dir}" from(inputDir) { exclude '**/*.gif' exclude '**/*.jpg' exclude '**/*.png' filter(ReplaceTokens, beginToken: '$$', endToken: '$$', tokens: [ 'Version-Rel': JALVIEW_VERSION, 'Year-Rel': getDate("yyyy") ] ) } from(inputDir) { include '**/*.gif' include '**/*.jpg' include '**/*.png' } into outputDir inputs.dir(inputDir) outputs.files(helpFile) outputs.dir(outputDir) } task syncResources(type: Sync) { from resourceDir include "**/*.*" into "${resourceClassesDir}" preserve { include "**" } } task prepare { dependsOn syncResources dependsOn syncDocs dependsOn copyHelp } //testReportDirName = "test-reports" // note that test workingDir will be $jalviewDir test { dependsOn prepare //dependsOn compileJava ////? DELETE dependsOn compileJava //? useTestNG() { includeGroups testng_groups excludeGroups testng_excluded_groups preserveOrder true useDefaultListeners=true } 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 doFirst { } } task buildIndices(type: JavaExec) { dependsOn copyHelp classpath = sourceSets.main.compileClasspath main = "com.sun.java.help.search.Indexer" workingDir = "${classesDir}/${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 compileLinkCheck(type: JavaCompile) { options.fork = true classpath = files("${jalviewDir}/${utils_dir}") destinationDir = file("${jalviewDir}/${utils_dir}") source = fileTree(dir: "${jalviewDir}/${utils_dir}", include: ["HelpLinksChecker.java", "BufferedLineReader.java"]) inputs.file("${jalviewDir}/${utils_dir}/HelpLinksChecker.java") inputs.file("${jalviewDir}/${utils_dir}/HelpLinksChecker.java") outputs.file("${jalviewDir}/${utils_dir}/HelpLinksChecker.class") outputs.file("${jalviewDir}/${utils_dir}/BufferedLineReader.class") } task linkCheck(type: JavaExec) { dependsOn prepare, compileLinkCheck def helpLinksCheckerOutFile = file("${jalviewDir}/${utils_dir}/HelpLinksChecker.out") classpath = files("${jalviewDir}/${utils_dir}") main = "HelpLinksChecker" workingDir = jalviewDir args = [ "${classesDir}/${help_dir}", "-nointernet" ] def outFOS = new FileOutputStream(helpLinksCheckerOutFile, false) // false == don't append def errFOS = outFOS standardOutput = new org.apache.tools.ant.util.TeeOutputStream( outFOS, standardOutput) errorOutput = new org.apache.tools.ant.util.TeeOutputStream( outFOS, errorOutput) inputs.dir("${classesDir}/${help_dir}") outputs.file(helpLinksCheckerOutFile) } // import the pubhtmlhelp target ant.properties.basedir = "${jalviewDir}" ant.properties.helpBuildDir = "${jalviewDirAbsolutePath}/${classes_dir}/${help_dir}" ant.importBuild "${utils_dir}/publishHelp.xml" task cleanPackageDir(type: Delete) { doFirst { delete fileTree(dir: "${jalviewDir}/${package_dir}", include: "*.jar") } } jar { dependsOn linkCheck dependsOn buildIndices dependsOn createBuildProperties manifest { attributes "Main-Class": main_class, "Permissions": "all-permissions", "Application-Name": "Jalview Desktop", "Codebase": application_codebase } destinationDir = file("${jalviewDir}/${package_dir}") archiveName = rootProject.name+".jar" exclude "cache*/**" exclude "*.jar" exclude "*.jar.*" exclude "**/*.jar" exclude "**/*.jar.*" inputs.dir(classesDir) outputs.file("${jalviewDir}/${package_dir}/${archiveName}") }