/* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Amazon designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ dependencies { compile project(path: ':openjdksrc', configuration: 'archives') compile project(path: ':prebuild', configuration: 'cacerts') } // Two configurations for tgz & Jtreg native library respectively. // Separate artifacts to simplify the artifacts fetching in :mac:pkg. configurations { buildTar testLib } // consts def imageDir= "$buildRoot/build/${project.jdkImageName}/images" def jdkResultingImage = "${imageDir}/jdk-bundle" def testResultingImage = "${imageDir}/test" def correttoMacDir = "amazon-corretto-${project.version.major}.jdk" // deps def depsMap = [:] project.configurations.compile.getFiles().each { depsMap[it.getName()] = it } /** * Create a local copy of the source tree in our * build root -- this is required since OpenJDK's * build wants to occur inside the source tree, * and we don't want to tamper with someone * else's tree. */ task copySource(type: Exec) { if (!file(buildRoot).exists()) { file(buildRoot).mkdirs() } workingDir '/usr/bin' commandLine 'rsync', '-am', '--exclude=pre-build', '--exclude=installers', '--exclude=corretto-build', "${project.rootDir}/", buildRoot } task configureBuild(type: Exec) { dependsOn project.configurations.compile dependsOn copySource workingDir "$buildRoot" // Platform specific flags def command = ['bash', 'configure', "--with-cacerts-file=${depsMap[caCerts]}" ] if (project.correttoArch == "aarch64") { command += "--with-zlib=bundled" } // Common flags command += project.correttoCommonFlags commandLine command.flatten() } task executeBuild(type: Exec) { dependsOn configureBuild workingDir "$buildRoot" commandLine 'make', 'images' } task executeTestBuild(type: Exec) { dependsOn executeBuild workingDir "$buildRoot" commandLine 'make','test-image' } task prepareArtifacts { dependsOn executeBuild doLast { if(file("${jdkResultingImage}/${correttoMacDir}").exists()) { delete "${jdkResultingImage}/${correttoMacDir}" } // Rename bundle exec { workingDir jdkResultingImage commandLine 'bash', '-c', "\"\"mv jdk-${version.major}*.jdk ${correttoMacDir}\"\"" } // Replace Info.plist def plistTokens = new Properties() plistTokens["INFO"] = "Amazon Corretto ${project.version.full}-${versionOpt}".toString() plistTokens["ID"] = "com.amazon.corretto.${project.version.major}".toString() plistTokens["NAME"] = "Amazon Corretto ${project.version.major}".toString() plistTokens["VERSION"] = "${project.version.major}.${project.version.minor}.${project.version.security}".toString() plistTokens["BUILD_VERSION"] = "${project.version.full}".toString() plistTokens["MACOSX_VERSION_MIN"] = (correttoArch == "x64" ? "10.12" : "11.0") plistTokens["VENDOR"] = "Amazon.com Inc." copy { from("${rootDir}/make/data/bundle/JDK-Info.plist") { rename { file -> 'Info.plist' } filter(org.apache.tools.ant.filters.ReplaceTokens, beginToken: "@@", endToken: "@@", tokens: plistTokens) } into "${jdkResultingImage}/${correttoMacDir}/Contents" } // Filter files if(file("${buildDir}/${correttoMacDir}").exists()) { delete "${buildDir}/${correttoMacDir}" } copy { from("${jdkResultingImage}/${correttoMacDir}") { include "Contents/Home/bin/**" include "Contents/Home/conf/**" include "Contents/Home/include/**" include "Contents/Home/jmods/**" include "Contents/Home/legal/**" include "Contents/Home/lib/**" include "Contents/Home/man/man1/**" include "Contents/Home/release" include "Contents/Info.plist" include "Contents/MacOS/**" exclude "Contents/Home/**/*.diz" } from(buildRoot) { include 'ADDITIONAL_LICENSE_INFO' include 'ASSEMBLY_EXCEPTION' include 'LICENSE' include 'README.md' include 'commitId.txt' include 'version.txt' into "Contents/Home" } into "${buildDir}/${correttoMacDir}" } // Set the directory as bundle exec { commandLine "SetFile", "-a", "B", "${buildDir}/${correttoMacDir}" } } } task packaging(type: Exec) { dependsOn prepareArtifacts String tarDir = "${distributionDir}/${project.correttoJdkArchiveName}.tar.gz" workingDir buildDir commandLine "tar", "czf", tarDir, correttoMacDir outputs.file tarDir } task packageDebugSymbols(type: Tar) { dependsOn prepareArtifacts description 'Package debug symbols' archiveName "${project.correttoDebugSymbolsArchiveName}.tar.gz" compression Compression.GZIP from("${jdkResultingImage}/${correttoMacDir}") { include "Contents/Home/bin/*.diz" include "Contents/Home/lib/*.diz" include "Contents/Home/lib/server/*.diz" } into "${buildDir}/${correttoMacDir}" into project.correttoDebugSymbolsArchiveName } task packageTestResults(type: Tar) { dependsOn executeTestBuild description 'Package test results' archiveName "${project.correttoTestImageArchiveName}.tar.gz" compression Compression.GZIP from(testResultingImage) { include '**' } into project.correttoTestImageArchiveName } build.dependsOn packaging build.dependsOn packageDebugSymbols build.dependsOn packageTestResults artifacts { buildTar file: packaging.outputs.getFiles().getSingleFile(), builtBy: packaging testLib packageTestResults }