lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Isakson" <Eric.Isak...@sas.com>
Subject RE: two versioning problems with Lucene
Date Tue, 07 Dec 2004 19:50:48 GMT
Here is the API you should be using to fetch the version:

    public static void main(String[] args) throws ClassNotFoundException {

        // make sure the class loader knows about a lucene package
        Package lucenePackage = Class.forName("org.apache.lucene.util.Constants")
                .getPackage();
        System.out.println(lucenePackage.getSpecificationVersion());
        System.out.println(lucenePackage.getSpecificationTitle());

        // if you know the class loader is already supposed to know about lucene
        Package lucenePackageAnotherWay = Package.getPackage("org.apache.lucene");
        if (lucenePackageAnotherWay != null) {
            System.out.println(lucenePackageAnotherWay.getSpecificationVersion());
        }
        else {
            throw new IllegalStateException(
                    "We did not know about the org.apache.lucene package.");
        }
    }

This will also require a modification to the build.xml file for lucene to remove the Name
section around the version attributes in the manifest.

Index: build.xml
===================================================================
RCS file: /home/cvspublic/jakarta-lucene/build.xml,v
retrieving revision 1.68
diff -u -r1.68 build.xml
--- build.xml	5 Dec 2004 18:24:35 -0000	1.68
+++ build.xml	7 Dec 2004 19:47:52 -0000
@@ -178,14 +178,12 @@
       excludes="**/*.java">
       <manifest>
         <attribute name="Created-By" value="Apache Jakarta"/>
-        <section name="org/apache/lucene">
-          <attribute name="Specification-Title" value="Lucene Search Engine"/>
-          <attribute name="Specification-Version" value="${version}"/>
-          <attribute name="Specification-Vendor" value="Lucene"/>
-          <attribute name="Implementation-Title" value="org.apache.lucene"/>
-          <attribute name="Implementation-Version" value="build ${DSTAMP}"/>
-          <attribute name="Implementation-Vendor" value="Lucene"/>
-        </section>
+        <attribute name="Specification-Title" value="Lucene Search Engine"/>
+        <attribute name="Specification-Version" value="${version}"/>
+        <attribute name="Specification-Vendor" value="Lucene"/>
+        <attribute name="Implementation-Title" value="org.apache.lucene"/>
+        <attribute name="Implementation-Version" value="build ${DSTAMP}"/>
+        <attribute name="Implementation-Vendor" value="Lucene"/>
       </manifest>
     </jar>
   </target>

I don't understand manifest file processing enough to know how to specify these things properly
at some lower level than the default for the whole jar, but with that section in there, getting
the attributes for the package always returns null.

Eric 

-----Original Message-----
From: Erik Hatcher [mailto:erik@ehatchersolutions.com] 
Sent: Tuesday, December 07, 2004 2:14 PM
To: Lucene Developers List
Subject: Re: two versioning problems with Lucene 

On Dec 7, 2004, at 12:42 PM, Bill Janssen wrote:
>> We could easily store the version number in a Java static variable 
>> somewhere, but let's first explore whether the manifest information 
>> is sufficient.
>
> Will this work in the face of re-packaging?  For instance, suppose I 
> unpack the class files from the jar file and use them directly?  Or 
> then re-package them into a different jar file along with my set of 
> classes?

It would only work if you kept the manifest entries (see Lucene's build file or the manifest
itself for details).

It could be argued that if you repackage that the version number is not a reliable number,
or at least it should also be noted that its not
*exactly* the same version of Lucene as the official binary download JAR file.

	Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-dev-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-dev-help@jakarta.apache.org


Mime
View raw message