Travis CI에서 Oracle JDK 9 EA를 사용하는 방법
Unstable 환경에서 평가판
JDK 9(Oracle JDK 9 Early Access) 지원에 대해서는 travis-ci#gh-5220에서 대응이 이루어지고 있어 작년의 1/28에는 Unstable 환경상에서의 이용이 가능하게 된 것 같습니다. (오늘까지 몰랐다・・・ )
어떻게 사용할 수 있습니까?
.travis.yml
설정은 다음과 같습니다.
.travis.ymllanguage: java
sudo: required
dist: trusty
jdk:
- oraclejdk8
- oraclejdk9
before_install: export MAVEN_SKIP_RC=true
install: mvn install
포인트는・・・・
.travis.yml
설정은 다음과 같습니다..travis.yml
language: java
sudo: required
dist: trusty
jdk:
- oraclejdk8
- oraclejdk9
before_install: export MAVEN_SKIP_RC=true
install: mvn install
포인트는・・・・
sudo: required
dist: trusty
jdk
에 oraclejdk9
추가 before_install: export MAVEN_SKIP_RC=true
(Maven을 사용하는 경우에만) 네 가지입니다.
sudo
는 false
하지만 움직이는 것 같습니다만 required
가 무난한 것 같습니다.나중에 Maven을 사용하는 경우
MAVEN_SKIP_RC=true
를 지정하지 않으면 다음과 같은 오류가 발생합니다....
$ mvn install
Unrecognized VM option 'MaxPermSize=192m'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
...
이것은, Java 8 로 폐지되었다
-XX:MaxPermSize
가 VM 의 기동 옵션으로 지정되고 있기 (위해)때문에입니다. Java 8에서는 경고 로그를 출력한 후에 런타임은 무시하게 되어 있었습니다만, Java 9부터는 에러가 되도록 되어 있습니다. (자세한 내용은 Issue 참조)실제로 Travis CI에서 JDK 9를 사용해보십시오.
Hallo World!를 표준 출력하는 간이 어플리케이션을 만들고 Travis CI에서 Maven을 사용하여 빌드해 봅시다.
Note:
실제로 사용한 간단한 애플리케이션은 다음 GitHub 리포지토리에 저장됩니다. (Maven 빌드시에 Maven wapper를 사용하고 있는 점을 제외하면, 본 투고와 내용은 같습니다)
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>jdk9-demo-with-maven</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>jdk9-demo-with-maven</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.testTarget>1.8</maven.compiler.testTarget>
<maven.compiler.testSource>1.8</maven.compiler.testSource>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>jdk9</id>
<activation>
<jdk>9</jdk>
</activation>
<properties>
<maven.compiler.target>1.9</maven.compiler.target>
<maven.compiler.testTarget>1.9</maven.compiler.testTarget>
</properties>
</profile>
</profiles>
</project>
간단한 앱
package com.example;
public class Jdk9DemoWithMavenApplication {
public static void main(String[] args) {
Message message = new Message("Hello World !");
System.out.println(message.getText());
System.out.println(System.getProperties());
}
static class Message {
private final String text;
Message(String text) {
this.text = text;
}
String getText() {
return text;
}
}
}
모처럼 왜 간단한 테스트 케이스
package com.example;
import org.hamcrest.core.Is;
import org.junit.Assert;
import org.junit.Test;
public class Jdk9DemoWithMavenApplicationTest {
@Test
public void contextLoads() {
System.out.println(System.getProperties());
Jdk9DemoWithMavenApplication.Message message = new Jdk9DemoWithMavenApplication.Message("Hello World !");
Assert.assertThat(message.getText(), Is.is("Hello World !"));
}
}
.travis.yml
language: java
sudo: required
dist: trusty
jdk:
- oraclejdk8
- oraclejdk9
before_install: export MAVEN_SKIP_RC=true
install: mvn install
# 簡易アプリを起動するためのスクリプト
script: mvn exec:java -Dexec.mainClass=com.example.Jdk9DemoWithMavenApplication
이것을 GitHub에 Push하면 ...
Travis CI에서 빌드가 시작되고 다음과 같은 실행 로그가 출력됩니다.
...
$ jdk_switcher use oraclejdk9
Switching to Oracle JDK9 (java-9-oracle), JAVA_HOME will be set to /usr/lib/jvm/java-9-oracle
$ java -Xmx32m -version
java version "9-ea"
Java(TM) SE Runtime Environment (build 9-ea+140)
Java HotSpot(TM) 64-Bit Server VM (build 9-ea+140, mixed mode)
$ javac -J-Xmx32m -version
javac 9-ea
$ export MAVEN_SKIP_RC=true
$ mvn install
...
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.example.Jdk9DemoWithMavenApplicationTest
{awt.toolkit=sun.awt.X11.XToolkit, java.specification.version=9, file.encoding.pkg=sun.io, sun.cpu.isalist=, sun.jnu.encoding=UTF-8, java.class.path=/home/travis/build/kazuki43zoo/jdk9-demo-with-maven/target/test-classes:/home/travis/build/kazuki43zoo/jdk9-demo-with-maven/target/classes:/home/travis/.m2/repository/junit/junit/4.12/junit-4.12.jar:/home/travis/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:, java.vm.vendor=Oracle Corporation, sun.arch.data.model=64, java.vendor.url=http://java.oracle.com/, user.timezone=, os.name=Linux, java.vm.specification.version=9, sun.java.launcher=SUN_STANDARD, user.country=US, sun.boot.library.path=/usr/lib/jvm/java-9-oracle/lib/amd64, sun.java.command=/home/travis/build/kazuki43zoo/jdk9-demo-with-maven/target/surefire/surefirebooter8688134916500123866.jar /home/travis/build/kazuki43zoo/jdk9-demo-with-maven/target/surefire/surefire965005284627576688tmp /home/travis/build/kazuki43zoo/jdk9-demo-with-maven/target/surefire/surefire_05891703120810359159tmp, jdk.debug=release, surefire.test.class.path=/home/travis/build/kazuki43zoo/jdk9-demo-with-maven/target/test-classes:/home/travis/build/kazuki43zoo/jdk9-demo-with-maven/target/classes:/home/travis/.m2/repository/junit/junit/4.12/junit-4.12.jar:/home/travis/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:, sun.cpu.endian=little, user.home=/home/travis, user.language=en, java.specification.vendor=Oracle Corporation, java.home=/usr/lib/jvm/java-9-oracle, file.separator=/, basedir=/home/travis/build/kazuki43zoo/jdk9-demo-with-maven, java.vm.compressedOopsMode=32-bit, line.separator=
, java.vm.specification.vendor=Oracle Corporation, java.specification.name=Java Platform API Specification, java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment, surefire.real.class.path=/home/travis/build/kazuki43zoo/jdk9-demo-with-maven/target/surefire/surefirebooter8688134916500123866.jar, sun.management.compiler=HotSpot 64-Bit Tiered Compilers, java.runtime.version=9-ea+140, user.name=travis, path.separator=:, os.version=4.4.0-51-generic, java.runtime.name=Java(TM) SE Runtime Environment, file.encoding=UTF-8, java.vm.name=Java HotSpot(TM) 64-Bit Server VM, localRepository=/home/travis/.m2/repository, java.vendor.url.bug=http://bugreport.java.com/bugreport/, java.io.tmpdir=/tmp, java.version=9-ea, user.dir=/home/travis/build/kazuki43zoo/jdk9-demo-with-maven, os.arch=amd64, java.vm.specification.name=Java Virtual Machine Specification, java.awt.printerjob=sun.print.PSPrinterJob, sun.os.patch.level=unknown, java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib, java.vm.info=mixed mode, java.vendor=Oracle Corporation, java.vm.version=9-ea+140, sun.io.unicode.encoding=UnicodeLittle, java.class.version=53.0}
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.11 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
...
$ mvn exec:java -Dexec.mainClass=com.example.Jdk9DemoWithMavenApplication
...
Hello World !
{awt.toolkit=sun.awt.X11.XToolkit, exec.mainClass=com.example.Jdk9DemoWithMavenApplication, java.specification.version=9, file.encoding.pkg=sun.io, sun.cpu.isalist=, sun.jnu.encoding=UTF-8, java.class.path=/home/travis/build/kazuki43zoo/jdk9-demo-with-maven/.mvn/wrapper/maven-wrapper.jar, java.vm.vendor=Oracle Corporation, sun.arch.data.model=64, java.vendor.url=http://java.oracle.com/, user.timezone=UTC, os.name=Linux, java.vm.specification.version=9, sun.java.launcher=SUN_STANDARD, user.country=US, sun.boot.library.path=/usr/lib/jvm/java-9-oracle/lib/amd64, sun.java.command=org.apache.maven.wrapper.MavenWrapperMain exec:java -Dexec.mainClass=com.example.Jdk9DemoWithMavenApplication, jdk.debug=release, maven.home=/home/travis/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9, sun.cpu.endian=little, user.home=/home/travis, user.language=en, java.specification.vendor=Oracle Corporation, java.home=/usr/lib/jvm/java-9-oracle, file.separator=/, java.vm.compressedOopsMode=32-bit, line.separator=
, java.vm.specification.vendor=Oracle Corporation, java.specification.name=Java Platform API Specification, java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment, sun.management.compiler=HotSpot 64-Bit Tiered Compilers, java.runtime.version=9-ea+140, user.name=travis, path.separator=:, securerandom.source=file:/dev/./urandom, os.version=4.4.0-51-generic, java.runtime.name=Java(TM) SE Runtime Environment, file.encoding=UTF-8, guice.disable.misplaced.annotation.check=true, java.vm.name=Java HotSpot(TM) 64-Bit Server VM, java.vendor.url.bug=http://bugreport.java.com/bugreport/, java.io.tmpdir=/tmp, java.version=9-ea, user.dir=/home/travis/build/kazuki43zoo/jdk9-demo-with-maven, os.arch=amd64, maven.multiModuleProjectDirectory=/home/travis/build/kazuki43zoo/jdk9-demo-with-maven, java.vm.specification.name=Java Virtual Machine Specification, java.awt.printerjob=sun.print.PSPrinterJob, sun.os.patch.level=unknown, java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib, java.vm.info=mixed mode, java.vendor=Oracle Corporation, java.vm.version=9-ea+140, classworlds.conf=/home/travis/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/bin/m2.conf, sun.io.unicode.encoding=UnicodeLittle, java.class.version=53.0}
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.089 s
[INFO] Finished at: 2017-01-06T15:49:53+00:00
[INFO] Final Memory: 12M/43M
[INFO] ------------------------------------------------------------------------
The command "mvn exec:java -Dexec.mainClass=com.example.Jdk9DemoWithMavenApplication" exited with 0.
Done. Your build exited with 0.
요약
Travis CI에서 JDK 9를 사용하는 것은 쉽습니다. 단지・・・자신이 만들고 있는 라이브러리나 어플리케이션이 JDK 9로 빌드&실행할 수 있을까는 다른 이야기입니다・・・. 사용하고 있는 라이브러리가 Java 9의 JVM으로 움직이지 않는다・・・라고 하는 것은 보통에 있을 것 같고, 빌드 툴의 플러그인이 JDK 9를 서포트 할 수 없는 케이스등도 있는 것 같습니다...
우선 현재 상태를 파악하기 위해서, Travis CI를 사용해 JDK 9로 빌드해 보면 좋을 것입니다.
Note:
Javassist나 CGLIB등의 바이트 코드를 괴롭히는 라이브러리를 사용하고 있는 경우는, 런타임시에 에러가 될 가능성인가 그렇다・・・.
참고 사이트
...
$ jdk_switcher use oraclejdk9
Switching to Oracle JDK9 (java-9-oracle), JAVA_HOME will be set to /usr/lib/jvm/java-9-oracle
$ java -Xmx32m -version
java version "9-ea"
Java(TM) SE Runtime Environment (build 9-ea+140)
Java HotSpot(TM) 64-Bit Server VM (build 9-ea+140, mixed mode)
$ javac -J-Xmx32m -version
javac 9-ea
$ export MAVEN_SKIP_RC=true
$ mvn install
...
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.example.Jdk9DemoWithMavenApplicationTest
{awt.toolkit=sun.awt.X11.XToolkit, java.specification.version=9, file.encoding.pkg=sun.io, sun.cpu.isalist=, sun.jnu.encoding=UTF-8, java.class.path=/home/travis/build/kazuki43zoo/jdk9-demo-with-maven/target/test-classes:/home/travis/build/kazuki43zoo/jdk9-demo-with-maven/target/classes:/home/travis/.m2/repository/junit/junit/4.12/junit-4.12.jar:/home/travis/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:, java.vm.vendor=Oracle Corporation, sun.arch.data.model=64, java.vendor.url=http://java.oracle.com/, user.timezone=, os.name=Linux, java.vm.specification.version=9, sun.java.launcher=SUN_STANDARD, user.country=US, sun.boot.library.path=/usr/lib/jvm/java-9-oracle/lib/amd64, sun.java.command=/home/travis/build/kazuki43zoo/jdk9-demo-with-maven/target/surefire/surefirebooter8688134916500123866.jar /home/travis/build/kazuki43zoo/jdk9-demo-with-maven/target/surefire/surefire965005284627576688tmp /home/travis/build/kazuki43zoo/jdk9-demo-with-maven/target/surefire/surefire_05891703120810359159tmp, jdk.debug=release, surefire.test.class.path=/home/travis/build/kazuki43zoo/jdk9-demo-with-maven/target/test-classes:/home/travis/build/kazuki43zoo/jdk9-demo-with-maven/target/classes:/home/travis/.m2/repository/junit/junit/4.12/junit-4.12.jar:/home/travis/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:, sun.cpu.endian=little, user.home=/home/travis, user.language=en, java.specification.vendor=Oracle Corporation, java.home=/usr/lib/jvm/java-9-oracle, file.separator=/, basedir=/home/travis/build/kazuki43zoo/jdk9-demo-with-maven, java.vm.compressedOopsMode=32-bit, line.separator=
, java.vm.specification.vendor=Oracle Corporation, java.specification.name=Java Platform API Specification, java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment, surefire.real.class.path=/home/travis/build/kazuki43zoo/jdk9-demo-with-maven/target/surefire/surefirebooter8688134916500123866.jar, sun.management.compiler=HotSpot 64-Bit Tiered Compilers, java.runtime.version=9-ea+140, user.name=travis, path.separator=:, os.version=4.4.0-51-generic, java.runtime.name=Java(TM) SE Runtime Environment, file.encoding=UTF-8, java.vm.name=Java HotSpot(TM) 64-Bit Server VM, localRepository=/home/travis/.m2/repository, java.vendor.url.bug=http://bugreport.java.com/bugreport/, java.io.tmpdir=/tmp, java.version=9-ea, user.dir=/home/travis/build/kazuki43zoo/jdk9-demo-with-maven, os.arch=amd64, java.vm.specification.name=Java Virtual Machine Specification, java.awt.printerjob=sun.print.PSPrinterJob, sun.os.patch.level=unknown, java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib, java.vm.info=mixed mode, java.vendor=Oracle Corporation, java.vm.version=9-ea+140, sun.io.unicode.encoding=UnicodeLittle, java.class.version=53.0}
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.11 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
...
$ mvn exec:java -Dexec.mainClass=com.example.Jdk9DemoWithMavenApplication
...
Hello World !
{awt.toolkit=sun.awt.X11.XToolkit, exec.mainClass=com.example.Jdk9DemoWithMavenApplication, java.specification.version=9, file.encoding.pkg=sun.io, sun.cpu.isalist=, sun.jnu.encoding=UTF-8, java.class.path=/home/travis/build/kazuki43zoo/jdk9-demo-with-maven/.mvn/wrapper/maven-wrapper.jar, java.vm.vendor=Oracle Corporation, sun.arch.data.model=64, java.vendor.url=http://java.oracle.com/, user.timezone=UTC, os.name=Linux, java.vm.specification.version=9, sun.java.launcher=SUN_STANDARD, user.country=US, sun.boot.library.path=/usr/lib/jvm/java-9-oracle/lib/amd64, sun.java.command=org.apache.maven.wrapper.MavenWrapperMain exec:java -Dexec.mainClass=com.example.Jdk9DemoWithMavenApplication, jdk.debug=release, maven.home=/home/travis/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9, sun.cpu.endian=little, user.home=/home/travis, user.language=en, java.specification.vendor=Oracle Corporation, java.home=/usr/lib/jvm/java-9-oracle, file.separator=/, java.vm.compressedOopsMode=32-bit, line.separator=
, java.vm.specification.vendor=Oracle Corporation, java.specification.name=Java Platform API Specification, java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment, sun.management.compiler=HotSpot 64-Bit Tiered Compilers, java.runtime.version=9-ea+140, user.name=travis, path.separator=:, securerandom.source=file:/dev/./urandom, os.version=4.4.0-51-generic, java.runtime.name=Java(TM) SE Runtime Environment, file.encoding=UTF-8, guice.disable.misplaced.annotation.check=true, java.vm.name=Java HotSpot(TM) 64-Bit Server VM, java.vendor.url.bug=http://bugreport.java.com/bugreport/, java.io.tmpdir=/tmp, java.version=9-ea, user.dir=/home/travis/build/kazuki43zoo/jdk9-demo-with-maven, os.arch=amd64, maven.multiModuleProjectDirectory=/home/travis/build/kazuki43zoo/jdk9-demo-with-maven, java.vm.specification.name=Java Virtual Machine Specification, java.awt.printerjob=sun.print.PSPrinterJob, sun.os.patch.level=unknown, java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib, java.vm.info=mixed mode, java.vendor=Oracle Corporation, java.vm.version=9-ea+140, classworlds.conf=/home/travis/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/bin/m2.conf, sun.io.unicode.encoding=UnicodeLittle, java.class.version=53.0}
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.089 s
[INFO] Finished at: 2017-01-06T15:49:53+00:00
[INFO] Final Memory: 12M/43M
[INFO] ------------------------------------------------------------------------
The command "mvn exec:java -Dexec.mainClass=com.example.Jdk9DemoWithMavenApplication" exited with 0.
Done. Your build exited with 0.
Travis CI에서 JDK 9를 사용하는 것은 쉽습니다. 단지・・・자신이 만들고 있는 라이브러리나 어플리케이션이 JDK 9로 빌드&실행할 수 있을까는 다른 이야기입니다・・・. 사용하고 있는 라이브러리가 Java 9의 JVM으로 움직이지 않는다・・・라고 하는 것은 보통에 있을 것 같고, 빌드 툴의 플러그인이 JDK 9를 서포트 할 수 없는 케이스등도 있는 것 같습니다...
우선 현재 상태를 파악하기 위해서, Travis CI를 사용해 JDK 9로 빌드해 보면 좋을 것입니다.
Note:
Javassist나 CGLIB등의 바이트 코드를 괴롭히는 라이브러리를 사용하고 있는 경우는, 런타임시에 에러가 될 가능성인가 그렇다・・・.
참고 사이트
Reference
이 문제에 관하여(Travis CI에서 Oracle JDK 9 EA를 사용하는 방법), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/kazuki43zoo/items/3718ee05fa526d048a86텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)