Still a bit confused. The Assembly plugin's documentation says it runs a
lifecyle package before creating the assembly.  The only thing I can think
of is that "assembly:assembly" is running a separate "package" against each
and every pom.xml separately.

I did a "mvn clean verify" and everything runs.

I can now do a:

*    $ mvn clean package assembly:assembly
*
And that works. It builds exactly what I want.

Now, I want to combine in the assembly step in the package goal. I add the
following in my root pom.xml:

*        <executions>
          <execution>
            <id>Build Adinventory Package</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
*
Right? (I've attached my full root pom.xml to this email).

Run

   $ mvn clean package

And, I get the following error (entire output is in package.out file which
is enclosed):

[*INFO] Building adinventory*
*[INFO]    task-segment: [package]*
*[INFO]
------------------------------------------------------------------------*
*[INFO] [site:attach-descriptor]*
*[INFO] [assembly:single {execution: Build Adinventory Package}]*
*[INFO] Reading assembly descriptor: src/main/assembly/bin.xml*
*[INFO]
------------------------------------------------------------------------*
*[ERROR] BUILD ERROR*
*[INFO]
------------------------------------------------------------------------*
*[INFO] Failed to create assembly: Error adding file to archive:
/home/dweintraub/builds/adinventory-trunk/ear/target/adinventory.ear isn't a
file.*

Now, the adinventory.ear file that built before isn't building?

Look at the beginning of the build process:

[*INFO] Scanning for projects...
[INFO] Reactor build order:
[INFO]   adinventory-projects
[INFO]   base
[INFO]   jar
[INFO]   servlet
[INFO]   har
[INFO]   adplanning
[INFO]   adinventory
[INFO]   aimwebservices.war
[INFO]   jboss-init
[INFO]   apps.war
[INFO]   adinventory.ear
*

Wait a second, it's doing "adinventory" (the root pom.xml) before building
adinventory.ear?

How can I specify the dependency order. That the "adinventory" root project
needs to be built after adinventory.ear?

As far as I can tell, I have the right dependencies set in each pom.xml.

On Fri, Jul 10, 2009 at 12:24 PM, Stephen Connolly <
stephen.alan.conno...@gmail.com> wrote:

> 2009/7/10 David Weintraub <qazw...@gmail.com>
>
> > I actually don't want to install these jars/wars/hars into my repository
> > because they aren't really separate components. No other project of ours
> > uses them. Instead, I'm trying to build a multi-part project which
> consists
> > of two built wars, a built har, three built jars, plus all of the
> dependent
> > jar files into a single ear. No need to waste the diskspace (even though
> > "install" only puts them into my local .m2 repository)
> >
> > The problem I'm having is getting Maven to understand that the jars it
> > needs
> > aren't in the repository, but are the ones it just built earlier in the
> > project. This works beautifully when I do:
> >
> >  *$ mvn package*
> >
> > Everything builds as I expect it too. It's that when I do:
> >
> > *  $ mvn assembly:assembly*
> >
> > that everything fails.
> >
> > According to the book, the assembly:assembly goal executes all the poms
> up
> > to the package lifecycle. That sounds like it first does a:
> >
> > *   $ mvn package*
> >
> > before it attempts to create the assembly. I have no problems with that.
> > The
> > problem I have is that when the "assembly:assembly" step executes the
> > package lifecycle on all the poms, the build fails because suddenly Maven
> > cannot figure out that the jars it needs were built earlier in the build
> > process.
> >
> > Even stranger is I discovered after I sent out the email, that this:
> >
> >   *$ mvn clean package assembly:assembly
> > *
> > works! Suddenly. the assembly is built.
> >
> > Can someone explain the difference between
> > *
> >    $ mvn clean package
> >    $ mvn assembly:assembly*
> >
> > and
> >
> >  * $ mvn clean package assembly:assembly*
> >
> > Why does the first one fail because of the dependency confusion, and the
> > second one works fine?
> >
>
> The first one is two _separate_ invocations of Maven.  invocations of Maven
> can only share artifacts via the local / remote repositories... so you need
> to run up as far as at least the *install* phase to allow the artifacts be
> accessed from a subsequent invocation.
>
> so
>
> $ mvn clean install
> $ mvn assembly:assembly
>
> would work (but this is not the solution you want)
>
> The second is_one single invocation of Maven_ thus the assembly:assembly
> mojo can find the artifacts that were attached to the reactor during the
> earlier phases/mojo executions.
>
> You should always try to make sure that your build will build successfully
> when you have met the following conditions:
>
> 1. Blow away your local repository, e.g. rm -rf ~/.m2/repository
> 2. Do a clean build without populating the local repository, e.g. mvn clean
> verify
>
> This will result in your build being one of the "holy grail maven builds".
>
> Such builds nearly always "just work"(TM) with the maven release plugin,
> and
> are generally considered to be the dog's bollicks
>
> If you want your build to be such a build, then what you need to do is bind
> an execution of the assembly plugin to a phase >= package.
>
> Then all you need to do to package your project is
>
> $ mvn clean package
>
> and you are done!
>
> -Stephen
>
> >
> > On Thu, Jul 9, 2009 at 2:34 PM, Tim O'Brien <tobr...@discursive.com>
> > wrote:
> >
> > > David,
> > >
> > > It looks like
> > > com.solbright.adinventory.projects.base:jar:jar:2.1.2-SNAPSHOT
> > > can't be found in the local repository.   Instead of running
> > > assembly:assembly by itself, try:  mvn install assembly:assembly
> > >
> > > Better yet, why not just bind the assembly goal to the package phase
> > > of the project that is going to produce the assembly? like this:
> > > http://tr.im/rBBw
> > >
> > > Maybe binding to the package phase isn't the right solution for you,
> > > if you are looking for a list of phases, see  http://tr.im/rBAq
> > >
> > >
> > > On Thu, Jul 9, 2009 at 12:49 PM, David Weintraub<qazw...@gmail.com>
> > wrote:
> > > > We have a project we're converting over to Maven. The structure is a
> > bit
> > > > convoluted:
> > > >
> > > > Project Root
> > > >   apps.war: Builds apps.war
> > > >   aimwebservices: Builds aimwebservices.war
> > > >   ear: Builds adinventory.ear. Contains all other modules
> > > >   projects
> > > >      adplanning: Builds adplanning.jar
> > > >      base
> > > >         jar: Builds base.jar
> > > >         har: Builds base-hib.har
> > > >         servlet: Builds base-ui.jar
> > > >
> > > > For various reasons, we do not want the version names in any of these
> > > files
> > > > we create.
> > > >
> > > > The project is structured so that most of the components depend upon
> > > > base.jar. The aimwebservices.war and apps.war also depend upon the
> > > > base-hib.har and the base-ui.jar.
> > > >
> > > > The adinventory.ear file contains all of the built wars, hars, and
> > jars.
> > > > Each component directory contains a pom.xml.
> > > >
> > > > When I do a "mvn package", everything is built, and the final result
> is
> > > the
> > > > adinventory.ear file which contains all the jars, hars, and wars that
> > it
> > > is
> > > > suppose to have. This is what I want. Beautiful.
> > > >
> > > > The problem is I want to package this adinventory.ear file with a
> bunch
> > > of
> > > > scripts, configuration files, and other items that are in the
> > > > src/main/instance directory. I configured a assembly, and am using
> the
> > > > assembly plugin. The problem is when I run "mvn assembly:assembly", I
> > get
> > > > the following error:
> > > >
> > > > [INFO]
> > > >
> > ------------------------------------------------------------------------
> > > > [INFO] Building servlet
> > > > [INFO]
> > > >
> > ------------------------------------------------------------------------
> > > > [INFO] [resources:resources]
> > > > [WARNING] Using platform encoding (UTF-8 actually) to copy filtered
> > > > resources, i.e. build is platform dependent!
> > > > [INFO] Copying 16 resources
> > > > [INFO] snapshot
> > > com.solbright.adinventory.projects.base:jar:2.1.2-SNAPSHOT:
> > > > checking for updates from snapshot
> > > > Downloading:
> > > >
> > >
> >
> http://aladdin.solbright.com:8082/nexus/content/repositories/snapshots//com/solbright/adinventory/projects/base/jar/2.1.2-SNAPSHOT/jar-2.1.2-SNAPSHOT.jar
> > > > [INFO] Unable to find resource
> > > > 'com.solbright.adinventory.projects.base:jar:jar:2.1.2-SNAPSHOT' in
> > > > repository snapshot
> > > > (
> > http://aladdin.solbright.com:8082/nexus/content/repositories/snapshots/
> > > )
> > > > [INFO]
> > > >
> > ------------------------------------------------------------------------
> > > > [ERROR] BUILD ERROR
> > > > [INFO]
> > > >
> > ------------------------------------------------------------------------
> > > > [INFO] Failed to resolve artifact.
> > > >
> > > > Missing:
> > > > ----------
> > > > 1) com.solbright.adinventory.projects.base:jar:jar:2.1.2-SNAPSHOT
> > > >
> > > >  Try downloading the file manually from the project website.
> > > >
> > > >  Then, install it using the command:
> > > >      mvn install:install-file
> > > > -DgroupId=com.solbright.adinventory.projects.base -DartifactId=jar
> > > > -Dversion=2.1.2-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file
> > > >
> > > >  Alternatively, if you host your own repository you can deploy the
> file
> > > > there:
> > > >      mvn deploy:deploy-file
> > > > -DgroupId=com.solbright.adinventory.projects.base -DartifactId=jar
> > > > -Dversion=2.1.2-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file
> > -Durl=[url]
> > > > -DrepositoryId=[id]
> > > >
> > > >  Path to dependency:
> > > >   1)
> com.solbright.adinventory.projects.base:servlet:jar:2.1.2-SNAPSHOT
> > > >   2) com.solbright.adinventory.projects.base:jar:jar:2.1.2-SNAPSHOT
> > > >
> > > > ----------
> > > > 1 required artifact is missing.
> > > >
> > > > for artifact:
> > > >  com.solbright.adinventory.projects.base:servlet:jar:2.1.2-SNAPSHOT
> > > >
> > > > from the specified remote repositories:
> > > >  snapshot
> > > > (
> > http://aladdin.solbright.com:8082/nexus/content/repositories/snapshots/
> > > ),
> > > >  production
> > > > (
> > http://aladdin.solbright.com:8082/nexus/content/repositories/releases/
> > > ),
> > > >  Nexus (
> http://aladdin.solbright.com:8082/nexus/content/groups/public)
> > > >
> > > >
> > > >
> > > > [INFO]
> > > >
> > ------------------------------------------------------------------------
> > > > [INFO] For more information, run Maven with the -e switch
> > > > [INFO]
> > > >
> > ------------------------------------------------------------------------
> > > > [INFO] Total time: 9 seconds
> > > > [INFO] Finished at: Thu Jul 09 12:10:15 GMT-05:00 2009
> > > > [INFO] Final Memory: 29M/194M
> > > > [INFO]
> > > >
> > ------------------------------------------------------------------------
> > > >
> > > > Why does the build suddenly fail when I run the assembly:assembly
> > > lifecycle,
> > > > yet the same setup succeeds when I do "mvn package"?
> > > >
> > > > For convinence, the pom files I use are at
> > > > <http://files.getdropbox.com/u/433257/pom.tar>. I've also attached
> it
> > to
> > > > this message.
> > > >
> > > > --
> > > > David Weintraub
> > > > qazw...@gmail.com
> > > >
> > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> > > > For additional commands, e-mail: users-h...@maven.apache.org
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> > > For additional commands, e-mail: users-h...@maven.apache.org
> > >
> > >
> >
> >
> > --
> > David Weintraub
> > qazw...@gmail.com
> >
>



-- 
David Weintraub
qazw...@gmail.com
<project>
	<modelVersion>4.0.0</modelVersion>
	<properties>
	</properties>
	<groupId>com.solbright</groupId>
	<artifactId>adinventory</artifactId>
	<version>2.1.2-SNAPSHOT</version>
	<packaging>pom</packaging>
	<name>adinventory</name>
	<modules>
		<module>aimwebservices.war</module>
		<module>projects</module>
		<module>apps.war</module>
		<module>ear</module>
	</modules>
	<build>
		<plugins>
			<plugin>
				<artifactId>maven-assembly-plugin</artifactId>
				<configuration>
					<descriptors>
						<descriptor>src/main/assembly/bin.xml</descriptor>
					</descriptors>
					<appendAssemblyId>true</appendAssemblyId>
				</configuration>
				<!--
				<executions>
					<execution>
						<id>Build Adinventory Package</id>
						<phase>package</phase>
						<goals>
							<goal>single</goal>
						</goals>
					</execution>
				</executions>
				-->
			</plugin>
		</plugins>
	</build>
	<dependencyManagement>
	</dependencyManagement>
</project>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org

Reply via email to