You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ju...@apache.org on 2011/10/25 19:14:21 UTC
svn commit: r1188803 - in /tika/trunk:
tika-app/src/main/java/org/apache/tika/cli/TikaCLI.java tika-core/pom.xml
tika-core/src/main/java/org/apache/tika/Tika.java
tika-core/src/test/java/org/apache/tika/TikaIT.java
Author: jukka
Date: Tue Oct 25 17:14:21 2011
New Revision: 1188803
URL: http://svn.apache.org/viewvc?rev=1188803&view=rev
Log:
TIKA-761: Provide version number by CLI argument -V
Patch by Ingo Renner
Added:
tika/trunk/tika-core/src/test/java/org/apache/tika/TikaIT.java
Modified:
tika/trunk/tika-app/src/main/java/org/apache/tika/cli/TikaCLI.java
tika/trunk/tika-core/pom.xml
tika/trunk/tika-core/src/main/java/org/apache/tika/Tika.java
Modified: tika/trunk/tika-app/src/main/java/org/apache/tika/cli/TikaCLI.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-app/src/main/java/org/apache/tika/cli/TikaCLI.java?rev=1188803&r1=1188802&r2=1188803&view=diff
==============================================================================
--- tika/trunk/tika-app/src/main/java/org/apache/tika/cli/TikaCLI.java (original)
+++ tika/trunk/tika-app/src/main/java/org/apache/tika/cli/TikaCLI.java Tue Oct 25 17:14:21 2011
@@ -52,6 +52,7 @@ import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.SimpleLayout;
import org.apache.log4j.WriterAppender;
+import org.apache.tika.Tika;
import org.apache.tika.config.TikaConfig;
import org.apache.tika.detect.DefaultDetector;
import org.apache.tika.detect.Detector;
@@ -300,6 +301,9 @@ public class TikaCLI {
if (arg.equals("-?") || arg.equals("--help")) {
pipeMode = false;
usage();
+ } else if (arg.equals("-V") || arg.equals("--version")) {
+ pipeMode = false;
+ version();
} else if (arg.equals("-v") || arg.equals("--verbose")) {
Logger.getRootLogger().setLevel(Level.DEBUG);
} else if (arg.equals("-g") || arg.equals("--gui")) {
@@ -401,6 +405,7 @@ public class TikaCLI {
out.println("Options:");
out.println(" -? or --help Print this usage message");
out.println(" -v or --verbose Print debug level messages");
+ out.println(" -V or --version Print the Apache Tika version number");
out.println();
out.println(" -g or --gui Start the Apache Tika GUI");
out.println(" -s or --server Start the Apache Tika server");
@@ -458,6 +463,10 @@ public class TikaCLI {
out.println();
}
+ private void version() {
+ System.out.println(new Tika().toString());
+ }
+
private void displayMetModels(){
Class<?>[] modelClasses = Metadata.class.getInterfaces();
Arrays.sort(modelClasses, new Comparator<Class<?>>() {
Modified: tika/trunk/tika-core/pom.xml
URL: http://svn.apache.org/viewvc/tika/trunk/tika-core/pom.xml?rev=1188803&r1=1188802&r2=1188803&view=diff
==============================================================================
--- tika/trunk/tika-core/pom.xml (original)
+++ tika/trunk/tika-core/pom.xml Tue Oct 25 17:14:21 2011
@@ -93,6 +93,24 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <configuration>
+ <additionalClasspathElements>
+ <additionalClasspathElement>
+ ${project.build.directory}/${project.build.finalName}.jar
+ </additionalClasspathElement>
+ </additionalClasspathElements>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
Modified: tika/trunk/tika-core/src/main/java/org/apache/tika/Tika.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-core/src/main/java/org/apache/tika/Tika.java?rev=1188803&r1=1188802&r2=1188803&view=diff
==============================================================================
--- tika/trunk/tika-core/src/main/java/org/apache/tika/Tika.java (original)
+++ tika/trunk/tika-core/src/main/java/org/apache/tika/Tika.java Tue Oct 25 17:14:21 2011
@@ -22,6 +22,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.net.URL;
+import java.util.Properties;
import org.apache.tika.config.TikaConfig;
import org.apache.tika.detect.Detector;
@@ -493,4 +494,31 @@ public class Tika {
return detector;
}
+ //--------------------------------------------------------------< Object >
+
+ public String toString() {
+ String version = null;
+
+ try {
+ InputStream stream = Tika.class.getResourceAsStream(
+ "/META-INF/maven/org.apache.tika/tika-core/pom.properties");
+ if (stream != null) {
+ try {
+ Properties properties = new Properties();
+ properties.load(stream);
+ version = properties.getProperty("version");
+ } finally {
+ stream.close();
+ }
+ }
+ } catch (Exception ignore) {
+ }
+
+ if (version != null) {
+ return "Apache Tika " + version;
+ } else {
+ return "Apache Tika";
+ }
+ }
+
}
Added: tika/trunk/tika-core/src/test/java/org/apache/tika/TikaIT.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-core/src/test/java/org/apache/tika/TikaIT.java?rev=1188803&view=auto
==============================================================================
--- tika/trunk/tika-core/src/test/java/org/apache/tika/TikaIT.java (added)
+++ tika/trunk/tika-core/src/test/java/org/apache/tika/TikaIT.java Tue Oct 25 17:14:21 2011
@@ -0,0 +1,27 @@
+/*
+ * 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.tika;
+
+import junit.framework.TestCase;
+
+public class TikaIT extends TestCase {
+
+ public void testToString() {
+ System.out.println(new Tika().toString());
+ }
+
+}