Issue #2090 Java Version JEP223. Use shaded util in start.
This commit is contained in:
parent
bfe79c0afe
commit
595c6ac1ee
|
@ -371,7 +371,7 @@ public class Server extends HandlerWrapper implements Attributes
|
|||
String gitHash = Jetty.GIT_HASH;
|
||||
String timestamp = Jetty.BUILD_TIMESTAMP;
|
||||
|
||||
LOG.info("jetty-{}; build timestamp: {}; git hash: {}; on {}", getVersion(), timestamp, gitHash, JavaVersion.VERSION);
|
||||
LOG.info("jetty-{}; built: {}; git: {}; jvm {}", getVersion(), timestamp, gitHash, JavaVersion.VERSION);
|
||||
if (!Jetty.STABLE)
|
||||
{
|
||||
LOG.warn("THIS IS NOT A STABLE RELEASE! DO NOT USE IN PRODUCTION!");
|
||||
|
|
|
@ -32,9 +32,45 @@
|
|||
<onlyAnalyze>org.eclipse.jetty.start.*</onlyAnalyze>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<createSourcesJar>true</createSourcesJar>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>org.eclipse.jetty:jetty-util</artifact>
|
||||
<includes>
|
||||
<include>org/eclipse/jetty/util/JavaVersion*</include>
|
||||
</includes>
|
||||
</filter>
|
||||
</filters>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.eclipse.jetty.util</pattern>
|
||||
<shadedPattern>org.eclipse.jetty.start.shaded.util</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-util</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||
<artifactId>jetty-test-helper</artifactId>
|
||||
|
|
|
@ -1,159 +0,0 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.start;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Java Version Utility class.
|
||||
* <p>Parses java versions to extract a consistent set of version parts</p>
|
||||
*/
|
||||
public class JavaVersion
|
||||
{
|
||||
// Copy of code in jetty-util
|
||||
|
||||
private static final Pattern PRE_JDK9 = Pattern.compile("1\\.(\\d)(\\.(\\d+)(_(\\d+))?)?(-.+)?");
|
||||
// Regexp from JEP 223 (http://openjdk.java.net/jeps/223).
|
||||
private static final Pattern JDK9 = Pattern.compile("(\\d+)(\\.(\\d+))?(\\.(\\d+))?((-.+)?(\\+(\\d+)?(-.+)?)?)");
|
||||
|
||||
public static JavaVersion parse(String version)
|
||||
{
|
||||
if (version.startsWith("1."))
|
||||
return parsePreJDK9(version);
|
||||
return parseJDK9(version);
|
||||
}
|
||||
|
||||
private static JavaVersion parsePreJDK9(String version)
|
||||
{
|
||||
Matcher matcher = PRE_JDK9.matcher(version);
|
||||
if (!matcher.matches())
|
||||
throw new IllegalArgumentException("Invalid Java version " + version);
|
||||
int major = 1;
|
||||
int minor = Integer.parseInt(matcher.group(1));
|
||||
String microGroup = matcher.group(3);
|
||||
int micro = microGroup == null || microGroup.isEmpty() ? 0 : Integer.parseInt(microGroup);
|
||||
String updateGroup = matcher.group(5);
|
||||
int update = updateGroup == null || updateGroup.isEmpty() ? 0 : Integer.parseInt(updateGroup);
|
||||
String suffix = matcher.group(6);
|
||||
return new JavaVersion(version, minor, major, minor, micro, update, suffix);
|
||||
}
|
||||
|
||||
private static JavaVersion parseJDK9(String version)
|
||||
{
|
||||
Matcher matcher = JDK9.matcher(version);
|
||||
if (!matcher.matches())
|
||||
throw new IllegalArgumentException("Invalid Java version " + version);
|
||||
int major = Integer.parseInt(matcher.group(1));
|
||||
String minorGroup = matcher.group(3);
|
||||
int minor = minorGroup == null || minorGroup.isEmpty() ? 0 : Integer.parseInt(minorGroup);
|
||||
String microGroup = matcher.group(5);
|
||||
int micro = microGroup == null || microGroup.isEmpty() ? 0 : Integer.parseInt(microGroup);
|
||||
String suffix = matcher.group(6);
|
||||
return new JavaVersion(version, major, major, minor, micro, 0, suffix);
|
||||
}
|
||||
|
||||
private final String version;
|
||||
private final int platform;
|
||||
private final int major;
|
||||
private final int minor;
|
||||
private final int micro;
|
||||
private final int update;
|
||||
private final String suffix;
|
||||
|
||||
private JavaVersion(String version, int platform, int major, int minor, int micro, int update, String suffix)
|
||||
{
|
||||
this.version = version;
|
||||
this.platform = platform;
|
||||
this.major = major;
|
||||
this.minor = minor;
|
||||
this.micro = micro;
|
||||
this.update = update;
|
||||
this.suffix = suffix;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the string from which this JavaVersion was created
|
||||
*/
|
||||
public String getVersion()
|
||||
{
|
||||
return version;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Returns the Java Platform version, such as {@code 8} for JDK 1.8.0_92 and {@code 9} for JDK 9.2.4.</p>
|
||||
*
|
||||
* @return the Java Platform version
|
||||
*/
|
||||
public int getPlatform()
|
||||
{
|
||||
return platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Returns the major number version, such as {@code 1} for JDK 1.8.0_92 and {@code 9} for JDK 9.2.4.</p>
|
||||
*
|
||||
* @return the major number version
|
||||
*/
|
||||
public int getMajor()
|
||||
{
|
||||
return major;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Returns the minor number version, such as {@code 8} for JDK 1.8.0_92 and {@code 2} for JDK 9.2.4.</p>
|
||||
*
|
||||
* @return the minor number version
|
||||
*/
|
||||
public int getMinor()
|
||||
{
|
||||
return minor;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Returns the micro number version, such as {@code 0} for JDK 1.8.0_92 and {@code 4} for JDK 9.2.4.</p>
|
||||
*
|
||||
* @return the micro number version
|
||||
*/
|
||||
public int getMicro()
|
||||
{
|
||||
return micro;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Returns the update number version, such as {@code 92} for JDK 1.8.0_92 and {@code 0} for JDK 9.2.4.</p>
|
||||
*
|
||||
* @return the update number version
|
||||
*/
|
||||
public int getUpdate()
|
||||
{
|
||||
return update;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Returns the remaining string after the version numbers, such as {@code -internal} for
|
||||
* JDK 1.8.0_92-internal and {@code -ea} for JDK 9-ea, or {@code +13} for JDK 9.2.4+13.</p>
|
||||
*
|
||||
* @return the remaining string after the version numbers
|
||||
*/
|
||||
public String getSuffix()
|
||||
{
|
||||
return suffix;
|
||||
}
|
||||
}
|
|
@ -41,6 +41,7 @@ import org.eclipse.jetty.start.Props.Prop;
|
|||
import org.eclipse.jetty.start.config.ConfigSource;
|
||||
import org.eclipse.jetty.start.config.ConfigSources;
|
||||
import org.eclipse.jetty.start.config.DirConfigSource;
|
||||
import org.eclipse.jetty.util.JavaVersion;
|
||||
|
||||
/**
|
||||
* The Arguments required to start Jetty.
|
||||
|
|
|
@ -0,0 +1,151 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.util;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Tests for LazyList utility class.
|
||||
*/
|
||||
public class JavaVersionTest
|
||||
{
|
||||
@Test
|
||||
public void test9()
|
||||
{
|
||||
JavaVersion version = JavaVersion.parse("9.0.1");
|
||||
assertThat(version.getPlatform(),is(9));
|
||||
assertThat(version.getMajor(),is(9));
|
||||
assertThat(version.getMinor(),is(0));
|
||||
assertThat(version.getMicro(),is(1));
|
||||
assertThat(version.getUpdate(),is(0));
|
||||
assertThat(version.getSuffix(),nullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test9nano()
|
||||
{
|
||||
JavaVersion version = JavaVersion.parse("9.0.1.3");
|
||||
assertThat(version.getPlatform(),is(9));
|
||||
assertThat(version.getMajor(),is(9));
|
||||
assertThat(version.getMinor(),is(0));
|
||||
assertThat(version.getMicro(),is(1));
|
||||
assertThat(version.getUpdate(),is(0));
|
||||
assertThat(version.getSuffix(),is("3"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test9build()
|
||||
{
|
||||
JavaVersion version = JavaVersion.parse("9.0.1+11");
|
||||
assertThat(version.getPlatform(),is(9));
|
||||
assertThat(version.getMajor(),is(9));
|
||||
assertThat(version.getMinor(),is(0));
|
||||
assertThat(version.getMicro(),is(1));
|
||||
assertThat(version.getUpdate(),is(11));
|
||||
assertThat(version.getSuffix(),nullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test9all()
|
||||
{
|
||||
JavaVersion version = JavaVersion.parse("9.0.1-ea+11-b01");
|
||||
assertThat(version.getPlatform(),is(9));
|
||||
assertThat(version.getMajor(),is(9));
|
||||
assertThat(version.getMinor(),is(0));
|
||||
assertThat(version.getMicro(),is(1));
|
||||
assertThat(version.getUpdate(),is(11));
|
||||
assertThat(version.getSuffix(),is("ea-b01"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test9yuck()
|
||||
{
|
||||
JavaVersion version = JavaVersion.parse("9.0.1.2.3-ea+11-b01");
|
||||
assertThat(version.getPlatform(),is(9));
|
||||
assertThat(version.getMajor(),is(9));
|
||||
assertThat(version.getMinor(),is(0));
|
||||
assertThat(version.getMicro(),is(1));
|
||||
assertThat(version.getUpdate(),is(11));
|
||||
assertThat(version.getSuffix(),is("2.3-ea-b01"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test10ea()
|
||||
{
|
||||
JavaVersion version = JavaVersion.parse("10-ea");
|
||||
assertThat(version.getPlatform(),is(10));
|
||||
assertThat(version.getMajor(),is(10));
|
||||
assertThat(version.getMinor(),is(0));
|
||||
assertThat(version.getMicro(),is(0));
|
||||
assertThat(version.getUpdate(),is(0));
|
||||
assertThat(version.getSuffix(),is("ea"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test8()
|
||||
{
|
||||
JavaVersion version = JavaVersion.parse("1.8.0_152");
|
||||
assertThat(version.getPlatform(),is(8));
|
||||
assertThat(version.getMajor(),is(1));
|
||||
assertThat(version.getMinor(),is(8));
|
||||
assertThat(version.getMicro(),is(0));
|
||||
assertThat(version.getUpdate(),is(152));
|
||||
assertThat(version.getSuffix(),nullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test8ea()
|
||||
{
|
||||
JavaVersion version = JavaVersion.parse("1.8.1_03-ea");
|
||||
assertThat(version.getPlatform(),is(8));
|
||||
assertThat(version.getMajor(),is(1));
|
||||
assertThat(version.getMinor(),is(8));
|
||||
assertThat(version.getMicro(),is(1));
|
||||
assertThat(version.getUpdate(),is(3));
|
||||
assertThat(version.getSuffix(),is("ea"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test3eaBuild()
|
||||
{
|
||||
JavaVersion version = JavaVersion.parse("1.3.1_05-ea-b01");
|
||||
assertThat(version.getPlatform(),is(3));
|
||||
assertThat(version.getMajor(),is(1));
|
||||
assertThat(version.getMinor(),is(3));
|
||||
assertThat(version.getMicro(),is(1));
|
||||
assertThat(version.getUpdate(),is(5));
|
||||
assertThat(version.getSuffix(),is("ea-b01"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUbuntu()
|
||||
{
|
||||
JavaVersion version = JavaVersion.parse("9-Ubuntu+0-9b181-4");
|
||||
assertThat(version.getPlatform(),is(9));
|
||||
assertThat(version.getMajor(),is(9));
|
||||
assertThat(version.getMinor(),is(0));
|
||||
assertThat(version.getMicro(),is(0));
|
||||
assertThat(version.getUpdate(),is(0));
|
||||
assertThat(version.getSuffix(),is("Ubuntu-9b181-4"));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue