add a build.properties file containing git hash, build timestamp scm url (#1957)
* add a build.properties file containing git hash, build timestamp and scm url #1956 Signed-off-by: olivier lamy <olamy@webtide.com> * move build infos to Jetty class so it's available for server and client Signed-off-by: olivier lamy <olamy@webtide.com> * apply changes by Greg review Signed-off-by: olivier lamy <olamy@webtide.com>
This commit is contained in:
parent
b1d5fea96c
commit
6499baa3a2
|
@ -18,6 +18,7 @@
|
|||
|
||||
package org.eclipse.jetty.server;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
|
@ -68,6 +69,7 @@ import org.eclipse.jetty.util.thread.ShutdownThread;
|
|||
import org.eclipse.jetty.util.thread.ThreadPool;
|
||||
import org.eclipse.jetty.util.thread.ThreadPool.SizedThreadPool;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Jetty HTTP Servlet Server.
|
||||
* This class is the main class for the Jetty HTTP Servlet server.
|
||||
|
@ -343,7 +345,10 @@ public class Server extends HandlerWrapper implements Attributes
|
|||
//Start a thread waiting to receive "stop" commands.
|
||||
ShutdownMonitor.getInstance().start(); // initialize
|
||||
|
||||
LOG.info("jetty-" + getVersion());
|
||||
String gitHash = Jetty.GIT_HASH;
|
||||
String timestamp = Jetty.BUILD_TIMESTAMP;
|
||||
|
||||
LOG.info("jetty-{}, build timestamp: {}, git hash: {}", getVersion(), timestamp, gitHash);
|
||||
if (!Jetty.STABLE)
|
||||
{
|
||||
LOG.warn("THIS IS NOT A STABLE RELEASE! DO NOT USE IN PRODUCTION!");
|
||||
|
|
|
@ -13,6 +13,12 @@
|
|||
<bundle-symbolic-name>${project.groupId}.util</bundle-symbolic-name>
|
||||
</properties>
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
|
@ -21,6 +27,23 @@
|
|||
<onlyAnalyze>org.eclipse.jetty.util.*</onlyAnalyze>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<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>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
|
|
|
@ -18,14 +18,50 @@
|
|||
|
||||
package org.eclipse.jetty.util;
|
||||
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Properties;
|
||||
|
||||
public class Jetty
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger( Jetty.class);
|
||||
|
||||
public static final String VERSION;
|
||||
public static final String POWERED_BY;
|
||||
public static final boolean STABLE;
|
||||
public static final String GIT_HASH;
|
||||
|
||||
/**
|
||||
* a formatted build timestamp with pattern yyyy-MM-dd'T'HH:mm:ssXXX
|
||||
*/
|
||||
public static final String BUILD_TIMESTAMP;
|
||||
private static final Properties __buildProperties = new Properties( );
|
||||
|
||||
static
|
||||
{
|
||||
try
|
||||
{
|
||||
try (InputStream inputStream = //
|
||||
Jetty.class.getResourceAsStream( "/org/eclipse/jetty/version/build.properties" ))
|
||||
{
|
||||
__buildProperties.load( inputStream );
|
||||
}
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
LOG.ignore( e );
|
||||
}
|
||||
|
||||
GIT_HASH = __buildProperties.getProperty( "buildNumber", "unknown" );
|
||||
System.setProperty( "jetty.git.hash" , GIT_HASH );
|
||||
BUILD_TIMESTAMP = formatTimestamp( __buildProperties.getProperty( "timestamp", "unknown" ));
|
||||
|
||||
// using __buildProperties.getProperty("version") will contain version from the pom
|
||||
|
||||
Package pkg = Jetty.class.getPackage();
|
||||
if (pkg != null &&
|
||||
"Eclipse.org - Jetty".equals(pkg.getImplementationVendor()) &&
|
||||
|
@ -43,5 +79,20 @@ public class Jetty
|
|||
private Jetty()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private static String formatTimestamp( String timestamp )
|
||||
{
|
||||
try
|
||||
{
|
||||
return new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ssXXX" )
|
||||
.format( new Date( Long.valueOf( timestamp ) ) );
|
||||
}
|
||||
catch ( NumberFormatException e )
|
||||
{
|
||||
LOG.debug( e );
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
buildNumber=${buildNumber}
|
||||
timestamp=${timestamp}
|
||||
version=${project.version}
|
||||
scmUrl=${project.scm.connection}
|
174
pom.xml
174
pom.xml
|
@ -531,6 +531,180 @@
|
|||
<onlyAnalyze>org.eclipse.jetty.*</onlyAnalyze>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.m2e</groupId>
|
||||
<artifactId>lifecycle-mapping</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<configuration>
|
||||
<lifecycleMappingMetadata>
|
||||
<pluginExecutions>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||
<artifactId>jetty-version-maven-plugin</artifactId>
|
||||
<versionRange>[1.0.3,)</versionRange>
|
||||
<goals>
|
||||
<goal>attach-version-text</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore />
|
||||
</action>
|
||||
</pluginExecution>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<versionRange>[2.1,)</versionRange>
|
||||
<goals>
|
||||
<goal>unpack</goal>
|
||||
<goal>unpack-dependencies</goal>
|
||||
<goal>copy-dependencies</goal>
|
||||
<goal>copy</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore />
|
||||
</action>
|
||||
</pluginExecution>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>org.ops4j.pax.exam</groupId>
|
||||
<artifactId>maven-paxexam-plugin</artifactId>
|
||||
<versionRange>
|
||||
[1.2.0,)
|
||||
</versionRange>
|
||||
<goals>
|
||||
<goal>
|
||||
generate-depends-file
|
||||
</goal>
|
||||
<goal>generate-config</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore />
|
||||
</action>
|
||||
</pluginExecution>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<versionRange>[1.4,)</versionRange>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore />
|
||||
</action>
|
||||
</pluginExecution>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>org.sonatype.maven.plugin</groupId>
|
||||
<artifactId>emma-maven-plugin</artifactId>
|
||||
<versionRange>[1.1,)</versionRange>
|
||||
<goals>
|
||||
<goal>instrument</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore />
|
||||
</action>
|
||||
</pluginExecution>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-plugin-plugin</artifactId>
|
||||
<versionRange>[2.5,)</versionRange>
|
||||
<goals>
|
||||
<goal>default-descriptor</goal>
|
||||
<goal>descriptor</goal>
|
||||
<goal>xdoc</goal>
|
||||
<goal>helpmojo</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore />
|
||||
</action>
|
||||
</pluginExecution>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>native-maven-plugin</artifactId>
|
||||
<versionRange>[1.0-alpha-7,)</versionRange>
|
||||
<goals>
|
||||
<goal>initialize</goal>
|
||||
<goal>javah</goal>
|
||||
<goal>compile</goal>
|
||||
<goal>unzipinc</goal>
|
||||
<goal>link</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore />
|
||||
</action>
|
||||
</pluginExecution>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<versionRange>[2.8,)</versionRange>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore />
|
||||
</action>
|
||||
</pluginExecution>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-pmd-plugin</artifactId>
|
||||
<versionRange>[2.5,)</versionRange>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore />
|
||||
</action>
|
||||
</pluginExecution>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-remote-resources-plugin</artifactId>
|
||||
<versionRange>[1.0,)</versionRange>
|
||||
<goals>
|
||||
<goal>process</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore />
|
||||
</action>
|
||||
</pluginExecution>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-enforcer-plugin</artifactId>
|
||||
<versionRange>[1.0,)</versionRange>
|
||||
<goals>
|
||||
<goal>enforce</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore />
|
||||
</action>
|
||||
</pluginExecution>
|
||||
</pluginExecutions>
|
||||
</lifecycleMappingMetadata>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>buildnumber-maven-plugin</artifactId>
|
||||
<version>1.4</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
|
Loading…
Reference in New Issue