You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Kevin Krumwiede <kj...@gmail.com> on 2013/04/01 05:15:06 UTC

Circular dependency and assembly plugin

I have a project -- let's call it A -- in which maven-assembly-plugin
is bound to the package phase.  It creates a zip file containing the
main artifact and all the project's dependencies.  This works as
intended.

I have a second project -- call it B -- that consists of plugins for
project A.  As part of building A, I'd like to have the assembly
plugin create a scripts/ directory in the zip file and unpack the
classes from B into it.

The problem is that B must depend on A.  So if I make the assembly
plugin depend on B, A won't have been installed yet when B is built,
creating a circular dependency.

What's the Maven way to solve this?  I'm thinking I could create the
zip file in a different project that is a peer or parent of A and B...

Thanks,
Krum

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


Re: Circular dependency and assembly plugin

Posted by Wayne Fay <wa...@gmail.com>.
> Okay, tell me if this is crazy...
>
> My assembly project is not the parent of my main project or its
> plugins.  Instead, it just depends on them.  The versions it depends

Why do you think this might be crazy? It is perfectly fine.

Wayne

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


Re: Circular dependency and assembly plugin

Posted by Kevin Krumwiede <kj...@gmail.com>.
Okay, tell me if this is crazy...

My assembly project is not the parent of my main project or its
plugins.  Instead, it just depends on them.  The versions it depends
on are identical to the assembly project's own version.  So if I want
to make a distribution zip of version 1.0 of my main project, I use
version 1.0 of the assembly POM.

This actually works really well.  My main project is called WeaponM,
and my assembly project produces a file called
WeaponM-1.0-Linux-Windows.zip that contains everything exactly where I
want it.

Here's my POM:

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>com.chalcodes.weaponm.distribution</groupId>
	<artifactId>WeaponM</artifactId>
	<packaging>pom</packaging>
	<version>1.0</version>
	<name>Weapon M Distribution</name>
	<description>Distribution packages for Weapon M</description>
	<dependencies>
		<dependency>
			<groupId>com.chalcodes.weaponm</groupId>
			<artifactId>WeaponM</artifactId>
			<version>${project.version}</version>
		</dependency>
		<dependency>
			<groupId>com.chalcodes.weaponm</groupId>
			<artifactId>WeaponM-Scripts</artifactId>
			<version>${project.version}</version>
		</dependency>
	</dependencies>
	<build>
		<plugins>
		    <!-- Linux & Windows -->
			<plugin>
				<artifactId>maven-assembly-plugin</artifactId>
				<version>2.4</version>
				<executions>
					<execution>
						<phase>package</phase>
						<goals>
							<goal>single</goal>
						</goals>
						<configuration>
							<descriptors>
								<descriptor>assembly.xml</descriptor>
							</descriptors>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
</project>

And my assembly descriptor:

