Create a standalone source release with Maven

So far we have used Ant in my company. Whenever we wanted to send the application to the client, we run a special Ant script, which packs all our source code with all the jar and Ant libraries together with a simple batch file.

Then the client can place the files on the computer without access to the network at all (and not even Ant) and run the batch file. As long as the computer had a valid JDK, the batch script package would compile all the code using banners and create a WAR / EAR that would finally be deployed by the client to the application server.

Recently, we switched to Maven 2. But I did not find a way to do the same. I saw the Maven build plugin, but it just creates the source distributions or binary. Our script is actually a mix, because it contains our source code, but the binary banks of the libraries used (for example, Spring, Hibernate)

So, is it possible to create a standalone assembly / release / package with Maven that can be run on a computer without network access at all? This means that all libraries must be contained inside.

An added bonus if Maven itself is also contained internally, but this is not a strict requirement. The final package should be easily compiled with just one command (just for the system administrator).

I was thinking of writing my own Maven plugin for this, but I suspect that someone has already run into this.

+5
source share
5 answers

You can try this approach:

  • Use mvn ant: ant create ant build scripts from maven project
  • Make sure ant is project dependent.
  • Use assembly to build ant
    system

or plan b:

  • Use mvn ant: ant create ant build scripts from maven project
  • Make sure ant is project dependent.
  • Write a "bootstrap class" to call ant and run the construct
  • Use appassembler to create a script to build and install the environment

b , - , appassembler ant. , .

, .

+1

dev,

<plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <configuration>
        <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
        </descriptorRefs>
    </configuration>
</plugin>

mvn: assembly, yourApp-version-with-dependencies.jar . , MANIFEST.MF .

+2

, , , . . maven , ? , . , . Maven .

Ant Maven? , Ant, Maven ?

, Maven Ant, .

0

, -: jar. , ( ) .

, , . maven, , , ! .

0

... pom :

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <executions>
                <execution>
                    <id>attach-sources</id>
                    <phase>verify</phase>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

:

<profiles>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

maven install, , .

0
source

All Articles