Issue #6148 - update jetty.tag.version behavior

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
This commit is contained in:
Joakim Erdfelt 2021-04-08 13:50:20 -05:00
parent aed20abcbe
commit 871560032e
No known key found for this signature in database
GPG Key ID: 2D0E1FB8FE4B68B4
4 changed files with 62 additions and 34 deletions

View File

@ -13,7 +13,30 @@
<spotbugs.onlyAnalyze>org.eclipse.jetty.start.*</spotbugs.onlyAnalyze>
</properties>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<executions>
<execution>
<id>create-buildnumber</id>
<goals>
<goal>create</goal>
</goals>
<configuration>
<doCheck>false</doCheck>
<doUpdate>false</doUpdate>
<revisionOnScmFailure>${nonCanonicalRevision}</revisionOnScmFailure>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>

View File

@ -19,7 +19,9 @@
package org.eclipse.jetty.start;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@ -365,4 +367,25 @@ public final class Props implements Iterable<Prop>
{
return props.toString();
}
public static Props load(URL url)
{
Props props = new Props();
if (url != null)
{
try (InputStream in = url.openStream())
{
Properties properties = new Properties();
properties.load(in);
String urlStr = url.toExternalForm();
properties.stringPropertyNames().forEach((name) ->
props.setProperty(name, properties.getProperty(name), urlStr));
}
catch (IOException x)
{
StartLog.debug(x);
}
}
return props;
}
}

View File

@ -21,9 +21,7 @@ package org.eclipse.jetty.start;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@ -69,8 +67,8 @@ public class StartArgs
static
{
// Use command line versions
String ver = System.getProperty("jetty.version", null);
String tag = System.getProperty("jetty.tag.version", "master");
String ver = System.getProperty("jetty.version");
String tag = System.getProperty("jetty.tag.version");
// Use META-INF/MANIFEST.MF versions
if (ver == null)
@ -82,41 +80,21 @@ public class StartArgs
.orElse(null);
}
// Use jetty-version.properties values
if (ver == null)
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
// use old jetty-version.properties (as seen within various linux distro repackaging of Jetty)
Props jettyVerProps = Props.load(classLoader.getResource("jetty-version.properties"));
// use build-time properties (included in start.jar) to pull version and buildNumber
Props buildProps = Props.load(classLoader.getResource("/org/eclipse/jetty/version/build.properties"));
if (Utils.isBlank(ver))
{
URL url = Thread.currentThread().getContextClassLoader().getResource("jetty-version.properties");
if (url != null)
{
try (InputStream in = url.openStream())
{
Properties props = new Properties();
props.load(in);
ver = props.getProperty("jetty.version");
}
catch (IOException x)
{
StartLog.debug(x);
}
}
ver = jettyVerProps.getString("version", buildProps.getString("version", "0.0"));
}
// Default values
if (ver == null)
if (Utils.isBlank(tag))
{
ver = "0.0";
if (tag == null)
tag = "master";
tag = jettyVerProps.getString("buildNumber", buildProps.getString("buildNumber", "jetty-" + ver));
}
else
{
if (tag == null)
tag = "jetty-" + ver;
}
// Set Tag Defaults
if (tag.contains("-SNAPSHOT"))
tag = "master";
VERSION = ver;
System.setProperty("jetty.version", VERSION);

View File

@ -0,0 +1,4 @@
buildNumber=${buildNumber}
timestamp=${timestamp}
version=${project.version}
scmUrl=${project.scm.connection}