- job:
    name: jdk-build-specjbb2015-jdk11
    project-type: freestyle
    defaults: global
    description: |
        * This job creates an archive of the SPECjbb2015 product for JDK11+.<br>
          It can be copied as a *copy artifact* by other jobs.<br>
        * <b>Note:</b> SPECjbb2015 should <b>not</b> be shared publically as there are licensing restrictions.
        * This is build built on and for JDK 11+. JEP-320 removed some APIs that need to be replaced - this job
          adds some dependencies to the maven job building SPECjbb2015.
    properties:
        - authorization:
            everyone-flat:
                - job-read
            openjdk-members:
                - job-build
                - job-cancel
                - job-workspace
        - build-discarder:
            days-to-keep: 30
            num-to-keep: 10
            artifact-num-to-keep: 5
    parameters:
        - string:
            name: MAVEN_URL
            default: 'http://www.us.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz'
    disabled: true
    node: aarch64-06
    display-name: 'DELETE ME'
    wrappers:
        - timestamps
    builders:
        - copyartifact:
            project: archive-specjbb2015-product-tarball
            filter: 'out/SPECjbb2015.tgz'
            target: artifacts
            flatten: true
        - copyartifact:
            project: jdkX-build-image
            parameters: 'BUILD_TYPE=release,JVM_VARIANT=server,label=aarch64-06'
            filter: 'out/jdkX-server-release.tar.gz'
            target: artifacts
            flatten: true
        - shell: |
            #!/bin/bash

            set -exu

            rm -f artifacts/apache-maven-*.tar.gz
            cd artifacts
            wget --progress=dot -e dotbytes=2M  ${MAVEN_URL}
            cd -

            tar -zxf artifacts/apache-maven-*.tar.gz
            cd apache-maven-*
            export M3_HOME=${PWD}
            cd -

            export PATH=${M3_HOME}/bin:$PATH

            rm -rf build out jdkX-server-release
            tar xzf artifacts/BUILD_TYPE=release,JVM_VARIANT=server,label=aarch64-06/jdkX-server-release.tar.gz
            export PATH=$PWD/jdkX-server-release/bin:$PATH

            java -version

            rm -rf build out
            mkdir build out


            tar -xzf artifacts/SPECjbb2015.tgz -C build

            cd build/SPECjbb2015

            unzip src.zip

            sed  '
            /<\/dependencies>/ {
            i\
                    <dependency>\
                     <groupId>org.glassfish.jaxb</groupId>\
                      <artifactId>jaxb-runtime</artifactId>\
                      <version>2.3.0</version>\
                    </dependency>\
                    <dependency>\
                      <groupId>org.glassfish.jaxb</groupId>\
                      <artifactId>jaxb-xjc</artifactId>\
                      <version>2.3.0</version>\
                    </dependency>\
                    <dependency>\
                      <groupId>org.glassfish.jaxb</groupId>\
                      <artifactId>jaxb-jxc</artifactId>\
                      <version>2.3.0</version>\
                    </dependency>\
                    <dependency>\
                      <groupId>javax.activation</groupId>\
                      <artifactId>activation</artifactId>\
                      <version>1.1.1</version>\
                    </dependency>
            }
            ' <pom.xml >newpom.xml

            mvn install -f newpom.xml

            cp -r config docs *.bat *.sh target/SPECjbb2015-1.00

            cd target

            chmod -R ug+rw SPECjbb2015-1.00
            tar -czf ../../../out/SPECjbb2015-jdk11.tar.gz SPECjbb2015-1.00

            cd ../..
    publishers:
        - archive:
            artifacts: 'out/SPECjbb2015-jdk11.tar.gz'
