aboutsummaryrefslogtreecommitdiff
path: root/common.xml
diff options
context:
space:
mode:
authorlimpbizkit <limpbizkit@d779f126-a31b-0410-b53b-1d3aecad763e>2008-06-03 09:19:35 +0000
committerlimpbizkit <limpbizkit@d779f126-a31b-0410-b53b-1d3aecad763e>2008-06-03 09:19:35 +0000
commitf716cf4566051760970b3cc9a785bbeff0520475 (patch)
treef1e671af999ef5668f56cfd4841d1c0a47a01261 /common.xml
parente81cf1badd745b8c194f8b5f65f262e3111ab33a (diff)
downloadguice-f716cf4566051760970b3cc9a785bbeff0520475.tar.gz
OSGi support - we now export OSGi metadata in our manifest.
The tool we're currently using is somewhat crufty. It attempts to parse the .java files to figure out what needs importing and exporting. As a consequence, when we import inner classes, it breaks. For example, it will do the wrong thing if it sees this statement: import com.google.inject.InjectorImpl.SingleParameterInjector; The alternative is a popular tool called BND. It's what most of the OSGi diehards use, and we might consider switching to it. But it is significantly more complex (it has its own property language) and requires .bnd files for each exported .jar. Regardless, that tool is smarter and if this strategy doesn't work out, we should adopt that tool. git-svn-id: https://google-guice.googlecode.com/svn/trunk@501 d779f126-a31b-0410-b53b-1d3aecad763e
Diffstat (limited to 'common.xml')
-rw-r--r--common.xml51
1 files changed, 45 insertions, 6 deletions
diff --git a/common.xml b/common.xml
index 4bf04161..6c62660f 100644
--- a/common.xml
+++ b/common.xml
@@ -7,7 +7,11 @@
<!-- can be overridden at the command line with -Dversion=
or in IDEA, in the ant properties dialog -->
<property name="version" value="snapshot"/>
-
+ <property name="bundle.version" value="0.0.0.snapshot"/>
+ <tstamp prefix="datestamp">
+ <format property="dateAndTime" pattern="yyyy-MM-dd H:mm"/>
+ </tstamp>
+
<target name="compile" description="Compile Java source.">
<mkdir dir="${build.dir}/classes"/>
<javac srcdir="${src.dir}"
@@ -20,7 +24,42 @@
</copy>
</target>
- <target name="test.compile"
+ <target name="manifest"
+ description="Build a jar manifest so Guice can be used as an OSGi bundle">
+ <dirname property="guice_home" file="${ant.file.common}" />
+ <taskdef name="osgiBundleInfo" classname="org.knopflerfish.ant.taskdefs.bundle.BundleInfoTask"
+ classpath="${guice_home}/lib/build/OSGiBundleInfo.jar"/>
+
+ <!-- extracts the packagelist for OSGi -->
+ <osgiBundleInfo exports="exports" imports="imports" defaultimports="com.google.inject"
+ stdimports="java.,net.sf.cglib,org.objectweb.asm,com.google.inject.InjectorImpl,com.google.inject.BindCommandProcessor">
+ <fileset dir="${basedir}">
+ <include name="src/**/*.java"/>
+ <!--<exclude name="src/com/google/inject/internal/**/*.java"/>-->
+ </fileset>
+ </osgiBundleInfo>
+
+ <mkdir dir="${build.dir}/META-INF"/>
+ <manifest file="${build.dir}/META-INF/MANIFEST.MF">
+ <attribute name="Manifest-Version" value="1.0"/>
+ <attribute name="Built-By" value="${user.name}"/>
+ <attribute name="Built-At" value="${datestamp.dateAndTime}"/>
+
+ <attribute name="Bundle-License" value="http://www.apache.org/licenses/LICENSE-2.0"/>
+ <attribute name="Import-Package" value="${imports}"/>
+ <attribute name="Export-Package" value="${exports}"/>
+ <attribute name="Bundle-Version" value="${bundle.version}"/>
+ <attribute name="Bundle-Copyright" value="Google Inc. (C) 2006"/>
+ <attribute name="Bundle-Name" value="${ant.project.name}"/>
+ <attribute name="Bundle-Description" value="Guice is a lightweight dependency injection framework for Java 5 and above"/>
+ <attribute name="Bundle-DocURL" value="http://code.google.com/p/google-guice/"/>
+ <attribute name="Bundle-Vendor" value="Google Inc."/>
+ <attribute name="Bundle-ManifestVersion" value="2"/>
+ <attribute name="Bundle-SymbolicName" value="${ant.project.name}"/>
+ </manifest>
+ </target>
+
+ <target name="test.compile"
depends="compile"
description="Compile test source.">
<mkdir dir="${build.dir}/test"/>
@@ -38,7 +77,7 @@
<target name="test"
depends="test.compile"
description="Execute JUnit tests.">
- <java fork="true"
+ <java fork="true"
classname="junit.textui.TestRunner"
failonerror="true"
taskname="junit">
@@ -47,15 +86,15 @@
<pathelement location="${build.dir}/classes"/>
<path refid="compile.classpath"/>
</classpath>
- <arg value="${test.class}"/>
+ <arg value="${test.class}"/>
</java>
</target>
-
+
<target name="clean"
description="Remove generated files.">
<delete dir="${build.dir}"/>
</target>
-
+
<target name="source.jar"
description="Create a .jar file with sources">
<mkdir dir="${build.dir}"/>