You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Bahri Gençsoy <ba...@gmail.com> on 2009/01/02 13:24:35 UTC

Re: Installing assembled zip of a multi-module project

With help of a colleague we finally solved our problem.

Our problem was that we were installing jars prior to package with this
command:

mvn clean install package assembly:assembly
>

This was because of the modules using others' test classes. This was
accomplished with following configuration in module's pom file:

<dependencies>
...
    <dependency>
        <groupId>com.mycompany.myapp</groupId>
        <artifactId>Api</artifactId>
        <version>3.2.1</version>
        <classifier>tests</classifier>
        <scope>test</scope>
    </dependency>
...

ABOVE IS WRONG, or at least bad practise (who knows from which mail I've
adopted this usage). We changed above to the following, as stated in the
documentation:

<dependency>
    <groupId>com.mycompany.myapp</groupId>
    <artifactId>Api</artifactId>
    <version>3.2.1</version>
    <type>test-jar</type>
    <scope>test</scope>
 </dependency>

And build command to the following:

    mvn clean package assembly:attached install

It creates and installs zip archive to local repository. assembly:assembly
does not work since it tries to create zip for parent pom immediately,
before building modules.

Thanks anyway for your time.

Bahri

On Tue, Dec 30, 2008 at 10:28 AM, Johan Lindquist <jo...@kawoo.co.uk> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi Bahri,
>
> I use dependencySets instead of modules - unfortunately never tried the
> moduleSets.
>
> A little stumped at this stage.
>
> Cheers,
>
> Johan
>
> Bahri Gençsoy wrote:
> > I cannot copy&paste, writing necessary parts by hand:
> >
> > <assembly>
> > ....
> >    <moduleSets>
> >       <moduleSet>
> >          <includes>
> >             <include>*:Api</include>
> >             <include>*:Common</include>
> >          <includes>
> >        ....
> >        </moduleSet>
> >    </moduleSets>
> > ....
> > </assembly>
> >
> >
> > On Mon, Dec 29, 2008 at 5:48 PM, Johan Lindquist <jo...@kawoo.co.uk>
> wrote:
> >
> > Hi Bahri,
> >
> > My assembly also includes dependencies on modules in the pom - what does
> > your assembly look like?
> >
> > Cheers,
> >
> > Johan
> >
> > Bahri Gençsoy wrote:
> >>>> Thanks for answer, but unfortunately it didn't work.
> >>>>
> >>>> Removing outputDirectory from assembly plugin's configuration just
> > changed
> >>>> the location of created zip file, did not install it.
> >>>>
> >>>> Appending execution gave the following error:
> >>>>
> >>>> D:\projects\MyProject\>mvn package
> >>>> ......
> >>>> [INFO] [site:attach-descriptor]
> >>>> [INFO] [assembly:attached {execution: make-assembly}]
> >>>> [INFO] Reading assembly descriptor ......./dep.xml
> >>>> [ERROR] BUILD ERROR
> >>>> [INFO] Failed to create assembly: Artifact:
> >>>> com.mycompany.myapp:Common:jar:3.2.1 (included by module) does not
> have
> > an
> >>>> artifact with a file. Please ensure the package phase is run before
> the
> >>>> assembly is generated.
> >>>>
> >>>> Please note that my original command was:
> >>>>
> >>>> mvn clean install package assembly:assembly
> >>>>
> >>>> i.e, I was explicitly calling assembly after package. I am not sure
> why
> > this
> >>>> approach was fit for me, probably was because of inter dependencies of
> > sub
> >>>> modules.
> >>>>
> >>>> Bahri
> >>>>
> >>>> On Mon, Dec 29, 2008 at 4:39 PM, Johan Lindquist <jo...@kawoo.co.uk>
> > wrote:
> >>>> Hi Bahri,
> >>>>
> >>>> The assembly plugin should install it's artifacts by default - not
> sure
> >>>> why it is not doing so in this case.
> >>>>
> >>>> Could you try running it without the output directory specified?
> >>>>
> >>>> If not working, try adding the the following (just after your
> >>>> configuration tags)
> >>>>
> >>>> <executions>
> >>>>  <execution>
> >>>>    <id>make-assembly</id>
> >>>>    <phase>package</phase>
> >>>>    <goals>
> >>>>      <goal>attached</goal>
> >>>>    </goals>
> >>>>  </execution>
> >>>> </executions>
> >>>>
> >>>> Cheers,
> >>>>
> >>>> Johan
> >>>>
> >>>> Bahri Gençsoy wrote:
> >>>>>>> I am trying to install maven-assembly-plugin's output (zip file)
> into
> >>>> local
> >>>>>>> repository but I am not successful so far.
> >>>>>>>
> >>>>>>>
> >>>>>>> Below is crippled contents of my parent pom file:
> >>>>>>>
> >>>>>>>
> >>>>>>> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
> >>>>>>> http://www.w3.org/2001/XMLSchema-instance">
> >>>>>>>
> >>>>>>>       <modelVersion>4.0.0</modelVersion>
> >>>>>>>
> >>>>>>>       <groupId>com.mycompany.myapp</groupId>
> >>>>>>>
> >>>>>>>       <artifactId>MyApplication</artifactId>
> >>>>>>>
> >>>>>>>       <packaging>pom</packaging>
> >>>>>>>
> >>>>>>>       <version>3.2.1</version>
> >>>>>>>
> >>>>>>>       <name>My Tool</name>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>       <dependencyManagement>
> >>>>>>>
> >>>>>>>             <dependencies>
> >>>>>>>
> >>>>>>>                   <dependency>
> >>>>>>>
> >>>>>>>                         <groupId>com.mycompany.myapp</groupId>
> >>>>>>>
> >>>>>>>                         <artifactId>Api</artifactId>
> >>>>>>>
> >>>>>>>                         <version>${project.version}</version>
> >>>>>>>
> >>>>>>>                   </dependency>
> >>>>>>>
> >>>>>>>                   <dependency>
> >>>>>>>
> >>>>>>>                         <groupId>com.mycompany.myapp</groupId>
> >>>>>>>
> >>>>>>>                         <artifactId>Common</artifactId>
> >>>>>>>
> >>>>>>>                         <version>${project.version}</version>
> >>>>>>>
> >>>>>>>                   </dependency>
> >>>>>>>
> >>>>>>>             </dependencies>
> >>>>>>>
> >>>>>>>       </dependencyManagement>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>       <build>
> >>>>>>>
> >>>>>>>             <plugins>
> >>>>>>>
> >>>>>>>                   <plugin>
> >>>>>>>
> >>>>>>>                         <groupId>org.apache.maven.plugins</groupId>
> >>>>>>>
> >>>>>>>
> <artifactId>maven-assembly-plugin</artifactId>
> >>>>>>>
> >>>>>>>                         <configuration>
> >>>>>>>
> >>>>>>>                              <descriptors>
> >>>>>>>
> >>>>>>>                                    <descriptor>
> >>>>>>>
> >>>>>>>
> >>>>  ${basedir}/build/assembly/dep.xml
> >>>>>>>                                    </descriptor>
> >>>>>>>
> >>>>>>>                              </descriptors>
> >>>>>>>
> >>>>>>>                              <outputDirectory>
> >>>>>>>
> >>>>>>>
>  ${project.build.directory}/release
> >>>>>>>
> >>>>>>>                              </outputDirectory>
> >>>>>>>
> >>>>>>>                         </configuration>
> >>>>>>>
> >>>>>>>                   </plugin>
> >>>>>>>
> >>>>>>>             </plugins>
> >>>>>>>
> >>>>>>>       </build>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>       <modules>
> >>>>>>>
> >>>>>>>             <module>Api</module>
> >>>>>>>
> >>>>>>>             <module>Common</module>
> >>>>>>>
> >>>>>>>       </modules>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>> </project>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>> I am building this project with following command:
> >>>>>>>
> >>>>>>> mvn clean install package assembly:assembly
> >>>>>>>
> >>>>>>>
> >>>>>>> So far, there is no problem. Maven builds sub-projects, installs
> their
> >>>> jars
> >>>>>>> and creates a zip archive in the release directory.
> >>>>>>>
> >>>>>>> Now I need to install this zip archive (the output of assembly
> plugin)
> >>>> into
> >>>>>>> local repository as well. To accomplish this task, build-helper
> plugin
> >>>>>>> seemed appropriate. Below is the added plug-ins part of the parent
> > pom.
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>> <plugin>
> >>>>>>>
> >>>>>>>       <groupId>org.codehaus.mojo</groupId>
> >>>>>>>
> >>>>>>>       <artifactId>build-helper-maven-plugin</artifactId>
> >>>>>>>
> >>>>>>>       <configuration>
> >>>>>>>
> >>>>>>>             <artifacts>
> >>>>>>>
> >>>>>>>                   <artifact>
> >>>>>>>
> >>>>>>>                         <file>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >
> ${project.build.directory}/release/${project.artifactId}-${project.version}.zip
> >>>>>>>                         </file>
> >>>>>>>
> >>>>>>>                         <type>zip</type>
> >>>>>>>
> >>>>>>>                   </artifact>
> >>>>>>>
> >>>>>>>             </artifacts>
> >>>>>>>
> >>>>>>>       </configuration>
> >>>>>>>
> >>>>>>> </plugin>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>> I have come up with following command, which seems somewhat wrong,
> but
> >>>> does
> >>>>>>> the job of installing the archive to the repository:
> >>>>>>>
> >>>>>>> mvn clean install package assembly:assembly
> > build-helper:attach-artifact
> >>>>>>> install
> >>>>>>>
> >>>>>>> However, the problem with this command is, it tries to locate zip
> > archive
> >>>> of
> >>>>>>> modules, which don't exist, thus fails the build:
> >>>>>>>
> >>>>>>> [INFO] Installing
> >>>>>>> D:\projects\MyApplicationRoot\Api\target\release\Api-3.2.1.zip to
> >>>>>>> C:\Documents and
> >>>>>>>
> >
> Settings\Administrator\.m2\repository\com\mycompany\myapp\myapplication\Api\3.2.1\Api-3.2.1.zip
> >>>>>>> [INFO]
> >>>>>>>
> > ------------------------------------------------------------------------
> >>>>>>> [ERROR] BUILD ERROR
> >>>>>>>
> >>>>>>> [INFO]
> >>>>>>>
> > ------------------------------------------------------------------------
> >>>>>>> [INFO] Error installing artifact: File
> >>>>>>> D:\projects\MyApplicationRoot\Api\target\release\Api-3.2.1.zip does
> > not
> >>>>>>> exist
> >>>>>>>
> >>>>>>>
> >>>>>>> I guess I might be:
> >>>>>>>
> >>>>>>>    - Using wrong plugin?
> >>>>>>>    - Using wrong command?
> >>>>>>>    - Shooting the moon?
> >>>>>>>
> >>>>>>> Any help is appreciated, thanks in advance.
> >>>>>>>  Bahri
> >>>>>>>
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >>>>>
> >>
> - ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> >>
> >>
>
> - --
> you too?
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFJWduZpHYnED7evioRAlpsAJ0Upzov2aoP2L3R+mUP0dIZXJ8XjQCfZl8K
> PdLpC1I8J02ZyO182GxZqqE=
> =ECFM
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>