Skip to content

Commit

Permalink
Issue #6148 - update jetty.tag.version behavior
Browse files Browse the repository at this point in the history
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
  • Loading branch information
joakime committed Apr 8, 2021
1 parent aed20ab commit 8715600
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 34 deletions.
23 changes: 23 additions & 0 deletions jetty-start/pom.xml
Expand Up @@ -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>
Expand Down
23 changes: 23 additions & 0 deletions jetty-start/src/main/java/org/eclipse/jetty/start/Props.java
Expand Up @@ -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;
Expand Down Expand Up @@ -365,4 +367,25 @@ public String toString()
{
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;
}
}
46 changes: 12 additions & 34 deletions jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java
Expand Up @@ -21,9 +21,7 @@
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;
Expand Down Expand Up @@ -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)
Expand All @@ -82,42 +80,22 @@ public class StartArgs
.orElse(null);
}

// Use jetty-version.properties values
if (ver == null)
{
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);
}
}
}
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"));

// Default values
if (ver == null)
if (Utils.isBlank(ver))
{
ver = "0.0";
if (tag == null)
tag = "master";
ver = jettyVerProps.getString("version", buildProps.getString("version", "0.0"));
}
else

if (Utils.isBlank(tag))
{
if (tag == null)
tag = "jetty-" + ver;
tag = jettyVerProps.getString("buildNumber", buildProps.getString("buildNumber", "jetty-" + ver));
}

// Set Tag Defaults
if (tag.contains("-SNAPSHOT"))
tag = "master";

VERSION = ver;
System.setProperty("jetty.version", VERSION);
System.setProperty("jetty.tag.version", tag);
Expand Down
@@ -0,0 +1,4 @@
buildNumber=${buildNumber}
timestamp=${timestamp}
version=${project.version}
scmUrl=${project.scm.connection}

0 comments on commit 8715600

Please sign in to comment.