You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by mw...@apache.org on 2006/03/02 07:50:45 UTC
svn commit: r382309 - in /logging/log4j/trunk: ./ docs/
src/java/org/apache/log4j/ tests/ tests/src/java/org/apache/log4j/
Author: mwomack
Date: Wed Mar 1 22:50:43 2006
New Revision: 382309
URL: http://svn.apache.org/viewcvs?rev=382309&view=rev
Log:
Added Version class and tests; bug 17862
Added:
logging/log4j/trunk/src/java/org/apache/log4j/Version.java (with props)
logging/log4j/trunk/src/java/org/apache/log4j/versionInfo (with props)
logging/log4j/trunk/tests/src/java/org/apache/log4j/VersionTest.java (with props)
Modified:
logging/log4j/trunk/build.xml
logging/log4j/trunk/docs/HISTORY.txt
logging/log4j/trunk/tests/build.xml
logging/log4j/trunk/tests/src/java/org/apache/log4j/CoreTestSuite.java
Modified: logging/log4j/trunk/build.xml
URL: http://svn.apache.org/viewcvs/logging/log4j/trunk/build.xml?rev=382309&r1=382308&r2=382309&view=diff
==============================================================================
--- logging/log4j/trunk/build.xml (original)
+++ logging/log4j/trunk/build.xml Wed Mar 1 22:50:43 2006
@@ -21,7 +21,15 @@
<!-- The build.properties file defines the parth to local jar files -->
<property file="build.properties"/>
- <property name="version" value="1.3alpha-8"/>
+ <property name="version" value="1.3"/>
+ <property name="apiVersion" value="1.3"/>
+ <property name="milestone" value="alpha"/>
+ <property name="milestoneVersion" value="8"/>
+ <condition property="fullVersion"
+ value="${version}-${milestone}"
+ else="${version}-${milestone}-${milestoneVersion}">
+ <equals arg1="${milestone}" arg2="final"/>
+ </condition>
<property name="target" value="1.2"/>
<property name="source" value="1.3"/>
@@ -55,16 +63,16 @@
<property name="jar.dest" value="${dist.dir}/lib"/>
<!-- The jar file that the jar task will generate -->
- <property name="log4j.jar" value="log4j-${version}.jar"/>
- <property name="log4j-optional.jar" value="log4j-optional-${version}.jar"/>
- <property name="log4j-oro.jar" value="log4j-oro-${version}.jar"/>
- <property name="log4j-xml.jar" value="log4j-xml-${version}.jar"/>
- <property name="log4j-jms.jar" value="log4j-jms-${version}.jar"/>
- <property name="log4j-smtp.jar" value="log4j-smtp-${version}.jar"/>
- <property name="log4j-db.jar" value="log4j-db-${version}.jar"/>
- <property name="log4j-nt.jar" value="log4j-nt-${version}.jar"/>
- <property name="log4j-jmx.jar" value="log4j-jmx-${version}.jar"/>
- <property name="log4j-all.jar" value="log4j-all-${version}.jar"/>
+ <property name="log4j.jar" value="log4j-${fullVersion}.jar"/>
+ <property name="log4j-optional.jar" value="log4j-optional-${fullVersion}.jar"/>
+ <property name="log4j-oro.jar" value="log4j-oro-${fullVersion}.jar"/>
+ <property name="log4j-xml.jar" value="log4j-xml-${fullVersion}.jar"/>
+ <property name="log4j-jms.jar" value="log4j-jms-${fullVersion}.jar"/>
+ <property name="log4j-smtp.jar" value="log4j-smtp-${fullVersion}.jar"/>
+ <property name="log4j-db.jar" value="log4j-db-${fullVersion}.jar"/>
+ <property name="log4j-nt.jar" value="log4j-nt-${fullVersion}.jar"/>
+ <property name="log4j-jmx.jar" value="log4j-jmx-${fullVersion}.jar"/>
+ <property name="log4j-all.jar" value="log4j-all-${fullVersion}.jar"/>
<!-- Destination for documentation files -->
@@ -309,7 +317,20 @@
</target>
<target name="build.core" depends="init, jndiCheck, jaxpCheck">
- <mkdir dir="${javac.dest}/"/>
+ <mkdir dir="${javac.dest}/"/>
+
+ <available file="org/apache/log4j/versionInfo"
+ filepath="${javac.dest}"
+ property="build.copyVersion"/>
+ <mkdir dir="${javac.dest}/org/apache/log4j"/>
+ <copy file="${BSTEM}/versionInfo" todir="${javac.dest}/org/apache/log4j">
+ <filterset>
+ <filter token="version" value="${version}"/>
+ <filter token="apiVersion" value="${apiVersion}"/>
+ <filter token="milestone" value="${milestone}"/>
+ <filter token="milestoneVersion" value="${milestoneVersion}"/>
+ </filterset>
+ </copy>
<javac destdir="${javac.dest}"
includes="${stem}/**/*.java"
excludes="**/UnitTest*.java,
@@ -390,7 +411,7 @@
<manifest>
<section name="org/apache/log4j/">
<attribute name="Implementation-Title" value="log4j-xml"/>
- <attribute name="Implementation-Version" value="${version}"/>
+ <attribute name="Implementation-Version" value="${fullVersion}"/>
<attribute name="Implementation-Vendor" value="Apache Software Foundation"/>
</section>
</manifest>
@@ -423,7 +444,7 @@
<manifest>
<section name="org/apache/log4j/">
<attribute name="Implementation-Title" value="log4j-smtp"/>
- <attribute name="Implementation-Version" value="${version}"/>
+ <attribute name="Implementation-Version" value="${fullVersion}"/>
<attribute name="Implementation-Vendor" value="Apache Software Foundation"/>
</section>
</manifest>
@@ -458,7 +479,7 @@
<manifest>
<section name="org/apache/log4j/">
<attribute name="Implementation-Title" value="log4j-oro"/>
- <attribute name="Implementation-Version" value="${version}"/>
+ <attribute name="Implementation-Version" value="${fullVersion}"/>
<attribute name="Implementation-Vendor" value="Apache Software Foundation"/>
</section>
</manifest>
@@ -494,7 +515,7 @@
<manifest>
<section name="org/apache/log4j/">
<attribute name="Implementation-Title" value="log4j-jms"/>
- <attribute name="Implementation-Version" value="${version}"/>
+ <attribute name="Implementation-Version" value="${fullVersion}"/>
<attribute name="Implementation-Vendor" value="Apache Software Foundation"/>
</section>
</manifest>
@@ -527,7 +548,7 @@
<manifest>
<section name="org/apache/log4j/">
<attribute name="Implementation-Title" value="log4j-jmx"/>
- <attribute name="Implementation-Version" value="${version}"/>
+ <attribute name="Implementation-Version" value="${fullVersion}"/>
<attribute name="Implementation-Vendor" value="Apache Software Foundation"/>
</section>
</manifest>
@@ -568,7 +589,7 @@
<manifest>
<section name="org/apache/log4j/">
<attribute name="Implementation-Title" value="log4j-db"/>
- <attribute name="Implementation-Version" value="${version}"/>
+ <attribute name="Implementation-Version" value="${fullVersion}"/>
<attribute name="Implementation-Vendor" value="Apache Software Foundation"/>
</section>
</manifest>
@@ -595,7 +616,7 @@
<manifest>
<section name="org/apache/log4j/">
<attribute name="Implementation-Title" value="log4j-nt"/>
- <attribute name="Implementation-Version" value="${version}"/>
+ <attribute name="Implementation-Version" value="${fullVersion}"/>
<attribute name="Implementation-Vendor" value="Apache Software Foundation"/>
</section>
</manifest>
@@ -668,7 +689,7 @@
<manifest>
<section name="org/apache/log4j/">
<attribute name="Implementation-Title" value="log4j-optional"/>
- <attribute name="Implementation-Version" value="${version}"/>
+ <attribute name="Implementation-Version" value="${fullVersion}"/>
<attribute name="Implementation-Vendor" value="Apache Software Foundation"/>
</section>
</manifest>
@@ -709,7 +730,8 @@
<mkdir dir="${jar.dest}/"/>
<jar jarfile="${jar.dest}/${log4j.jar}" basedir="${javac.dest}"
- includes="${stem}/*.class,
+ includes="${stem}/versionInfo,
+ ${stem}/*.class,
${stem}/joran/**/*.class,
${stem}/config/*.class,
${stem}/helpers/*.class,
@@ -757,7 +779,7 @@
<attribute name="Manifest-version" value="1.0"/>
<section name="org/apache/log4j/">
<attribute name="Implementation-Title" value="log4j"/>
- <attribute name="Implementation-Version" value="${version}"/>
+ <attribute name="Implementation-Version" value="${fullVersion}"/>
<attribute name="Implementation-Vendor" value="Apache Software Foundation"/>
</section>
</manifest>
@@ -771,14 +793,14 @@
<mkdir dir="${jar.dest}/"/>
<jar jarfile="${jar.dest}/${log4j-all.jar}" basedir="${javac.dest}"
- includes="${stem}/**/*.class"
+ includes="${stem}/versionInfo,${stem}/**/*.class"
excludes="**/UnitTest**,
${stem}/xml/test/*.class">
<manifest>
<attribute name="Manifest-version" value="1.0"/>
<section name="org/apache/log4j/">
<attribute name="Implementation-Title" value="log4j with all features"/>
- <attribute name="Implementation-Version" value="${version}"/>
+ <attribute name="Implementation-Version" value="${fullVersion}"/>
<attribute name="Implementation-Vendor" value="Apache Software Foundation"/>
</section>
</manifest>
@@ -865,9 +887,9 @@
author="true"
use="true"
overview="${javadoc.dest}/overview.html"
- doctitle="log4j version ${version}<br>API Specification"
- windowtitle="Log4j Version ${version}"
- header="<b>Log4j ${version}</b>"
+ doctitle="log4j version ${fullVersion}<br>API Specification"
+ windowtitle="Log4j Version ${fullVersion}"
+ header="<b>Log4j ${fullVersion}</b>"
bottom='Copyright © 2000-2006 Apache Software Foundation. <br />
Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.'>
<sourcepath>
@@ -910,7 +932,7 @@
<old name="Version ${reference-api.version}">
<dirset dir="${reference-api.source.dir}" includes="org/**"/>
</old>
- <new name="Version ${version}">
+ <new name="Version ${fullVersion}">
<dirset dir="${java.source.dir}" includes="org/**"/>
</new>
</jdiff>
@@ -1025,9 +1047,9 @@
<mkdir dir="${dist.images}" />
- <mkdir dir="${dist.tmp}/logging-log4j-${version}" />
+ <mkdir dir="${dist.tmp}/logging-log4j-${fullVersion}" />
- <copy todir="${dist.tmp}/logging-log4j-${version}">
+ <copy todir="${dist.tmp}/logging-log4j-${fullVersion}">
<fileset dir="${base}"
includes="src/java/**,
src/xdocs/**,
@@ -1050,15 +1072,15 @@
/>
</copy>
- <tar tarfile="${dist.images}/logging-log4j-${version}.tar.gz"
+ <tar tarfile="${dist.images}/logging-log4j-${fullVersion}.tar.gz"
basedir="${dist.tmp}"
- includes="logging-log4j-${version}/**"
+ includes="logging-log4j-${fullVersion}/**"
compression="gzip"
longfile="gnu" />
- <zip zipfile="${dist.images}/logging-log4j-${version}.zip"
+ <zip zipfile="${dist.images}/logging-log4j-${fullVersion}.zip"
basedir="${dist.tmp}"
- includes="logging-log4j-${version}/**" />
+ includes="logging-log4j-${fullVersion}/**" />
<delete dir="${dist.tmp}" />
Modified: logging/log4j/trunk/docs/HISTORY.txt
URL: http://svn.apache.org/viewcvs/logging/log4j/trunk/docs/HISTORY.txt?rev=382309&r1=382308&r2=382309&view=diff
==============================================================================
--- logging/log4j/trunk/docs/HISTORY.txt (original)
+++ logging/log4j/trunk/docs/HISTORY.txt Wed Mar 1 22:50:43 2006
@@ -8,6 +8,10 @@
[D] Changes affect a method or property which was previously marked as
deprecated.
+ - Release of version 1.3-alpha9
+ TBD
+
+ - Bug
January 30th, 2006
- Release of version 1.3alpha-8
Added: logging/log4j/trunk/src/java/org/apache/log4j/Version.java
URL: http://svn.apache.org/viewcvs/logging/log4j/trunk/src/java/org/apache/log4j/Version.java?rev=382309&view=auto
==============================================================================
--- logging/log4j/trunk/src/java/org/apache/log4j/Version.java (added)
+++ logging/log4j/trunk/src/java/org/apache/log4j/Version.java Wed Mar 1 22:50:43 2006
@@ -0,0 +1,132 @@
+/*
+ * Copyright 1999,2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j;
+
+import java.util.Properties;
+import java.io.IOException;
+
+/**
+ * Provides methods for determining version information for the version of the
+ * log4j library being used. Callers can find the full version, milestone,
+ * milestone version, and api version. This information can be used in a
+ * variety of ways. For example, one could write code to ensure that only
+ * "final" versions of the log4j library are used on production systems, or that
+ * a certain api version is used.
+ *
+ * @author Mark Womack
+ * @since 1.3
+ */
+public class Version {
+
+ private static final String CONST_UNKNOWN = "UNKNOWN";
+
+ private static String fullVersion = CONST_UNKNOWN;
+ private static String version = CONST_UNKNOWN;
+ private static String apiVersion = CONST_UNKNOWN;
+ private static String milestone = CONST_UNKNOWN;
+ private static String milestoneVersion = CONST_UNKNOWN;
+
+ static {
+ loadVersionInfo();
+ }
+
+ /**
+ * Returns the full version information for the version of
+ * log4j being used. The full version contains the major version,
+ * milestone, and milestone version inf the following format:
+ *
+ * <majorVersion>-<milestone>[-<milestoneVersion>]
+ *
+ * The milestoneVersion information will not be included if
+ * the version is a final release version.
+ *
+ * Examples are:
+ *
+ * "1.3-final" - version string for the final 1.3 version
+ * "1.3.3-final" - version string for the final 1.3.3 version
+ * "1.3.1-alpha-3" - version string for the alpha 3, 1.3.1 version
+ * "1.3.2-beta-2" - version string for the beta 2, 1.3.2 version
+ * "1.3-rc-1" - version string for the release candidate 1, 1.3 version
+
+ * @return the full version string for the log4j library being used
+ */
+ public static String getFullVersion() {
+ return fullVersion;
+ }
+
+ /**
+ * Returns the version for the log4j library being used.
+ *
+ * @return the version for the log4j library being used
+ */
+ public static String getVersion() {
+ return version;
+ }
+
+ /**
+ * Returns the milestone for the log4j library being used.
+ * Valid values are "alpha", "beta", "rc", and "final".
+ *
+ * @return the milestone for the log4j library being used
+ */
+ public static String getMilestone() {
+ return milestone;
+ }
+
+ /**
+ * Returns the milestone version for the log4j library being used.
+ * If this value will be empty if the milestone is "final".
+ *
+ * @return the milestone version for the log4j library being used
+ */
+ public static String getMilestoneVersion() {
+ return milestoneVersion;
+ }
+
+ /**
+ * Returns the api version for the log4j library being used. This
+ * value can be different than the value returned by getVersion(). For
+ * example, the version might be "1.3.1" but the api version will be "1.3".
+ *
+ * @return the api version for the log4j library being used
+ */
+ public static String getApiVersion() {
+ return apiVersion;
+ }
+
+ /**
+ * Loads the version information from a file in the resources.
+ */
+ private static void loadVersionInfo() {
+ ClassLoader loader = Version.class.getClassLoader();
+ Properties versionProps = new Properties();
+ try {
+ versionProps.load(loader.getResourceAsStream("org/apache/log4j/versionInfo"));
+ } catch (IOException e) {
+ // do nothing, version will remain UNKNOWN
+ }
+
+ version = versionProps.getProperty("version", CONST_UNKNOWN);
+ apiVersion = versionProps.getProperty("apiVersion", CONST_UNKNOWN);
+ milestone = versionProps.getProperty("milestone", CONST_UNKNOWN);
+ milestoneVersion =
+ versionProps.getProperty("milestoneVersion", CONST_UNKNOWN);
+ fullVersion = version + "-" + milestone +
+ ((milestoneVersion.equals(CONST_UNKNOWN) || milestoneVersion.length() == 0) ? "" :
+ "-"+milestoneVersion);
+ }
+}
Propchange: logging/log4j/trunk/src/java/org/apache/log4j/Version.java
------------------------------------------------------------------------------
svn:executable = *
Added: logging/log4j/trunk/src/java/org/apache/log4j/versionInfo
URL: http://svn.apache.org/viewcvs/logging/log4j/trunk/src/java/org/apache/log4j/versionInfo?rev=382309&view=auto
==============================================================================
--- logging/log4j/trunk/src/java/org/apache/log4j/versionInfo (added)
+++ logging/log4j/trunk/src/java/org/apache/log4j/versionInfo Wed Mar 1 22:50:43 2006
@@ -0,0 +1,4 @@
+version=@version@
+apiVersion=@apiVersion@
+milestone=@milestone@
+milestoneVersion=@milestoneVersion@
\ No newline at end of file
Propchange: logging/log4j/trunk/src/java/org/apache/log4j/versionInfo
------------------------------------------------------------------------------
svn:executable = *
Modified: logging/log4j/trunk/tests/build.xml
URL: http://svn.apache.org/viewcvs/logging/log4j/trunk/tests/build.xml?rev=382309&r1=382308&r2=382309&view=diff
==============================================================================
--- logging/log4j/trunk/tests/build.xml (original)
+++ logging/log4j/trunk/tests/build.xml Wed Mar 1 22:50:43 2006
@@ -47,8 +47,8 @@
<path id="tests.classpath">
- <pathelement location="${project.source.home}"/>
<pathelement location="${project.classes.home}"/>
+ <pathelement location="${project.source.home}"/>
<pathelement location="${tests.source.home}"/>
<pathelement location="${tests.javac.dest}"/>
<pathelement location="./resources"/>
@@ -748,6 +748,14 @@
<classpath refid="tests.classpath"/>
<formatter type="plain" usefile="false"/>
<test name="org.apache.log4j.varia.ExternallyRolledFileAppenderTest" />
+ </junit>
+ </target>
+
+ <target name="Version" depends="check, build, cleanOutputDir">
+ <junit printsummary="yes" fork="yes" haltonfailure="${haltonfailure}">
+ <classpath refid="tests.classpath"/>
+ <formatter type="plain" usefile="false"/>
+ <test name="org.apache.log4j.VersionTest" />
</junit>
</target>
Modified: logging/log4j/trunk/tests/src/java/org/apache/log4j/CoreTestSuite.java
URL: http://svn.apache.org/viewcvs/logging/log4j/trunk/tests/src/java/org/apache/log4j/CoreTestSuite.java?rev=382309&r1=382308&r2=382309&view=diff
==============================================================================
--- logging/log4j/trunk/tests/src/java/org/apache/log4j/CoreTestSuite.java (original)
+++ logging/log4j/trunk/tests/src/java/org/apache/log4j/CoreTestSuite.java Wed Mar 1 22:50:43 2006
@@ -34,6 +34,7 @@
*/
public static Test suite() {
TestSuite s = new TestSuite();
+ s.addTestSuite(VersionTest.class);
s.addTestSuite(LoggingEventTest.class);
s.addTestSuite(org.apache.log4j.pattern.NameAbbreviatorTest.class);
s.addTestSuite(org.apache.log4j.pattern.PatternParserTest.class);
Added: logging/log4j/trunk/tests/src/java/org/apache/log4j/VersionTest.java
URL: http://svn.apache.org/viewcvs/logging/log4j/trunk/tests/src/java/org/apache/log4j/VersionTest.java?rev=382309&view=auto
==============================================================================
--- logging/log4j/trunk/tests/src/java/org/apache/log4j/VersionTest.java (added)
+++ logging/log4j/trunk/tests/src/java/org/apache/log4j/VersionTest.java Wed Mar 1 22:50:43 2006
@@ -0,0 +1,73 @@
+package org.apache.log4j;
+
+import junit.framework.TestCase;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import java.util.Properties;
+import java.io.FileInputStream;
+
+/**
+ * Unit test for the Version class.
+ *
+ * @author Mark Womack
+ */
+public class VersionTest extends TestCase {
+
+ private static final String propsFile = "output/version/versionInfo";
+
+ Logger logger = Logger.getLogger(VersionTest.class.getName());
+
+ public VersionTest(String name) {
+ super(name);
+ }
+
+ public void testVersion() throws Exception {
+ // first read in the properties we are expecting from the file
+ Properties baseProps = new Properties();
+ baseProps.load(VersionTest.class.getClassLoader().
+ getResourceAsStream("org/apache/log4j/versionInfo"));
+ String baseVersion = baseProps.getProperty("version");
+ String baseApiVersion = baseProps.getProperty("apiVersion");
+ String baseMilestone = baseProps.getProperty("milestone");
+ String baseMilestoneVersion = baseProps.getProperty("milestoneVersion");
+
+ // make sure it looks like the version info was correctly set
+ assertTrue("version was not replaced in versionInfo: '" + baseVersion + "'",
+ baseVersion.indexOf('@') == -1);
+ assertTrue("apiVersion was not replaced in versionInfo",
+ baseApiVersion.indexOf('@') == -1);
+ assertTrue("milestone was not replaced in versionInfo",
+ baseMilestone.indexOf('@') == -1);
+ assertTrue("milestoneVersion was not replaced in versionInfo",
+ baseMilestoneVersion.indexOf('@') == -1);
+ if (baseMilestone.equals("final")) {
+ assertTrue("milestoneVersion is not empty for final milestone",
+ baseMilestoneVersion.length() == 0);
+ } else {
+ assertTrue("milestoneVersion is not set for milestone",
+ baseMilestoneVersion.length() != 0);
+ }
+
+ // now compare values to what the Version object returns
+ assertEquals("version incorrect", baseVersion, Version.getVersion());
+ assertEquals("apiVersion incorrect", baseApiVersion, Version.getApiVersion());
+ assertEquals("milestone incorrect", baseMilestone, Version.getMilestone());
+ assertEquals("milestoneVersion incorrect", baseMilestoneVersion, Version.getMilestoneVersion());
+ String baseFullVersion = baseVersion + "-" + baseMilestone;
+ if (!baseMilestone.equals("final")) {
+ baseFullVersion += "-" + baseMilestoneVersion;
+ }
+ assertEquals("fullVersion incorrect", baseFullVersion, Version.getFullVersion());
+
+ System.out.println("fullVersion is: " + Version.getFullVersion());
+ System.out.println("apiVersion is: " + Version.getApiVersion());
+ }
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite();
+ suite.addTest(new VersionTest("testVersion"));
+
+ return suite;
+ }
+}
Propchange: logging/log4j/trunk/tests/src/java/org/apache/log4j/VersionTest.java
------------------------------------------------------------------------------
svn:executable = *
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org