Skip to content

Commit

Permalink
Fix for issue 254.
Browse files Browse the repository at this point in the history
http://code.google.com/p/google-guice/issues/detail?id=254

This solution is unfortunate but it works... For each extension like assistedinject, we use jarjar to create a .jar with all dependencies embedded. This classes in this jar have "imports" that point at the .internal versions of our libraries. 

Then we create a second jar that's a copy of the first without the internal/ package. This way Guice only includes one copy of collections, etc.

It would be convenient if jarjar had a feature where it could remap imports without actually embedding 'em.

git-svn-id: https://google-guice.googlecode.com/svn/trunk@706 d779f126-a31b-0410-b53b-1d3aecad763e
  • Loading branch information
limpbizkit committed Nov 29, 2008
1 parent 0551b64 commit 53708f0
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 58 deletions.
36 changes: 13 additions & 23 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,12 @@
<fileset dir="${lib.dir}/build" includes="*.jar"/>
</path>

<target name="jar" depends="compile, manifest"
description="Build jar.">
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask"
classpath="lib/build/jarjar-1.0rc8.jar"/>
<mkdir dir="${build.dir}/dist"/>
<jarjar jarfile="${build.dir}/dist/guice-${version}.jar"

<target name="jar" depends="jar.withdeps, manifest" description="Build jar.">
<jar jarfile="${build.dir}/dist/guice-${version}.jar"
manifest="${build.dir}/META-INF/MANIFEST.MF">
<fileset dir="${build.dir}/classes"/>
<zipfileset src="lib/build/cglib-2.2.jar"/>
<zipfileset src="lib/build/asm-3.1.jar"/>
<zipfileset src="lib/build/google-collect-snapshot-20080530.jar"/>
<rule pattern="com.google.common.**" result="com.google.inject.internal.@1"/>
<rule pattern="net.sf.cglib.**" result="com.google.inject.internal.cglib.@1"/>
<rule pattern="org.objectweb.asm.**" result="com.google.inject.internal.asm.@1"/>
<keep pattern="com.google.inject.**"/>
</jarjar>
<zipfileset src="${build.dir}/${ant.project.name}-with-deps.jar"/>
</jar>
</target>

<target name="dist" depends="distjars, javadoc"
Expand All @@ -38,25 +28,25 @@
<ant antfile="extensions/commands/build.xml" target="distjars" inheritAll="false"/>

<copy toDir="${build.dir}/dist">
<fileset dir="servlet/build" includes="*.jar"/>
<fileset dir="servlet/build" includes="*.jar" excludes="*-with-deps.jar"/>
</copy>
<copy toDir="${build.dir}/dist">
<fileset dir="spring/build" includes="*.jar"/>
<fileset dir="spring/build" includes="*.jar" excludes="*-with-deps.jar"/>
</copy>
<copy toDir="${build.dir}/dist">
<fileset dir="struts2/plugin/build" includes="*.jar"/>
<fileset dir="struts2/plugin/build" includes="*.jar" excludes="*-with-deps.jar"/>
</copy>
<copy toDir="${build.dir}/dist">
<fileset dir="extensions/assistedinject/build" includes="*.jar"/>
<fileset dir="extensions/assistedinject/build" includes="*.jar" excludes="*-with-deps.jar"/>
</copy>
<copy toDir="${build.dir}/dist">
<fileset dir="extensions/throwingproviders/build" includes="*.jar"/>
<fileset dir="extensions/throwingproviders/build" includes="*.jar" excludes="*-with-deps.jar"/>
</copy>
<copy toDir="${build.dir}/dist">
<fileset dir="extensions/multibindings/build" includes="*.jar"/>
<fileset dir="extensions/multibindings/build" includes="*.jar" excludes="*-with-deps.jar"/>
</copy>
<copy toDir="${build.dir}/dist">
<fileset dir="extensions/commands/build" includes="*.jar"/>
<fileset dir="extensions/commands/build" includes="*.jar" excludes="*-with-deps.jar"/>
</copy>

<copy toDir="${build.dir}/dist" file="COPYING"/>
Expand All @@ -69,7 +59,7 @@
</copy>

<zip destfile="${build.dir}/guice-${version}.zip">
<zipfileset dir="${build.dir}/dist" prefix="guice-${version}"/>
<zipfileset dir="${build.dir}/dist" prefix="guice-${version}" excludes="*-src.jar"/>
</zip>
<zip destfile="${build.dir}/guice-${version}-src.zip">
<zipfileset dir="." prefix="guice-${version}-src"
Expand Down
18 changes: 18 additions & 0 deletions common.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,22 @@
depends="source.jar, jar"
description="Build jar files"/>

<target name="jar.withdeps" depends="compile"
description="Build jar with dependencies embedded.">
<mkdir dir="${build.dir}/dist"/>
<dirname property="common.basedir" file="${ant.file.common}"/>
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask"
classpath="${common.basedir}/lib/build/jarjar-1.0rc8.jar"/>
<jarjar jarfile="${build.dir}/${ant.project.name}-with-deps.jar">
<fileset dir="${build.dir}/classes"/>
<zipfileset src="${common.basedir}/lib/build/cglib-2.2.jar"/>
<zipfileset src="${common.basedir}/lib/build/asm-3.1.jar"/>
<zipfileset src="${common.basedir}/lib/build/google-collect-snapshot-20080530.jar"/>
<rule pattern="com.google.common.**" result="com.google.inject.internal.@1"/>
<rule pattern="net.sf.cglib.**" result="com.google.inject.internal.cglib.@1"/>
<rule pattern="org.objectweb.asm.**" result="com.google.inject.internal.asm.@1"/>
<keep pattern="com.google.inject.**"/>
</jarjar>
</target>