<assembly>
	<id>Linux-Windows</id>
	<formats>
		<format>zip</format>
	</formats>
	<!-- put LICENSE and other misc files in root -->
	<fileSets>
		<fileSet>
			<directory>include</directory>
			<outputDirectory></outputDirectory>
		</fileSet>
	</fileSets>
	<dependencySets>
		<!-- put main jar in root, remapping its name -->
		<dependencySet>
			<useProjectArtifact>false</useProjectArtifact>
			<includes>
				<include>com.chalcodes.weaponm:WeaponM</include>
			</includes>
			<outputFileNameMapping>${artifact.artifactId}.${artifact.extension}
			</outputFileNameMapping>
		</dependencySet>
		<!-- unpack WeaponM-Scripts into scripts/ -->
		<dependencySet>
			<useProjectArtifact>false</useProjectArtifact>
			<includes>
				<include>com.chalcodes.weaponm:WeaponM-Scripts</include>
			</includes>
			<unpack>true</unpack>
			<unpackOptions>
				<excludes>
					<exclude>META-INF/**</exclude>
				</excludes>
			</unpackOptions>
			<outputDirectory>scripts</outputDirectory>
		</dependencySet>
		<!-- put deps in lib/ -->
		<dependencySet>
			<useProjectArtifact>false</useProjectArtifact>
			<excludes>
				<exclude>com.chalcodes.weaponm:WeaponM</exclude>
				<exclude>com.chalcodes.weaponm:WeaponM-Scripts</exclude>
			</excludes>
			<outputDirectory>lib</outputDirectory>
		</dependencySet>
	</dependencySets>
</assembly>

On 4/1/13, Adrien Rivard <ad...@gmail.com> wrote:
> Yes.
> Have a look at the example for the maven-assembly-plugin :
>
> http://maven.apache.org/plugins/maven-assembly-plugin/examples/multimodule/module-binary-inclusion-simple.html
>
>
> On Mon, Apr 1, 2013 at 6:03 PM, Kevin Krumwiede <kj...@gmail.com> wrote:
>
>> So if I'm thinking correctly, I could create a project C that contains
>> no code of its own, but depends on A and B and creates the
>> distribution zip.  Project C's artifact packaging would be pom, but I
>> could still attach the zip artifact to it and deploy it to my repo...
>> right?
>>
>> ~K
>>
>> On 4/1/13, Vincent Latombe <vi...@gmail.com> wrote:
>> > Hi,
>> >
>> > generally, the good answer to this kind of problem is to extract the
>> > assembly part to an artifact C, that depends on both A and B.
>> >
>> > Cheers,
>> >
>> > Vincent
>> >
>> >
>> > 2013/4/1 Baptiste MATHUS <bm...@batmat.net>
>> >
>> >> Hi,
>> >> Difficult to be sure what you're trying to do, but having circular dep
>> is
>> >> in fact unsupported and generally not a good idea from many points of
>> >> view.
>> >> I might answer that yes having a third project to break the circular
>> >> dep
>> >> is
>> >> one of the general solution to break the cycle.
>> >>
>> >> If ever possible, having a demo project github might encourage people
>> >> here
>> >> to help and propose a way to solve your problem?
>> >>
>> >> My 2 cents.
>> >>
>> >> Cheers
>> >>
>> >>
>> >> 2013/4/1 Kevin Krumwiede <kj...@gmail.com>
>> >>
>> >> > I have a project -- let's call it A -- in which
>> >> > maven-assembly-plugin
>> >> > is bound to the package phase.  It creates a zip file containing the
>> >> > main artifact and all the project's dependencies.  This works as
>> >> > intended.
>> >> >
>> >> > I have a second project -- call it B -- that consists of plugins for
>> >> > project A.  As part of building A, I'd like to have the assembly
>> >> > plugin create a scripts/ directory in the zip file and unpack the
>> >> > classes from B into it.
>> >> >
>> >> > The problem is that B must depend on A.  So if I make the assembly
>> >> > plugin depend on B, A won't have been installed yet when B is built,
>> >> > creating a circular dependency.
>> >> >
>> >> > What's the Maven way to solve this?  I'm thinking I could create the
>> >> > zip file in a different project that is a peer or parent of A and
>> >> > B...
>> >> >
>> >> > Thanks,
>> >> > Krum
>> >> >
>> >> > ---------------------------------------------------------------------
>> >> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> >> > For additional commands, e-mail: users-help@maven.apache.org
>> >> >
>> >> >
>> >>
>> >>
>> >> --
>> >> Baptiste <Batmat> MATHUS - http://batmat.net
>> >> Sauvez un arbre,
>> >> Mangez un castor !
>> >>
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>
>
> --
> Adrien Rivard
>

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


Re: Circular dependency and assembly plugin

Posted by Adrien Rivard <ad...@gmail.com>.
Yes.
Have a look at the example for the maven-assembly-plugin :

http://maven.apache.org/plugins/maven-assembly-plugin/examples/multimodule/module-binary-inclusion-simple.html


On Mon, Apr 1, 2013 at 6:03 PM, Kevin Krumwiede <kj...@gmail.com> wrote:

> So if I'm thinking correctly, I could create a project C that contains
> no code of its own, but depends on A and B and creates the
> distribution zip.  Project C's artifact packaging would be pom, but I
> could still attach the zip artifact to it and deploy it to my repo...
> right?
>
> ~K
>
> On 4/1/13, Vincent Latombe <vi...@gmail.com> wrote:
> > Hi,
> >
> > generally, the good answer to this kind of problem is to extract the
> > assembly part to an artifact C, that depends on both A and B.
> >
> > Cheers,
> >
> > Vincent
> >
> >
> > 2013/4/1 Baptiste MATHUS <bm...@batmat.net>
> >
> >> Hi,
> >> Difficult to be sure what you're trying to do, but having circular dep
> is
> >> in fact unsupported and generally not a good idea from many points of
> >> view.
> >> I might answer that yes having a third project to break the circular dep
> >> is
> >> one of the general solution to break the cycle.
> >>
> >> If ever possible, having a demo project github might encourage people
> >> here
> >> to help and propose a way to solve your problem?
> >>
> >> My 2 cents.
> >>
> >> Cheers
> >>
> >>
> >> 2013/4/1 Kevin Krumwiede <kj...@gmail.com>
> >>
> >> > I have a project -- let's call it A -- in which maven-assembly-plugin
> >> > is bound to the package phase.  It creates a zip file containing the
> >> > main artifact and all the project's dependencies.  This works as
> >> > intended.
> >> >
> >> > I have a second project -- call it B -- that consists of plugins for
> >> > project A.  As part of building A, I'd like to have the assembly
> >> > plugin create a scripts/ directory in the zip file and unpack the
> >> > classes from B into it.
> >> >
> >> > The problem is that B must depend on A.  So if I make the assembly
> >> > plugin depend on B, A won't have been installed yet when B is built,
> >> > creating a circular dependency.
> >> >
> >> > What's the Maven way to solve this?  I'm thinking I could create the
> >> > zip file in a different project that is a peer or parent of A and B...
> >> >
> >> > Thanks,
> >> > Krum
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >> > For additional commands, e-mail: users-help@maven.apache.org
> >> >
> >> >
> >>
> >>
> >> --
> >> Baptiste <Batmat> MATHUS - http://batmat.net
> >> Sauvez un arbre,
> >> Mangez un castor !
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


-- 
Adrien Rivard

Re: Circular dependency and assembly plugin

Posted by Kevin Krumwiede <kj...@gmail.com>.
So if I'm thinking correctly, I could create a project C that contains
no code of its own, but depends on A and B and creates the
distribution zip.  Project C's artifact packaging would be pom, but I
could still attach the zip artifact to it and deploy it to my repo...
right?

~K

On 4/1/13, Vincent Latombe <vi...@gmail.com> wrote:
> Hi,
>
> generally, the good answer to this kind of problem is to extract the
> assembly part to an artifact C, that depends on both A and B.
>
> Cheers,
>
> Vincent
>
>
> 2013/4/1 Baptiste MATHUS <bm...@batmat.net>
>
>> Hi,
>> Difficult to be sure what you're trying to do, but having circular dep is
>> in fact unsupported and generally not a good idea from many points of
>> view.
>> I might answer that yes having a third project to break the circular dep
>> is
>> one of the general solution to break the cycle.
>>
>> If ever possible, having a demo project github might encourage people
>> here
>> to help and propose a way to solve your problem?
>>
>> My 2 cents.
>>
>> Cheers
>>
>>
>> 2013/4/1 Kevin Krumwiede <kj...@gmail.com>
>>
>> > I have a project -- let's call it A -- in which maven-assembly-plugin
>> > is bound to the package phase.  It creates a zip file containing the
>> > main artifact and all the project's dependencies.  This works as
>> > intended.
>> >
>> > I have a second project -- call it B -- that consists of plugins for
>> > project A.  As part of building A, I'd like to have the assembly
>> > plugin create a scripts/ directory in the zip file and unpack the
>> > classes from B into it.
>> >
>> > The problem is that B must depend on A.  So if I make the assembly
>> > plugin depend on B, A won't have been installed yet when B is built,
>> > creating a circular dependency.
>> >
>> > What's the Maven way to solve this?  I'm thinking I could create the
>> > zip file in a different project that is a peer or parent of A and B...
>> >
>> > Thanks,
>> > Krum
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> > For additional commands, e-mail: users-help@maven.apache.org
>> >
>> >
>>
>>
>> --
>> Baptiste <Batmat> MATHUS - http://batmat.net
>> Sauvez un arbre,
>> Mangez un castor !
>>
>

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


Re: Circular dependency and assembly plugin

Posted by Vincent Latombe <vi...@gmail.com>.
Hi,

generally, the good answer to this kind of problem is to extract the
assembly part to an artifact C, that depends on both A and B.

Cheers,

Vincent


2013/4/1 Baptiste MATHUS <bm...@batmat.net>

> Hi,
> Difficult to be sure what you're trying to do, but having circular dep is
> in fact unsupported and generally not a good idea from many points of view.
> I might answer that yes having a third project to break the circular dep is
> one of the general solution to break the cycle.
>
> If ever possible, having a demo project github might encourage people here
> to help and propose a way to solve your problem?
>
> My 2 cents.
>
> Cheers
>
>
> 2013/4/1 Kevin Krumwiede <kj...@gmail.com>
>
> > I have a project -- let's call it A -- in which maven-assembly-plugin
> > is bound to the package phase.  It creates a zip file containing the
> > main artifact and all the project's dependencies.  This works as
> > intended.
> >
> > I have a second project -- call it B -- that consists of plugins for
> > project A.  As part of building A, I'd like to have the assembly
> > plugin create a scripts/ directory in the zip file and unpack the
> > classes from B into it.
> >
> > The problem is that B must depend on A.  So if I make the assembly
> > plugin depend on B, A won't have been installed yet when B is built,
> > creating a circular dependency.
> >
> > What's the Maven way to solve this?  I'm thinking I could create the
> > zip file in a different project that is a peer or parent of A and B...
> >
> > Thanks,
> > Krum
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
>
>
> --
> Baptiste <Batmat> MATHUS - http://batmat.net
> Sauvez un arbre,
> Mangez un castor !
>

Re: Circular dependency and assembly plugin

Posted by Baptiste MATHUS <bm...@batmat.net>.
Hi,
Difficult to be sure what you're trying to do, but having circular dep is
in fact unsupported and generally not a good idea from many points of view.
I might answer that yes having a third project to break the circular dep is
one of the general solution to break the cycle.

If ever possible, having a demo project github might encourage people here
to help and propose a way to solve your problem?

My 2 cents.

Cheers


2013/4/1 Kevin Krumwiede <kj...@gmail.com>

> I have a project -- let's call it A -- in which maven-assembly-plugin
> is bound to the package phase.  It creates a zip file containing the
> main artifact and all the project's dependencies.  This works as
> intended.
>
> I have a second project -- call it B -- that consists of plugins for
> project A.  As part of building A, I'd like to have the assembly
> plugin create a scripts/ directory in the zip file and unpack the
> classes from B into it.
>
> The problem is that B must depend on A.  So if I make the assembly
> plugin depend on B, A won't have been installed yet when B is built,
> creating a circular dependency.
>
> What's the Maven way to solve this?  I'm thinking I could create the
> zip file in a different project that is a peer or parent of A and B...
>
> Thanks,
> Krum
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


-- 
Baptiste <Batmat> MATHUS - http://batmat.net
Sauvez un arbre,
Mangez un castor !