maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Barrie Treloar <baerr...@gmail.com>
Subject Re: Assembly Plugin not seeing local repository
Date Thu, 30 Dec 2010 23:05:48 GMT
I think the problem may be in terminology, I'll try to describe it
below.  It has to do with "modules"

Let me preface this by saying I have never got modulesets working and
have found that I don't need to.
Have you read http://maven.apache.org/plugins/maven-assembly-plugin/advanced-module-set-topics.html?

Quoting:
"In these builds, project hierarchy is established through use of the
modules  section of the POM, where parent POMs specify their children
in a modules  section. Other relationships, like interdependency, also
exist within multimodule builds; however, these are beyond the scope
of this document."

In reading your other post, I quote:
"The structure I use is that each module is a separate Eclipse project
and a separate SVN project."

But you haven't provided an example of the directory layout, so I am
guessing what you are doing from the problems you are describing.

Think of "module" as a convenient way to run the same set of commands
across multiple maven projects from a parent project.
Thus you can build from the top level via "mvn install" and maven will
run install in the defined modules in the correct order (generated by
building a dependency graph).
But a "module" is not in itself a declaration of a dependency.  A
module needs to define a parent so in that sense the parent must be
built/available first.
Take a look at http://www.sonatype.com/books/mvnref-book/reference/pom-relationships-sect-multi-vs-inherit.html

I think you are most of the way there because you say in your other post:
"Since some of the modules need to be "owned" by both of the
applications, they aren't actually owned by either.  Instead, I try to
treat them as much like third-party jars as possible.  They are
installed into the local repository and then used as appropriate.
They aren't quite as stable as most third-party jars, they are
evolving to different degrees, along with the main applications."

So what you really need is the assembly sorted.  See the "copy all
dependencies" description below, which is probably what you need.
I've attached our assembly file and this is what it does:
* Create two archives a zip (which will get installed into the
repository) and a directory (which doesn't get installed into the
repo, but is useful to run easily since it is already exploded)
* includeBaseDirectory = Always create the archive in a sub directory
named after the current artifact
* Include the fileset src/main/config that contains our configuration
data - log4j, spring contexts, etc that are easier to edit if not
included in jar files
* Include the project's main artifiact by copying it from target
(there is probably a better way to do this but this is an old assembly
file - but it works)
* Copy the windows and unix scripts with filtering turned on.  This
allows me to use "java -jar
${project.artifactId}-${project.version}.jar start" as the contents of
my start scripts.
* Copy ALL dependencies to the lib/ directory.

For us, because our main artifact is being run as a standalone
application we also need to make sure the Manifest.MF has the correct
Class-Path (include config/ and lib/ directories)
This requires configuring the maven-jar-plugin.  You may need to do
the same for the ejb plugin, and perhaps the war plugin (we don't
really use them)

Hope that helps.

=== Start:pom.xml ===
...
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jar-plugin</artifactId>
          <configuration>
            <archive>
              <manifest>
                <mainClass>fqn.to.your.MainClass</mainClass>
              </manifest>
              <manifestEntries>
                <Class-Path>config/</Class-Path>
              </manifestEntries>
              <manifest>
                <addClasspath>true</addClasspath>
                <classpathPrefix>lib/</classpathPrefix>
              </manifest>
            </archive>
          </configuration>
        </plugin>
...
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-assembly-plugin</artifactId>
          <executions>
            <execution>
              <id>assembly:package</id>
              <phase>package</phase>
              <goals>
                <!--
                  Work around for http://jira.codehaus.org/browse/MASSEMBLY-97
                  as the goal should be attached.
                -->
                <goal>single</goal>
              </goals>
              <configuration>
                <descriptors>
                  <descriptor>src/main/assembly/bin.xml</descriptor>
                </descriptors>
              </configuration>
            </execution>
          </executions>
        </plugin>
=== End:pom.xml ===


=== Start:Assembly file ===
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0
http://maven.apache.org/xsd/assembly-1.1.0.xsd">
  <id>bin</id>
  <formats>
    <format>dir</format>
    <format>zip</format>
  </formats>
  <includeBaseDirectory>true</includeBaseDirectory>
  <fileSets>
    <fileSet>
      <directory>src/main/config</directory>
      <outputDirectory>config/</outputDirectory>
      <includes>
        <include>*</include>
      </includes>
      <excludes>
        <exclude>CVS</exclude>
      </excludes>
    </fileSet>
    <fileSet>
      <directory>target</directory>
      <outputDirectory></outputDirectory>
      <includes>
        <include>${artifactId}-${version}.jar</include>
      </includes>
    </fileSet>
  </fileSets>
  <files>
    <file>
      <source>src/main/scripts/start_debug.bat</source>
      <filtered>true</filtered>
    </file>
    <file>
      <source>src/main/scripts/start.bat</source>
      <filtered>true</filtered>
    </file>
    <file>
      <source>src/main/scripts/stop.bat</source>
      <filtered>true</filtered>
    </file>
    <file>
      <source>src/main/scripts/start.sh</source>
      <filtered>true</filtered>
      <fileMode>0744</fileMode>
    </file>
    <file>
      <source>src/main/scripts/stop.sh</source>
      <filtered>true</filtered>
      <fileMode>0744</fileMode>
    </file>
  </files>
  <dependencySets>
    <dependencySet>
      <outputDirectory>lib</outputDirectory>
      <unpack>false</unpack>
      <outputFileNameMapping>${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
    </dependencySet>
  </dependencySets>
</assembly>
=== End:Assembly file ===

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Mime
View raw message