Changeset 2556c77


Ignore:
Timestamp:
Feb 17, 2019 2:33:19 AM (20 months ago)
Author:
str4d <str4d@…>
Branches:
master
Children:
4f6b58e
Parents:
9731c20
Message:

Travis CI: Update config to handle cross-compilation

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • .travis.yml

    r9731c20 r2556c77  
    33jdk:
    44  - oraclejdk9
    5   - openjdk8
    65
    76matrix:
     
    1110        sonarcloud:
    1211          organization: "i2p"
     12      before_install:
     13        - export JAVA7_HOME=$(jdk_switcher home openjdk7)
     14        - sed -i "1iplugins {\n    id 'org.sonarqube' version '2.6.1'\n}\n" build.gradle
     15    - jdk: openjdk8
     16      before_install:
     17        - export JAVA7_HOME=$(jdk_switcher home openjdk7)
    1318    - jdk: openjdk7
    1419      sudo: required
    1520      before_install: # Work around missing crypto in openjdk7
     21        - export JAVA7_HOME=$(jdk_switcher home openjdk7)
    1622        - sudo wget "https://bouncycastle.org/download/bcprov-ext-jdk15on-158.jar" -O "${JAVA_HOME}/jre/lib/ext/bcprov-ext-jdk15on-158.jar"
    1723        - sudo perl -pi.bak -e 's/^(security\.provider\.)([0-9]+)/$1.($2+1)/ge' /etc/java-7-openjdk/security/java.security
    1824        - echo "security.provider.1=org.bouncycastle.jce.provider.BouncyCastleProvider" | sudo tee -a /etc/java-7-openjdk/security/java.security
    19 
    20 before_install:
    21  - |
    22     if [ "$TRAVIS_JDK_VERSION" == "oraclejdk8" ]; then
    23       sed -i "1iplugins {\n    id 'org.sonarqube' version '2.6.1'\n}\n" build.gradle
    24     fi
     25      install:
     26        - export TARGET_JAVA_HOME=$JAVA_HOME
     27        - jdk_switcher use oraclejdk8
     28        - ./gradlew assemble
    2529
    2630before_cache:
  • build.gradle

    r9731c20 r2556c77  
    3939        src
    4040    }
     41}
     42
     43String javaExecutable(String targetJavaHome, String execName) {
     44    def javaExecutablesPath = new File(targetJavaHome, "bin")
     45    def executable = new File(javaExecutablesPath, execName)
     46    if (!executable.exists()) {
     47        throw new IllegalArgumentException("There is no ${execName} executable in ${javaExecutablesPath}")
     48    }
     49    executable.toString()
    4150}
    4251
     
    99108        }
    100109    }
     110
     111    // Set up Java override if configured (used to test with Java 7).
     112    def targetJavaHome = System.getenv("TARGET_JAVA_HOME")
     113    if (targetJavaHome) {
     114        if (JavaVersion.current().java9Compatible) {
     115            throw new GradleException("Only set TARGET_JAVA_HOME with JDK 8")
     116        }
     117
     118        project.afterEvaluate {
     119            logger.info("Target Java home set to ${targetJavaHome}")
     120            logger.info("Configuring Gradle to use forked compilation and testing")
     121
     122            tasks.withType(JavaCompile) {
     123                options.fork = true
     124                options.forkOptions.javaHome = file(targetJavaHome)
     125            }
     126
     127            tasks.withType(Javadoc) {
     128                executable = javaExecutable(targetJavaHome, "javadoc")
     129            }
     130
     131            tasks.withType(Test) {
     132                executable = javaExecutable(targetJavaHome, "java")
     133            }
     134
     135            tasks.withType(JavaExec) {
     136                executable = javaExecutable(targetJavaHome, "java")
     137            }
     138        }
     139    }
    101140}
    102141
Note: See TracChangeset for help on using the changeset viewer.