From 0ecc0de82dae3d228d8aade76b8ad2f32ff09f28 Mon Sep 17 00:00:00 2001 From: antelder Date: Tue, 26 Jan 2010 10:59:48 +0000 Subject: First cut at having a programatic way to get the svn revision that a tuscany build is from. This approach seems a little conveluted so if anyone has a better approach please do say, this one uses the Maven buildnumber plugin to set a mvn property with the svn revision, which is then written into a message properties file with the antrun plugin, which is then used initilize a constant in a Version class. Not sure if it even actually works, committing it so i can get a Hudson build and check if it does end up with the correct value git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@903166 13f79535-47bb-0310-9956-ffa450edef68 --- sca-java-2.x/trunk/modules/core-spi/pom.xml | 44 ++++++++++++++++++++++ .../org/apache/tuscany/sca/runtime/Version.java | 35 +++++++++++++++++ .../sca/runtime/core-spi-messages.properties | 28 ++++++++++++++ .../tuscany/sca/runtime/VersionTestCase.java | 33 ++++++++++++++++ 4 files changed, 140 insertions(+) create mode 100644 sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/Version.java create mode 100644 sca-java-2.x/trunk/modules/core-spi/src/main/resources/org/apache/tuscany/sca/runtime/core-spi-messages.properties create mode 100644 sca-java-2.x/trunk/modules/core-spi/src/test/java/org/apache/tuscany/sca/runtime/VersionTestCase.java (limited to 'sca-java-2.x/trunk') diff --git a/sca-java-2.x/trunk/modules/core-spi/pom.xml b/sca-java-2.x/trunk/modules/core-spi/pom.xml index f3367c5cbb..5d89fcbe93 100644 --- a/sca-java-2.x/trunk/modules/core-spi/pom.xml +++ b/sca-java-2.x/trunk/modules/core-spi/pom.xml @@ -68,4 +68,48 @@ + + + + org.codehaus.mojo + buildnumber-maven-plugin + 1.0-beta-4 + + + validate + + create + + + + + sources.version + build.timestamp + true + true + + + + org.apache.maven.plugins + maven-antrun-plugin + + + process-resources + process-resources + + + + + + + + run + + + + + + + diff --git a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/Version.java b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/Version.java new file mode 100644 index 0000000000..b112176982 --- /dev/null +++ b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/Version.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.tuscany.sca.runtime; + +import java.util.ResourceBundle; + +public class Version { + + public static final String REVISION; + static { + ResourceBundle rb = ResourceBundle.getBundle("org/apache/tuscany/sca/runtime/core-spi-messages"); + REVISION = rb.getString("revision"); + } + + public static String getRevsion() { + return REVISION; + } +} diff --git a/sca-java-2.x/trunk/modules/core-spi/src/main/resources/org/apache/tuscany/sca/runtime/core-spi-messages.properties b/sca-java-2.x/trunk/modules/core-spi/src/main/resources/org/apache/tuscany/sca/runtime/core-spi-messages.properties new file mode 100644 index 0000000000..0659d609fd --- /dev/null +++ b/sca-java-2.x/trunk/modules/core-spi/src/main/resources/org/apache/tuscany/sca/runtime/core-spi-messages.properties @@ -0,0 +1,28 @@ +# +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +# +# + +#-- Don't edit these. They're updated from the build, see the +# buildnumber-maven-plugin in this modules pom.xml +revision=@svnRevision@ +#---------------------- + + + diff --git a/sca-java-2.x/trunk/modules/core-spi/src/test/java/org/apache/tuscany/sca/runtime/VersionTestCase.java b/sca-java-2.x/trunk/modules/core-spi/src/test/java/org/apache/tuscany/sca/runtime/VersionTestCase.java new file mode 100644 index 0000000000..b23709199d --- /dev/null +++ b/sca-java-2.x/trunk/modules/core-spi/src/test/java/org/apache/tuscany/sca/runtime/VersionTestCase.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.tuscany.sca.runtime; + +import org.junit.Test; + +/** + */ +public class VersionTestCase { + + @Test + public void testRevision() { + // Doesn't test much, just that it has been initilized to a number + Integer.parseInt(Version.getRevsion()); + } + +} -- cgit v1.2.3