Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Introduced a helper class with info about the CDK library: the versio…

…n number, which is read from the build.props which is now included in the cdk-core.jar

Signed-off-by: Rajarshi  Guha <rajarshi.guha@gmail.com>
  • Loading branch information...
commit 5a2bc653ebdd8c45f511117cde930246250d25b0 1 parent 0de5777
@egonw egonw authored rajarshi committed
View
1  build.xml
@@ -371,6 +371,7 @@
<includesfile name="${metainf}/${module}.autogenerated" if="module.autogenerated.present"/>
</fileset>
</copy>
+ <copy todir="${build}" file="build.props" />
<!-- ok, now that we have a copy, compile this copy -->
<javac srcdir="${build.src}/${module}" destdir="${build}/${module}" optimize="${optimization}"
View
1  src/META-INF/core.buildfiles
@@ -0,0 +1 @@
+build.props
View
67 src/main/org/openscience/cdk/CDK.java
@@ -0,0 +1,67 @@
+/* Copyright (C) 2010 Egon Willighagen <egonw@users.sf.net>
+ *
+ * Contact: cdk-devel@lists.sourceforge.net
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ * All I ask is that proper credit is given for my work, which includes
+ * - but is not limited to - adding the above copyright notice to the beginning
+ * of your source code files, and to any copyright notice that you may distribute
+ * with programs based on this work.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+package org.openscience.cdk;
+
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.openscience.cdk.annotations.TestClass;
+import org.openscience.cdk.annotations.TestMethod;
+import org.openscience.cdk.tools.LoggingTool;
+
+/**
+ * Helper class to provide general information about this CDK library.
+ *
+ * @cdk.module core
+ */
+@TestClass("org.openscience.cdk.CDKTest")
+public class CDK {
+
+ private static LoggingTool logger = new LoggingTool(CDK.class);
+
+ /**
+ * Returns the version of this CDK library.
+ *
+ * @return A {@link String} representation of the version number.
+ */
+ @TestMethod("testGetVersion")
+ public static String getVersion() {
+ String propsFilename = "build.props";
+ Properties props = new Properties();
+ try {
+ InputStream stream = CDK.class.getClassLoader().getResourceAsStream(propsFilename);
+ props.load(stream);
+ System.out.println("version: " + props.getProperty("version"));
+ return props.getProperty("version");
+ } catch (Exception exception) {
+ // there is no back up
+ logger.error(
+ "Error while loading the buid.props file: ", exception.getMessage()
+ );
+ logger.debug(exception);
+ exception.printStackTrace();
+ }
+ return "ERROR";
+ }
+
+}
View
41 src/test/org/openscience/cdk/CDKTest.java
@@ -0,0 +1,41 @@
+/* Copyright (C) 2010 Egon Willighagen <egonw@users.sf.net>
+ *
+ * Contact: cdk-devel@lists.sourceforge.net
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+package org.openscience.cdk;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Tests the {@link CDK} helper class functionality.
+ *
+ * @cdk.module test-core
+ */
+public class CDKTest {
+
+ @Test
+ public void testGetVersion() {
+ Assert.assertNotNull(CDK.getVersion());
+ Assert.assertNotSame(0, CDK.getVersion().length());
+ Assert.assertNotSame(
+ "There was an error retrieving the CDK version.",
+ "ERROR", CDK.getVersion()
+ );
+ }
+
+}
View
7 src/test/org/openscience/cdk/modulesuites/McoreTests.java
@@ -1,6 +1,5 @@
-/* $Revision$ $Author$ $Date$
- *
- * Copyright (C) 1997-2007 The Chemistry Development Kit (CDK) project
+/* Copyright (C) 1997-2007 The Chemistry Development Kit (CDK) project
+ * 2010 Egon Willighagen <egonw@users.sf.net>
*
* Contact: cdk-devel@lists.sourceforge.net
*
@@ -24,6 +23,7 @@
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
import org.openscience.cdk.CDKConstantsTest;
+import org.openscience.cdk.CDKTest;
import org.openscience.cdk.atomtype.CDKAtomTypeMatcherFilesTest;
import org.openscience.cdk.atomtype.CDKAtomTypeMatcherSMILESTest;
import org.openscience.cdk.atomtype.CDKAtomTypeMatcherTest;
@@ -63,6 +63,7 @@
@SuiteClasses(value={
CoreCoverageTest.class,
+ CDKTest.class,
CDKConstantsTest.class,
DataFeaturesTest.class,
Please sign in to comment.
Something went wrong with that request. Please try again.