Monolith-Generator Maven Plugin

Maven plugin to generate self-contained versions of declared plugins and other artifacts.

License

License

APLv2.0
Categories

Categories

Maven Build Tools
GroupId

GroupId

org.commonjava.maven.plugins
ArtifactId

ArtifactId

monolith-maven-plugin
Last Version

Last Version

0.2
Release Date

Release Date

Type

Type

maven-plugin
Description

Description

Monolith-Generator Maven Plugin
Maven plugin to generate self-contained versions of declared plugins and other artifacts.
Project URL

Project URL

http://github.com/jdcasey/monolith-maven-plugin
Source Code Management

Source Code Management

http://github.com/jdcasey/monolith-maven-plugin

Download monolith-maven-plugin

How to add to project

<plugin>
    <groupId>org.commonjava.maven.plugins</groupId>
    <artifactId>monolith-maven-plugin</artifactId>
    <version>0.2</version>
</plugin>

Dependencies

compile (5)

Group / Artifact Type Version
org.apache.maven.plugins : maven-assembly-plugin jar 2.4
org.commonjava.maven.atlas : atlas-identities jar 0.7.0
commons-lang : commons-lang jar 2.4
commons-io : commons-io jar 2.4
org.sonatype.aether : aether-util jar 1.13.1

provided (3)

Group / Artifact Type Version
org.apache.maven : maven-plugin-api jar 3.0.3
org.apache.maven.plugin-tools : maven-plugin-annotations jar 3.2
org.apache.maven : maven-core jar 3.0.3

test (1)

Group / Artifact Type Version
junit : junit jar 4.10

Project Modules

There are no modules declared in this project.

Monolith Plugin for Apache Maven

This plugin reads the entries in your POM's dependencyManagement and pluginManagement sections, and generates monolithic, self-contained assemblies for each. That is, self-contained EXCEPT when they reference other monoliths declared in the current project. In the case of plugins, these assemblies are usable as drop-in replacements for the original plugin...just adjust the version to the new, qualified version, and away you go.

Why??

In cleanroom environments, it's often desirable to avoid mixing built-time / toolchain libraries with the libraries you're building. When you're doing Maven builds, it's not enough to simply keep track of the plugins you're using. Each plugin has its own dependency graph, and if that graph overlaps with something you're trying to build and ship, it can cause a chicken-and-egg scenario that makes it hard to guarantee that what you're shipping is actually the code that you built, and not something you imported for the sake of supporting a plugin.

This is where monoliths come in handy. By creating self-contained plugins (and other libraries used during a Maven build), you avoid questions of dependency-graph overlap.

How To Use

Imagine you want to create a self-contained version of the Maven Archetype Plugin. However, since you want to manage the archetypes you're planning on shipping, you actually need a self-contained version of the archetype-packaging artifact. It's possible this artifact is already self-contained...for the purposes of this example, assume it's not.

Simply create a new Maven project, and in the pom.xml add this:

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.apache.maven.archetype</groupId>
      <artifactId>archetype-packaging</artifactId>
      <version>2.2</version>
    </dependency>
  </dependencies>
</dependencyManagement>

<build>
  <pluginManagement>
    <plugins>
      <plugin>
        <artifactId>maven-archetype-plugin</artifactId>
        <version>2.2</version>
      </plugin>
    </plugins>
  </pluginManagement>
</build>

Then, issue the following:

mvn org.commonjava.maven.plugins:monolith-maven-plugin:create

When Maven finishes, the basic output (i.e. monolithic artifacts + poms) will be in the target/monoliths directory. Additionally, the plugin generates a partial local repository (by installing these artifacts and POMs) in target/installed. It also generates a partial remote repository (by deploy'ing these artifacts and POMs) in target/deployed.

Making That Last Call Simpler

If you want to simplify the Maven command line you must run, try adding the following to your settings.xml:

<pluginGroups>
  <pluginGroup>org.commonjava.maven.plugins</pluginGroup>
</pluginGroups>

Then, the command you must issue becomes:

mvn monolith:create

Versions

Version
0.2
0.1