Comments (6)
I think it's possible to use maven-antrun-plugin to execute jarjar ant task
Original comment by Dmitry.Bedrin
on 15 Jul 2009 at 2:30
from jarjar.
anybody have an example of using antrun? I'm not an expert, if I eventually
get it
to work, I'll try to post it here.
Original comment by [email protected]
on 3 Sep 2009 at 5:38
from jarjar.
jarjar already contains a maven plugin - however it seems it's rarely used so
the build has swallowed it.
I've attached a patch that fixes the build process and also adds another
parameter to the jarjar-plugin that
enables the user to configure the skipping the manifest file.
To use the maven plugin you need to install the jarjar-plugin (generated from
source by *ant mojo*) into your
local maven repository and then use it like:
<build>
<plugins>
<plugin>
<groupId>com.tonicsystems.jarjar</groupId>
<artifactId>jarjar-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jarjar</goal>
</goals>
</execution>
</executions>
<configuration>
<fromJar>target/agni-${pom.version}-distribution.jar</fromJar>
<toJar>target/agni-${pom.version}-distribution.jar</toJar>
<rulesFile>rules.txt</rulesFile>
</configuration>
</plugin>
</plugins>
</build>
The behaviour is exactly the same as calling the command line.
Original comment by [email protected]
on 17 Nov 2009 at 1:53
Attachments:
from jarjar.
@fernman: antrun sample:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<taskdef name="jarjar"
classname="com.tonicsystems.jarjar.JarJarTask"/>
<jarjar destfile="${build.directory}/${build.finalName}-jar-with-
dependencies.jar"
update="true">
<!-- Replace "x.y.." with "<groupId>.repackaged.x.y..". -->
<rule pattern="javax.annotation.**"
result="${groupId}.repackaged.@0"/>
...
</jarjar>
</tasks>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.tonicsystems.jarjar</groupId>
<artifactId>jarjar</artifactId>
<version>1.0-rc8</version>
</dependency>
</dependencies>
</plugin>
Samuel Le Berrigaud at Atlassian also came up with a Groovy-based JarJar plugin
(http://docs.atlassian.com/jarjar-maven-plugin/jarjar-mojo.html), but I kept
running
up against errors when trying to get it to work. See also
http://old.nabble.com/jarjar-td5642213.html#a19929775.
Original comment by [email protected]
on 17 Dec 2009 at 2:15
from jarjar.
Here's what I've been using successfully for a while now. This automates
everything needed to deploy a usable artifact (in terms of downloading jarjar,
etc.). This example packages guava and commons-lang into a single jar and
*-sources.jar, rewritten with package prefix. Filling in basic maven stuff
(artifact id, etc.) is left out.
<properties>
<jarjar.version>1.1</jarjar.version>
<commons-lang.version>2.5</commons-lang.version>
<guava.version>r09</guava.version>
<package.prefix>my.package.internal</package.prefix>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies-to-jarjar</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>${commons-lang.version}</version>
</artifactItem>
<artifactItem>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>${commons-lang.version}</version>
<classifier>sources</classifier>
</artifactItem>
<artifactItem>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</artifactItem>
<artifactItem>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
<classifier>sources</classifier>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<dependencies>
<dependency>
<groupId>com.googlecode.jarjar</groupId>
<artifactId>jarjar</artifactId>
<version>${jarjar.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>jarjar</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpathref="maven.compile.classpath" />
<jarjar destfile="${project.build.directory}/${project.build.finalName}.jar" update="true">
<!-- commons-lang rewrite -->
<zipfileset src="${project.build.directory}/dependency/commons-lang-${commons-lang.version}.jar" />
<rule pattern="org.apache.**" result="${package.prefix}.apache.@1" />
<!-- guava rewrite -->
<zipfileset src="${project.build.directory}/dependency/guava-${guava.version}.jar" />
<rule pattern="com.google.**" result="${package.prefix}.google.@1" />
</jarjar>
<jarjar destfile="${project.build.directory}/${project.build.finalName}-sources.jar" update="true">
<!-- commons-lang rewrite -->
<zipfileset src="${project.build.directory}/dependency/commons-lang-${commons-lang.version}-sources.jar" />
<rule pattern="org.apache.**" result="${package.prefix}.apache.@1" />
<!-- guava rewrite -->
<zipfileset src="${project.build.directory}/dependency/guava-${guava.version}-sources.jar" />
<rule pattern="com.google.**" result="${package.prefix}.google.@1" />
</jarjar>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>${project.build.directory}/${project.build.finalName}-sources.jar</file>
<type>jar</type>
<classifier>sources</classifier>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
One minor annoyance with this setup is that the source jars don't get rewritten
correctly - the imports don't get rewritten with the package prefix. It should
be fixable with a bit of ant voodoo.
Original comment by [email protected]
on 14 Apr 2011 at 3:35
from jarjar.
FYI I'm having good luck using: http://sonatype.github.com/jarjar-maven-plugin
Original comment by eric.dalquist
on 8 Jul 2011 at 4:46
from jarjar.
Related Issues (20)
- Resources repackaged but not zapped
- Upgrade to ASM 4 HOT 5
- Missing 1.2 in Maven Central HOT 3
- Fix up Export-Package in MANIFEST.MF when running jar jar.
- jarjarXXXXXX.jar files are not deleted from the temp directory
- Jarjar rules file syntax should support comments HOT 1
- Provide public API for reusing jarjar as library (e.g. in a gradle task)
- The jarjar-1.4 binary package is empty
- jarjar-1.4.jar package does not contain any class file
- Java source filenames ignored by jarjar rules that work for classes.
- jarjar should rename inner $SwitchMap$com$foo$MyEnum class generated by enum switch
- version 1.4 not published in maven
- Empty directories in jar HOT 1
- Class not included in jar but it should be
- Please add to wiki (i'll be happy to if i have permission) a command line example with conversion of jar
- jarjar fails to repackage Java8 classes
- jarjar doesn't support JDK8/JDK9 HOT 1
- Support single class files as the classpath(s) to "find"
- Jarjar not shrink jar library
- Not exported to GitHub by the maintainers HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jarjar.