</project>
9 changes: 4 additions & 5 deletions extensions/assistedinject/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
<fileset dir="../../build/dist" includes="*.jar"/>
</path>

<target name="jar" depends="compile, manifest"
description="Build jar.">
<mkdir dir="${build.dir}"/>
<target name="jar" depends="jar.withdeps, manifest" description="Build jar.">
<jar destfile="${build.dir}/${ant.project.name}-${version}.jar"
manifest="${build.dir}/META-INF/MANIFEST.MF">
<fileset dir="${build.dir}/classes"/>
manifest="${build.dir}/META-INF/MANIFEST.MF">
<zipfileset src="${build.dir}/${ant.project.name}-with-deps.jar"
excludes="com/google/inject/internal/**"/>
</jar>
</target>

Expand Down
9 changes: 4 additions & 5 deletions extensions/commands/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
<fileset dir="../../build/dist" includes="*.jar"/>
</path>

<target name="jar" depends="compile, manifest"
description="Build jar.">
<mkdir dir="${build.dir}"/>
<target name="jar" depends="jar.withdeps, manifest" description="Build jar.">
<jar destfile="${build.dir}/${ant.project.name}-${version}.jar"
manifest="${build.dir}/META-INF/MANIFEST.MF">
<fileset dir="${build.dir}/classes"/>
manifest="${build.dir}/META-INF/MANIFEST.MF">
<zipfileset src="${build.dir}/${ant.project.name}-with-deps.jar"
excludes="com/google/inject/internal/**"/>
</jar>
</target>

Expand Down
9 changes: 4 additions & 5 deletions extensions/multibindings/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
<fileset dir="../../build/dist" includes="*.jar"/>
</path>

<target name="jar" depends="compile, manifest"
description="Build jar.">
<mkdir dir="${build.dir}"/>
<target name="jar" depends="jar.withdeps, manifest" description="Build jar.">
<jar destfile="${build.dir}/${ant.project.name}-${version}.jar"
manifest="${build.dir}/META-INF/MANIFEST.MF">
<fileset dir="${build.dir}/classes"/>
manifest="${build.dir}/META-INF/MANIFEST.MF">
<zipfileset src="${build.dir}/${ant.project.name}-with-deps.jar"
excludes="com/google/inject/internal/**"/>
</jar>
</target>

Expand Down
9 changes: 4 additions & 5 deletions extensions/throwingproviders/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
<fileset dir="../../build/dist" includes="*.jar"/>
</path>

<target name="jar" depends="compile, manifest"
description="Build jar.">
<mkdir dir="${build.dir}"/>
<target name="jar" depends="jar.withdeps, manifest" description="Build jar.">
<jar destfile="${build.dir}/${ant.project.name}-${version}.jar"
manifest="${build.dir}/META-INF/MANIFEST.MF">
<fileset dir="${build.dir}/classes"/>
manifest="${build.dir}/META-INF/MANIFEST.MF">
<zipfileset src="${build.dir}/${ant.project.name}-with-deps.jar"
excludes="com/google/inject/internal/**"/>
</jar>
</target>

Expand Down
9 changes: 4 additions & 5 deletions servlet/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
<fileset dir="../build/dist" includes="*.jar"/>
</path>

<target name="jar" depends="compile, manifest"
description="Build jar.">
<mkdir dir="${build.dir}"/>
<target name="jar" depends="jar.withdeps, manifest" description="Build jar.">
<jar destfile="${build.dir}/${ant.project.name}-${version}.jar"
manifest="${build.dir}/META-INF/MANIFEST.MF">
<fileset dir="${build.dir}/classes"/>
manifest="${build.dir}/META-INF/MANIFEST.MF">
<zipfileset src="${build.dir}/${ant.project.name}-with-deps.jar"
excludes="com/google/inject/internal/**"/>
</jar>
</target>

Expand Down
9 changes: 4 additions & 5 deletions spring/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
<fileset dir="../build/dist" includes="*.jar"/>
</path>

<target name="jar" depends="compile, manifest"
description="Build jar.">
<mkdir dir="${build.dir}"/>
<target name="jar" depends="jar.withdeps, manifest" description="Build jar.">
<jar destfile="${build.dir}/${ant.project.name}-${version}.jar"
manifest="${build.dir}/META-INF/MANIFEST.MF">
<fileset dir="${build.dir}/classes"/>
manifest="${build.dir}/META-INF/MANIFEST.MF">
<zipfileset src="${build.dir}/${ant.project.name}-with-deps.jar"
excludes="com/google/inject/internal/**"/>
</jar>
</target>

Expand Down
9 changes: 4 additions & 5 deletions struts2/plugin/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
<fileset dir="../../servlet/build" includes="*.jar"/>
</path>

<target name="jar" depends="compile, manifest"
description="Build jar.">
<mkdir dir="${build.dir}"/>
<target name="jar" depends="jar.withdeps, manifest" description="Build jar.">
<jar destfile="${build.dir}/${ant.project.name}-${version}.jar"
manifest="${build.dir}/META-INF/MANIFEST.MF">
<fileset dir="${build.dir}/classes"/>
manifest="${build.dir}/META-INF/MANIFEST.MF">
<zipfileset src="${build.dir}/${ant.project.name}-with-deps.jar"
excludes="com/google/inject/internal/**"/>
</jar>
</target>

Expand Down

0 comments on commit 53708f0

Please sign in to comment.