GithubHelp home page GithubHelp logo

Comments (6)

GoogleCodeExporter avatar GoogleCodeExporter commented on July 23, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 23, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 23, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 23, 2024
@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.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 23, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 23, 2024
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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.