You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by QL 983 <fr...@gmail.com> on 2012/04/17 11:44:03 UTC

Question about Maven Assembly Plugin

Hi.

I am writing a little tutorial in my company about the use of the Maven
Assembly Plugin to build a executable jar, with all dependencies inside it.

When I was using Maven 2.2.1, the following would done the job:

...
 <build>
  <plugins>
...
   <plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <configuration>
     <source>1.5</source>
     <target>1.5</target>
     <archive>
      <manifest>
       <mainClass>com.company.classX</mainClass>
      </manifest>
     </archive>
     <descriptorRefs>
      <descriptorRef>jar-with-dependencies</descriptorRef>
     </descriptorRefs>
    </configuration>
   </plugin>
...
  </plugins>
 </build>
...


This time, however, I am using Maven 3.0.4, and I am getting this warning:


[WARNING] Cannot include project artifact: com.company.class; it doesn't
have an associated file or directory.


I read the plugin's documentation, but could not figure what is the problem.

Here is the complete pom I am using now:


<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.company</groupId>
  <artifactId>tutorial</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>
  <name>someName</name>
  <url>http://maven.apache.org</url>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 <compileSource>1.6</compileSource>
  </properties>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.0.2</version>
        <configuration>
          <source>${compileSource}</source>
    <target>${compileSource}</target>
        </configuration>
      </plugin>

 <plugin>
 <artifactId>maven-assembly-plugin</artifactId>
        <version>2.3</version>
        <configuration>

   <archive>
    <manifest>
     <mainClass>com.company.classX</mainClass>
    </manifest>
   </archive>
          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>
        </configuration>
        <executions>
          <execution>
            <id>make-assembly</id> <!-- this is used for inheritance merges
-->
            <phase>package</phase> <!-- bind to the packaging phase -->
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
 </plugin>

    </plugins>
  </build>

  <dependencies>

 <dependency>
  <groupId>org.apache.httpcomponents</groupId>
  <artifactId>httpclient</artifactId>
  <version>4.1.3</version>
 </dependency>

  </dependencies>

</project>


 The resulting jar contains httpclient and all the dependencies it has, but
no code of mine is added in the jar, and I get this output in command line:


D:\projetos\tutorial>mvn assembly:single
[INFO] Scanning for projects...
[INFO]
[INFO]
------------------------------------------------------------------------
[INFO] Building tutorial 1.0-SNAPSHOT
[INFO]
------------------------------------------------------------------------
[INFO]
[INFO] --- maven-assembly-plugin:2.3:single (default-cli) @ tutorial ---
*[WARNING] Cannot include project artifact:
com.company:tutorial:jar:1.0-SNAPSHOT; it doesn't have an associated file
or directory.*
[INFO] META-INF/ already added, skipping
[INFO] META-INF/MANIFEST.MF already added, skipping
[INFO] org/ already added, skipping
[INFO] org/apache/ already added, skipping
[INFO] org/apache/http/ already added, skipping
[INFO] org/apache/http/impl/ already added, skipping
[INFO] META-INF/NOTICE.txt already added, skipping
[INFO] META-INF/LICENSE.txt already added, skipping
[INFO] META-INF/maven/ already added, skipping
[INFO] META-INF/maven/org.apache.httpcomponents/ already added, skipping
[INFO] META-INF/ already added, skipping
[INFO] META-INF/MANIFEST.MF already added, skipping
[INFO] org/ already added, skipping
[INFO] org/apache/ already added, skipping
[INFO] META-INF/maven/ already added, skipping
[INFO] META-INF/ already added, skipping
[INFO] META-INF/MANIFEST.MF already added, skipping
[INFO] org/ already added, skipping
[INFO] org/apache/ already added, skipping
[INFO] org/apache/commons/ already added, skipping
[INFO] META-INF/LICENSE.txt already added, skipping
[INFO] META-INF/NOTICE.txt already added, skipping
[INFO] META-INF/maven/ already added, skipping
[INFO] Building jar:
D:\projetos\tutorial\target\tutorial-1.0-SNAPSHOT-jar-with-dependencies.jar
[INFO] META-INF/ already added, skipping
[INFO] META-INF/MANIFEST.MF already added, skipping
[INFO] org/ already added, skipping
[INFO] org/apache/ already added, skipping
[INFO] org/apache/http/ already added, skipping
[INFO] org/apache/http/impl/ already added, skipping
[INFO] META-INF/NOTICE.txt already added, skipping
[INFO] META-INF/LICENSE.txt already added, skipping
[INFO] META-INF/maven/ already added, skipping
[INFO] META-INF/maven/org.apache.httpcomponents/ already added, skipping
[INFO] META-INF/ already added, skipping
[INFO] META-INF/MANIFEST.MF already added, skipping
[INFO] org/ already added, skipping
[INFO] org/apache/ already added, skipping
[INFO] META-INF/maven/ already added, skipping
[INFO] META-INF/ already added, skipping
[INFO] META-INF/MANIFEST.MF already added, skipping
[INFO] org/ already added, skipping
[INFO] org/apache/ already added, skipping
[INFO] org/apache/commons/ already added, skipping
[INFO] META-INF/LICENSE.txt already added, skipping
[INFO] META-INF/NOTICE.txt already added, skipping
[INFO] META-INF/maven/ already added, skipping
[INFO]
------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 1.437s
[INFO] Finished at: Tue Apr 17 06:38:42 BRT 2012
[INFO] Final Memory: 4M/15M
[INFO]
------------------------------------------------------------------------
D:\projetos\tutorial>


 Does anyone please have any idea? I am getting crazy with this problem.

Thank you very much,
Kind regards,

QL.

Re: Question about Maven Assembly Plugin

Posted by Curtis Rueden <ct...@wisc.edu>.
Hi QL,

Could you please supply me with an example of a executable
> jar-with-dependencies?
>


We build an executable JAR-with-dependencies using the assembly plugin.

There are two issues:

1) Including all the dependencies in the JAR. In your assembly descriptor,
use:

  <dependencySets>
    <dependencySet>
      <outputDirectory>/</outputDirectory>
      <unpack>true</unpack>
      <scope>runtime</scope>
    </dependencySet>
  </dependencySets>


2) Setting the main class for the combined JAR. In your POM, use:

            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
              <descriptors>
                <descriptor>src/main/assembly/all.xml</descriptor>
              </descriptors>
              <finalName>imagej-${project.version}</finalName>
              <archive>
                <manifest>
                  <mainClass>imagej.Main</mainClass>
                </manifest>
              </archive>
            </configuration>

If you want a working example, you can check the ImageJ2 codebase here:
    https://github.com/imagej/imagej/blob/master/ui/app/pom.xml

https://github.com/imagej/imagej/blob/master/ui/app/src/main/assembly/all.xml

Just be warned there is a fair bit of nastiness and complexity in there
that is very unlikely to be necessary for your use case.

HTH,
Curtis


On Tue, Apr 17, 2012 at 5:23 PM, QL 983 <fr...@gmail.com> wrote:

> Hi, Anders; thank you for your answer! I tried using useProjectArtifact
> false, but it did not work.
>
> Could you please supply me with an example of a executable
> jar-with-dependencies?
>
> Kind regards,
>
> QL
>
> On Tue, Apr 17, 2012 at 8:06 AM, Anders Hammar <an...@hammar.net> wrote:
>
> > I think the solution is to set useProjectArtifact to false in the
> > assembly descriptor.
> >
> > /Anders
> >
> > On Tue, Apr 17, 2012 at 11:44, QL 983 <fr...@gmail.com> wrote:
> > > Hi.
> > >
> > > I am writing a little tutorial in my company about the use of the Maven
> > > Assembly Plugin to build a executable jar, with all dependencies inside
> > it.
> > >
> > > When I was using Maven 2.2.1, the following would done the job:
> > >
> > > ...
> > >  <build>
> > >  <plugins>
> > > ...
> > >   <plugin>
> > >    <artifactId>maven-assembly-plugin</artifactId>
> > >    <configuration>
> > >     <source>1.5</source>
> > >     <target>1.5</target>
> > >     <archive>
> > >      <manifest>
> > >       <mainClass>com.company.classX</mainClass>
> > >      </manifest>
> > >     </archive>
> > >     <descriptorRefs>
> > >      <descriptorRef>jar-with-dependencies</descriptorRef>
> > >     </descriptorRefs>
> > >    </configuration>
> > >   </plugin>
> > > ...
> > >  </plugins>
> > >  </build>
> > > ...
> > >
> > >
> > > This time, however, I am using Maven 3.0.4, and I am getting this
> > warning:
> > >
> > >
> > > [WARNING] Cannot include project artifact: com.company.class; it
> doesn't
> > > have an associated file or directory.
> > >
> > >
> > > I read the plugin's documentation, but could not figure what is the
> > problem.
> > >
> > > Here is the complete pom I am using now:
> > >
> > >
> > > <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.company</groupId>
> > >  <artifactId>tutorial</artifactId>
> > >  <version>1.0-SNAPSHOT</version>
> > >  <packaging>jar</packaging>
> > >  <name>someName</name>
> > >  <url>http://maven.apache.org</url>
> > >  <properties>
> > >    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
> > >  <compileSource>1.6</compileSource>
> > >  </properties>
> > >  <build>
> > >    <plugins>
> > >      <plugin>
> > >        <artifactId>maven-compiler-plugin</artifactId>
> > >        <version>2.0.2</version>
> > >        <configuration>
> > >          <source>${compileSource}</source>
> > >    <target>${compileSource}</target>
> > >        </configuration>
> > >      </plugin>
> > >
> > >  <plugin>
> > >  <artifactId>maven-assembly-plugin</artifactId>
> > >        <version>2.3</version>
> > >        <configuration>
> > >
> > >   <archive>
> > >    <manifest>
> > >     <mainClass>com.company.classX</mainClass>
> > >    </manifest>
> > >   </archive>
> > >          <descriptorRefs>
> > >            <descriptorRef>jar-with-dependencies</descriptorRef>
> > >          </descriptorRefs>
> > >        </configuration>
> > >        <executions>
> > >          <execution>
> > >            <id>make-assembly</id> <!-- this is used for inheritance
> > merges
> > > -->
> > >            <phase>package</phase> <!-- bind to the packaging phase -->
> > >            <goals>
> > >              <goal>single</goal>
> > >            </goals>
> > >          </execution>
> > >        </executions>
> > >  </plugin>
> > >
> > >    </plugins>
> > >  </build>
> > >
> > >  <dependencies>
> > >
> > >  <dependency>
> > >  <groupId>org.apache.httpcomponents</groupId>
> > >  <artifactId>httpclient</artifactId>
> > >  <version>4.1.3</version>
> > >  </dependency>
> > >
> > >  </dependencies>
> > >
> > > </project>
> > >
> > >
> > >  The resulting jar contains httpclient and all the dependencies it has,
> > but
> > > no code of mine is added in the jar, and I get this output in command
> > line:
> > >
> > >
> > > D:\projetos\tutorial>mvn assembly:single
> > > [INFO] Scanning for projects...
> > > [INFO]
> > > [INFO]
> > >
> ------------------------------------------------------------------------
> > > [INFO] Building tutorial 1.0-SNAPSHOT
> > > [INFO]
> > >
> ------------------------------------------------------------------------
> > > [INFO]
> > > [INFO] --- maven-assembly-plugin:2.3:single (default-cli) @ tutorial
> ---
> > > *[WARNING] Cannot include project artifact:
> > > com.company:tutorial:jar:1.0-SNAPSHOT; it doesn't have an associated
> file
> > > or directory.*
> > > [INFO] META-INF/ already added, skipping
> > > [INFO] META-INF/MANIFEST.MF already added, skipping
> > > [INFO] org/ already added, skipping
> > > [INFO] org/apache/ already added, skipping
> > > [INFO] org/apache/http/ already added, skipping
> > > [INFO] org/apache/http/impl/ already added, skipping
> > > [INFO] META-INF/NOTICE.txt already added, skipping
> > > [INFO] META-INF/LICENSE.txt already added, skipping
> > > [INFO] META-INF/maven/ already added, skipping
> > > [INFO] META-INF/maven/org.apache.httpcomponents/ already added,
> skipping
> > > [INFO] META-INF/ already added, skipping
> > > [INFO] META-INF/MANIFEST.MF already added, skipping
> > > [INFO] org/ already added, skipping
> > > [INFO] org/apache/ already added, skipping
> > > [INFO] META-INF/maven/ already added, skipping
> > > [INFO] META-INF/ already added, skipping
> > > [INFO] META-INF/MANIFEST.MF already added, skipping
> > > [INFO] org/ already added, skipping
> > > [INFO] org/apache/ already added, skipping
> > > [INFO] org/apache/commons/ already added, skipping
> > > [INFO] META-INF/LICENSE.txt already added, skipping
> > > [INFO] META-INF/NOTICE.txt already added, skipping
> > > [INFO] META-INF/maven/ already added, skipping
> > > [INFO] Building jar:
> > >
> >
> D:\projetos\tutorial\target\tutorial-1.0-SNAPSHOT-jar-with-dependencies.jar
> > > [INFO] META-INF/ already added, skipping
> > > [INFO] META-INF/MANIFEST.MF already added, skipping
> > > [INFO] org/ already added, skipping
> > > [INFO] org/apache/ already added, skipping
> > > [INFO] org/apache/http/ already added, skipping
> > > [INFO] org/apache/http/impl/ already added, skipping
> > > [INFO] META-INF/NOTICE.txt already added, skipping
> > > [INFO] META-INF/LICENSE.txt already added, skipping
> > > [INFO] META-INF/maven/ already added, skipping
> > > [INFO] META-INF/maven/org.apache.httpcomponents/ already added,
> skipping
> > > [INFO] META-INF/ already added, skipping
> > > [INFO] META-INF/MANIFEST.MF already added, skipping
> > > [INFO] org/ already added, skipping
> > > [INFO] org/apache/ already added, skipping
> > > [INFO] META-INF/maven/ already added, skipping
> > > [INFO] META-INF/ already added, skipping
> > > [INFO] META-INF/MANIFEST.MF already added, skipping
> > > [INFO] org/ already added, skipping
> > > [INFO] org/apache/ already added, skipping
> > > [INFO] org/apache/commons/ already added, skipping
> > > [INFO] META-INF/LICENSE.txt already added, skipping
> > > [INFO] META-INF/NOTICE.txt already added, skipping
> > > [INFO] META-INF/maven/ already added, skipping
> > > [INFO]
> > >
> ------------------------------------------------------------------------
> > > [INFO] BUILD SUCCESS
> > > [INFO]
> > >
> ------------------------------------------------------------------------
> > > [INFO] Total time: 1.437s
> > > [INFO] Finished at: Tue Apr 17 06:38:42 BRT 2012
> > > [INFO] Final Memory: 4M/15M
> > > [INFO]
> > >
> ------------------------------------------------------------------------
> > > D:\projetos\tutorial>
> > >
> > >
> > >  Does anyone please have any idea? I am getting crazy with this
> problem.
> > >
> > > Thank you very much,
> > > Kind regards,
> > >
> > > QL.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
>

Re: Question about Maven Assembly Plugin

Posted by Anders Hammar <an...@hammar.net>.
OK. If you post your project somewhere I could give it a spin and see
what's wrong.

/Anders

On Wed, Apr 18, 2012 at 11:43, QL 983 <fr...@gmail.com> wrote:
> Hi, Anders.
> Thank you again.
>
> I think this example works with older plugin's versions, because it is very
> like the one I used with Maven 2.2.1. I searched google and read all
> documentation in the plugin's site before asking, and, as I could not
> resolve the issue, I am trying the mailing list.
>
> Kind regards,
>
> QL
>
>
>
> On Wed, Apr 18, 2012 at 4:43 AM, Anders Hammar <an...@hammar.net> wrote:
>
>> I get several hits with Google. For example:
>>
>>
>> http://www.sonatype.com/people/2009/08/how-to-make-an-executable-jar-in-maven/
>> (this one does not talk about useProjectArtifact=false, so I guess it
>> is not necessary)
>>
>> If someone has a real example with a link, please provide. I don't.
>>
>> /Anders
>>
>> On Wed, Apr 18, 2012 at 00:23, QL 983 <fr...@gmail.com> wrote:
>> > Hi, Anders; thank you for your answer! I tried using useProjectArtifact
>> > false, but it did not work.
>> >
>> > Could you please supply me with an example of a executable
>> > jar-with-dependencies?
>> >
>> > Kind regards,
>> >
>> > QL
>> >
>> > On Tue, Apr 17, 2012 at 8:06 AM, Anders Hammar <an...@hammar.net>
>> wrote:
>> >
>> >> I think the solution is to set useProjectArtifact to false in the
>> >> assembly descriptor.
>> >>
>> >> /Anders
>> >>
>> >> On Tue, Apr 17, 2012 at 11:44, QL 983 <fr...@gmail.com> wrote:
>> >> > Hi.
>> >> >
>> >> > I am writing a little tutorial in my company about the use of the
>> Maven
>> >> > Assembly Plugin to build a executable jar, with all dependencies
>> inside
>> >> it.
>> >> >
>> >> > When I was using Maven 2.2.1, the following would done the job:
>> >> >
>> >> > ...
>> >> >  <build>
>> >> >  <plugins>
>> >> > ...
>> >> >   <plugin>
>> >> >    <artifactId>maven-assembly-plugin</artifactId>
>> >> >    <configuration>
>> >> >     <source>1.5</source>
>> >> >     <target>1.5</target>
>> >> >     <archive>
>> >> >      <manifest>
>> >> >       <mainClass>com.company.classX</mainClass>
>> >> >      </manifest>
>> >> >     </archive>
>> >> >     <descriptorRefs>
>> >> >      <descriptorRef>jar-with-dependencies</descriptorRef>
>> >> >     </descriptorRefs>
>> >> >    </configuration>
>> >> >   </plugin>
>> >> > ...
>> >> >  </plugins>
>> >> >  </build>
>> >> > ...
>> >> >
>> >> >
>> >> > This time, however, I am using Maven 3.0.4, and I am getting this
>> >> warning:
>> >> >
>> >> >
>> >> > [WARNING] Cannot include project artifact: com.company.class; it
>> doesn't
>> >> > have an associated file or directory.
>> >> >
>> >> >
>> >> > I read the plugin's documentation, but could not figure what is the
>> >> problem.
>> >> >
>> >> > Here is the complete pom I am using now:
>> >> >
>> >> >
>> >> > <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.company</groupId>
>> >> >  <artifactId>tutorial</artifactId>
>> >> >  <version>1.0-SNAPSHOT</version>
>> >> >  <packaging>jar</packaging>
>> >> >  <name>someName</name>
>> >> >  <url>http://maven.apache.org</url>
>> >> >  <properties>
>> >> >    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>> >> >  <compileSource>1.6</compileSource>
>> >> >  </properties>
>> >> >  <build>
>> >> >    <plugins>
>> >> >      <plugin>
>> >> >        <artifactId>maven-compiler-plugin</artifactId>
>> >> >        <version>2.0.2</version>
>> >> >        <configuration>
>> >> >          <source>${compileSource}</source>
>> >> >    <target>${compileSource}</target>
>> >> >        </configuration>
>> >> >      </plugin>
>> >> >
>> >> >  <plugin>
>> >> >  <artifactId>maven-assembly-plugin</artifactId>
>> >> >        <version>2.3</version>
>> >> >        <configuration>
>> >> >
>> >> >   <archive>
>> >> >    <manifest>
>> >> >     <mainClass>com.company.classX</mainClass>
>> >> >    </manifest>
>> >> >   </archive>
>> >> >          <descriptorRefs>
>> >> >            <descriptorRef>jar-with-dependencies</descriptorRef>
>> >> >          </descriptorRefs>
>> >> >        </configuration>
>> >> >        <executions>
>> >> >          <execution>
>> >> >            <id>make-assembly</id> <!-- this is used for inheritance
>> >> merges
>> >> > -->
>> >> >            <phase>package</phase> <!-- bind to the packaging phase -->
>> >> >            <goals>
>> >> >              <goal>single</goal>
>> >> >            </goals>
>> >> >          </execution>
>> >> >        </executions>
>> >> >  </plugin>
>> >> >
>> >> >    </plugins>
>> >> >  </build>
>> >> >
>> >> >  <dependencies>
>> >> >
>> >> >  <dependency>
>> >> >  <groupId>org.apache.httpcomponents</groupId>
>> >> >  <artifactId>httpclient</artifactId>
>> >> >  <version>4.1.3</version>
>> >> >  </dependency>
>> >> >
>> >> >  </dependencies>
>> >> >
>> >> > </project>
>> >> >
>> >> >
>> >> >  The resulting jar contains httpclient and all the dependencies it
>> has,
>> >> but
>> >> > no code of mine is added in the jar, and I get this output in command
>> >> line:
>> >> >
>> >> >
>> >> > D:\projetos\tutorial>mvn assembly:single
>> >> > [INFO] Scanning for projects...
>> >> > [INFO]
>> >> > [INFO]
>> >> >
>> ------------------------------------------------------------------------
>> >> > [INFO] Building tutorial 1.0-SNAPSHOT
>> >> > [INFO]
>> >> >
>> ------------------------------------------------------------------------
>> >> > [INFO]
>> >> > [INFO] --- maven-assembly-plugin:2.3:single (default-cli) @ tutorial
>> ---
>> >> > *[WARNING] Cannot include project artifact:
>> >> > com.company:tutorial:jar:1.0-SNAPSHOT; it doesn't have an associated
>> file
>> >> > or directory.*
>> >> > [INFO] META-INF/ already added, skipping
>> >> > [INFO] META-INF/MANIFEST.MF already added, skipping
>> >> > [INFO] org/ already added, skipping
>> >> > [INFO] org/apache/ already added, skipping
>> >> > [INFO] org/apache/http/ already added, skipping
>> >> > [INFO] org/apache/http/impl/ already added, skipping
>> >> > [INFO] META-INF/NOTICE.txt already added, skipping
>> >> > [INFO] META-INF/LICENSE.txt already added, skipping
>> >> > [INFO] META-INF/maven/ already added, skipping
>> >> > [INFO] META-INF/maven/org.apache.httpcomponents/ already added,
>> skipping
>> >> > [INFO] META-INF/ already added, skipping
>> >> > [INFO] META-INF/MANIFEST.MF already added, skipping
>> >> > [INFO] org/ already added, skipping
>> >> > [INFO] org/apache/ already added, skipping
>> >> > [INFO] META-INF/maven/ already added, skipping
>> >> > [INFO] META-INF/ already added, skipping
>> >> > [INFO] META-INF/MANIFEST.MF already added, skipping
>> >> > [INFO] org/ already added, skipping
>> >> > [INFO] org/apache/ already added, skipping
>> >> > [INFO] org/apache/commons/ already added, skipping
>> >> > [INFO] META-INF/LICENSE.txt already added, skipping
>> >> > [INFO] META-INF/NOTICE.txt already added, skipping
>> >> > [INFO] META-INF/maven/ already added, skipping
>> >> > [INFO] Building jar:
>> >> >
>> >>
>> D:\projetos\tutorial\target\tutorial-1.0-SNAPSHOT-jar-with-dependencies.jar
>> >> > [INFO] META-INF/ already added, skipping
>> >> > [INFO] META-INF/MANIFEST.MF already added, skipping
>> >> > [INFO] org/ already added, skipping
>> >> > [INFO] org/apache/ already added, skipping
>> >> > [INFO] org/apache/http/ already added, skipping
>> >> > [INFO] org/apache/http/impl/ already added, skipping
>> >> > [INFO] META-INF/NOTICE.txt already added, skipping
>> >> > [INFO] META-INF/LICENSE.txt already added, skipping
>> >> > [INFO] META-INF/maven/ already added, skipping
>> >> > [INFO] META-INF/maven/org.apache.httpcomponents/ already added,
>> skipping
>> >> > [INFO] META-INF/ already added, skipping
>> >> > [INFO] META-INF/MANIFEST.MF already added, skipping
>> >> > [INFO] org/ already added, skipping
>> >> > [INFO] org/apache/ already added, skipping
>> >> > [INFO] META-INF/maven/ already added, skipping
>> >> > [INFO] META-INF/ already added, skipping
>> >> > [INFO] META-INF/MANIFEST.MF already added, skipping
>> >> > [INFO] org/ already added, skipping
>> >> > [INFO] org/apache/ already added, skipping
>> >> > [INFO] org/apache/commons/ already added, skipping
>> >> > [INFO] META-INF/LICENSE.txt already added, skipping
>> >> > [INFO] META-INF/NOTICE.txt already added, skipping
>> >> > [INFO] META-INF/maven/ already added, skipping
>> >> > [INFO]
>> >> >
>> ------------------------------------------------------------------------
>> >> > [INFO] BUILD SUCCESS
>> >> > [INFO]
>> >> >
>> ------------------------------------------------------------------------
>> >> > [INFO] Total time: 1.437s
>> >> > [INFO] Finished at: Tue Apr 17 06:38:42 BRT 2012
>> >> > [INFO] Final Memory: 4M/15M
>> >> > [INFO]
>> >> >
>> ------------------------------------------------------------------------
>> >> > D:\projetos\tutorial>
>> >> >
>> >> >
>> >> >  Does anyone please have any idea? I am getting crazy with this
>> problem.
>> >> >
>> >> > Thank you very much,
>> >> > Kind regards,
>> >> >
>> >> > QL.
>> >>
>> >> ---------------------------------------------------------------------
>> >> 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
>>
>>

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


Re: Question about Maven Assembly Plugin

Posted by QL 983 <fr...@gmail.com>.
Hi, Anders.
Thank you again.

I think this example works with older plugin's versions, because it is very
like the one I used with Maven 2.2.1. I searched google and read all
documentation in the plugin's site before asking, and, as I could not
resolve the issue, I am trying the mailing list.

Kind regards,

QL



On Wed, Apr 18, 2012 at 4:43 AM, Anders Hammar <an...@hammar.net> wrote:

> I get several hits with Google. For example:
>
>
> http://www.sonatype.com/people/2009/08/how-to-make-an-executable-jar-in-maven/
> (this one does not talk about useProjectArtifact=false, so I guess it
> is not necessary)
>
> If someone has a real example with a link, please provide. I don't.
>
> /Anders
>
> On Wed, Apr 18, 2012 at 00:23, QL 983 <fr...@gmail.com> wrote:
> > Hi, Anders; thank you for your answer! I tried using useProjectArtifact
> > false, but it did not work.
> >
> > Could you please supply me with an example of a executable
> > jar-with-dependencies?
> >
> > Kind regards,
> >
> > QL
> >
> > On Tue, Apr 17, 2012 at 8:06 AM, Anders Hammar <an...@hammar.net>
> wrote:
> >
> >> I think the solution is to set useProjectArtifact to false in the
> >> assembly descriptor.
> >>
> >> /Anders
> >>
> >> On Tue, Apr 17, 2012 at 11:44, QL 983 <fr...@gmail.com> wrote:
> >> > Hi.
> >> >
> >> > I am writing a little tutorial in my company about the use of the
> Maven
> >> > Assembly Plugin to build a executable jar, with all dependencies
> inside
> >> it.
> >> >
> >> > When I was using Maven 2.2.1, the following would done the job:
> >> >
> >> > ...
> >> >  <build>
> >> >  <plugins>
> >> > ...
> >> >   <plugin>
> >> >    <artifactId>maven-assembly-plugin</artifactId>
> >> >    <configuration>
> >> >     <source>1.5</source>
> >> >     <target>1.5</target>
> >> >     <archive>
> >> >      <manifest>
> >> >       <mainClass>com.company.classX</mainClass>
> >> >      </manifest>
> >> >     </archive>
> >> >     <descriptorRefs>
> >> >      <descriptorRef>jar-with-dependencies</descriptorRef>
> >> >     </descriptorRefs>
> >> >    </configuration>
> >> >   </plugin>
> >> > ...
> >> >  </plugins>
> >> >  </build>
> >> > ...
> >> >
> >> >
> >> > This time, however, I am using Maven 3.0.4, and I am getting this
> >> warning:
> >> >
> >> >
> >> > [WARNING] Cannot include project artifact: com.company.class; it
> doesn't
> >> > have an associated file or directory.
> >> >
> >> >
> >> > I read the plugin's documentation, but could not figure what is the
> >> problem.
> >> >
> >> > Here is the complete pom I am using now:
> >> >
> >> >
> >> > <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.company</groupId>
> >> >  <artifactId>tutorial</artifactId>
> >> >  <version>1.0-SNAPSHOT</version>
> >> >  <packaging>jar</packaging>
> >> >  <name>someName</name>
> >> >  <url>http://maven.apache.org</url>
> >> >  <properties>
> >> >    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
> >> >  <compileSource>1.6</compileSource>
> >> >  </properties>
> >> >  <build>
> >> >    <plugins>
> >> >      <plugin>
> >> >        <artifactId>maven-compiler-plugin</artifactId>
> >> >        <version>2.0.2</version>
> >> >        <configuration>
> >> >          <source>${compileSource}</source>
> >> >    <target>${compileSource}</target>
> >> >        </configuration>
> >> >      </plugin>
> >> >
> >> >  <plugin>
> >> >  <artifactId>maven-assembly-plugin</artifactId>
> >> >        <version>2.3</version>
> >> >        <configuration>
> >> >
> >> >   <archive>
> >> >    <manifest>
> >> >     <mainClass>com.company.classX</mainClass>
> >> >    </manifest>
> >> >   </archive>
> >> >          <descriptorRefs>
> >> >            <descriptorRef>jar-with-dependencies</descriptorRef>
> >> >          </descriptorRefs>
> >> >        </configuration>
> >> >        <executions>
> >> >          <execution>
> >> >            <id>make-assembly</id> <!-- this is used for inheritance
> >> merges
> >> > -->
> >> >            <phase>package</phase> <!-- bind to the packaging phase -->
> >> >            <goals>
> >> >              <goal>single</goal>
> >> >            </goals>
> >> >          </execution>
> >> >        </executions>
> >> >  </plugin>
> >> >
> >> >    </plugins>
> >> >  </build>
> >> >
> >> >  <dependencies>
> >> >
> >> >  <dependency>
> >> >  <groupId>org.apache.httpcomponents</groupId>
> >> >  <artifactId>httpclient</artifactId>
> >> >  <version>4.1.3</version>
> >> >  </dependency>
> >> >
> >> >  </dependencies>
> >> >
> >> > </project>
> >> >
> >> >
> >> >  The resulting jar contains httpclient and all the dependencies it
> has,
> >> but
> >> > no code of mine is added in the jar, and I get this output in command
> >> line:
> >> >
> >> >
> >> > D:\projetos\tutorial>mvn assembly:single
> >> > [INFO] Scanning for projects...
> >> > [INFO]
> >> > [INFO]
> >> >
> ------------------------------------------------------------------------
> >> > [INFO] Building tutorial 1.0-SNAPSHOT
> >> > [INFO]
> >> >
> ------------------------------------------------------------------------
> >> > [INFO]
> >> > [INFO] --- maven-assembly-plugin:2.3:single (default-cli) @ tutorial
> ---
> >> > *[WARNING] Cannot include project artifact:
> >> > com.company:tutorial:jar:1.0-SNAPSHOT; it doesn't have an associated
> file
> >> > or directory.*
> >> > [INFO] META-INF/ already added, skipping
> >> > [INFO] META-INF/MANIFEST.MF already added, skipping
> >> > [INFO] org/ already added, skipping
> >> > [INFO] org/apache/ already added, skipping
> >> > [INFO] org/apache/http/ already added, skipping
> >> > [INFO] org/apache/http/impl/ already added, skipping
> >> > [INFO] META-INF/NOTICE.txt already added, skipping
> >> > [INFO] META-INF/LICENSE.txt already added, skipping
> >> > [INFO] META-INF/maven/ already added, skipping
> >> > [INFO] META-INF/maven/org.apache.httpcomponents/ already added,
> skipping
> >> > [INFO] META-INF/ already added, skipping
> >> > [INFO] META-INF/MANIFEST.MF already added, skipping
> >> > [INFO] org/ already added, skipping
> >> > [INFO] org/apache/ already added, skipping
> >> > [INFO] META-INF/maven/ already added, skipping
> >> > [INFO] META-INF/ already added, skipping
> >> > [INFO] META-INF/MANIFEST.MF already added, skipping
> >> > [INFO] org/ already added, skipping
> >> > [INFO] org/apache/ already added, skipping
> >> > [INFO] org/apache/commons/ already added, skipping
> >> > [INFO] META-INF/LICENSE.txt already added, skipping
> >> > [INFO] META-INF/NOTICE.txt already added, skipping
> >> > [INFO] META-INF/maven/ already added, skipping
> >> > [INFO] Building jar:
> >> >
> >>
> D:\projetos\tutorial\target\tutorial-1.0-SNAPSHOT-jar-with-dependencies.jar
> >> > [INFO] META-INF/ already added, skipping
> >> > [INFO] META-INF/MANIFEST.MF already added, skipping
> >> > [INFO] org/ already added, skipping
> >> > [INFO] org/apache/ already added, skipping
> >> > [INFO] org/apache/http/ already added, skipping
> >> > [INFO] org/apache/http/impl/ already added, skipping
> >> > [INFO] META-INF/NOTICE.txt already added, skipping
> >> > [INFO] META-INF/LICENSE.txt already added, skipping
> >> > [INFO] META-INF/maven/ already added, skipping
> >> > [INFO] META-INF/maven/org.apache.httpcomponents/ already added,
> skipping
> >> > [INFO] META-INF/ already added, skipping
> >> > [INFO] META-INF/MANIFEST.MF already added, skipping
> >> > [INFO] org/ already added, skipping
> >> > [INFO] org/apache/ already added, skipping
> >> > [INFO] META-INF/maven/ already added, skipping
> >> > [INFO] META-INF/ already added, skipping
> >> > [INFO] META-INF/MANIFEST.MF already added, skipping
> >> > [INFO] org/ already added, skipping
> >> > [INFO] org/apache/ already added, skipping
> >> > [INFO] org/apache/commons/ already added, skipping
> >> > [INFO] META-INF/LICENSE.txt already added, skipping
> >> > [INFO] META-INF/NOTICE.txt already added, skipping
> >> > [INFO] META-INF/maven/ already added, skipping
> >> > [INFO]
> >> >
> ------------------------------------------------------------------------
> >> > [INFO] BUILD SUCCESS
> >> > [INFO]
> >> >
> ------------------------------------------------------------------------
> >> > [INFO] Total time: 1.437s
> >> > [INFO] Finished at: Tue Apr 17 06:38:42 BRT 2012
> >> > [INFO] Final Memory: 4M/15M
> >> > [INFO]
> >> >
> ------------------------------------------------------------------------
> >> > D:\projetos\tutorial>
> >> >
> >> >
> >> >  Does anyone please have any idea? I am getting crazy with this
> problem.
> >> >
> >> > Thank you very much,
> >> > Kind regards,
> >> >
> >> > QL.
> >>
> >> ---------------------------------------------------------------------
> >> 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
>
>

Re: Question about Maven Assembly Plugin

Posted by Anders Hammar <an...@hammar.net>.
I get several hits with Google. For example:

http://www.sonatype.com/people/2009/08/how-to-make-an-executable-jar-in-maven/
(this one does not talk about useProjectArtifact=false, so I guess it
is not necessary)

If someone has a real example with a link, please provide. I don't.

/Anders

On Wed, Apr 18, 2012 at 00:23, QL 983 <fr...@gmail.com> wrote:
> Hi, Anders; thank you for your answer! I tried using useProjectArtifact
> false, but it did not work.
>
> Could you please supply me with an example of a executable
> jar-with-dependencies?
>
> Kind regards,
>
> QL
>
> On Tue, Apr 17, 2012 at 8:06 AM, Anders Hammar <an...@hammar.net> wrote:
>
>> I think the solution is to set useProjectArtifact to false in the
>> assembly descriptor.
>>
>> /Anders
>>
>> On Tue, Apr 17, 2012 at 11:44, QL 983 <fr...@gmail.com> wrote:
>> > Hi.
>> >
>> > I am writing a little tutorial in my company about the use of the Maven
>> > Assembly Plugin to build a executable jar, with all dependencies inside
>> it.
>> >
>> > When I was using Maven 2.2.1, the following would done the job:
>> >
>> > ...
>> >  <build>
>> >  <plugins>
>> > ...
>> >   <plugin>
>> >    <artifactId>maven-assembly-plugin</artifactId>
>> >    <configuration>
>> >     <source>1.5</source>
>> >     <target>1.5</target>
>> >     <archive>
>> >      <manifest>
>> >       <mainClass>com.company.classX</mainClass>
>> >      </manifest>
>> >     </archive>
>> >     <descriptorRefs>
>> >      <descriptorRef>jar-with-dependencies</descriptorRef>
>> >     </descriptorRefs>
>> >    </configuration>
>> >   </plugin>
>> > ...
>> >  </plugins>
>> >  </build>
>> > ...
>> >
>> >
>> > This time, however, I am using Maven 3.0.4, and I am getting this
>> warning:
>> >
>> >
>> > [WARNING] Cannot include project artifact: com.company.class; it doesn't
>> > have an associated file or directory.
>> >
>> >
>> > I read the plugin's documentation, but could not figure what is the
>> problem.
>> >
>> > Here is the complete pom I am using now:
>> >
>> >
>> > <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.company</groupId>
>> >  <artifactId>tutorial</artifactId>
>> >  <version>1.0-SNAPSHOT</version>
>> >  <packaging>jar</packaging>
>> >  <name>someName</name>
>> >  <url>http://maven.apache.org</url>
>> >  <properties>
>> >    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>> >  <compileSource>1.6</compileSource>
>> >  </properties>
>> >  <build>
>> >    <plugins>
>> >      <plugin>
>> >        <artifactId>maven-compiler-plugin</artifactId>
>> >        <version>2.0.2</version>
>> >        <configuration>
>> >          <source>${compileSource}</source>
>> >    <target>${compileSource}</target>
>> >        </configuration>
>> >      </plugin>
>> >
>> >  <plugin>
>> >  <artifactId>maven-assembly-plugin</artifactId>
>> >        <version>2.3</version>
>> >        <configuration>
>> >
>> >   <archive>
>> >    <manifest>
>> >     <mainClass>com.company.classX</mainClass>
>> >    </manifest>
>> >   </archive>
>> >          <descriptorRefs>
>> >            <descriptorRef>jar-with-dependencies</descriptorRef>
>> >          </descriptorRefs>
>> >        </configuration>
>> >        <executions>
>> >          <execution>
>> >            <id>make-assembly</id> <!-- this is used for inheritance
>> merges
>> > -->
>> >            <phase>package</phase> <!-- bind to the packaging phase -->
>> >            <goals>
>> >              <goal>single</goal>
>> >            </goals>
>> >          </execution>
>> >        </executions>
>> >  </plugin>
>> >
>> >    </plugins>
>> >  </build>
>> >
>> >  <dependencies>
>> >
>> >  <dependency>
>> >  <groupId>org.apache.httpcomponents</groupId>
>> >  <artifactId>httpclient</artifactId>
>> >  <version>4.1.3</version>
>> >  </dependency>
>> >
>> >  </dependencies>
>> >
>> > </project>
>> >
>> >
>> >  The resulting jar contains httpclient and all the dependencies it has,
>> but
>> > no code of mine is added in the jar, and I get this output in command
>> line:
>> >
>> >
>> > D:\projetos\tutorial>mvn assembly:single
>> > [INFO] Scanning for projects...
>> > [INFO]
>> > [INFO]
>> > ------------------------------------------------------------------------
>> > [INFO] Building tutorial 1.0-SNAPSHOT
>> > [INFO]
>> > ------------------------------------------------------------------------
>> > [INFO]
>> > [INFO] --- maven-assembly-plugin:2.3:single (default-cli) @ tutorial ---
>> > *[WARNING] Cannot include project artifact:
>> > com.company:tutorial:jar:1.0-SNAPSHOT; it doesn't have an associated file
>> > or directory.*
>> > [INFO] META-INF/ already added, skipping
>> > [INFO] META-INF/MANIFEST.MF already added, skipping
>> > [INFO] org/ already added, skipping
>> > [INFO] org/apache/ already added, skipping
>> > [INFO] org/apache/http/ already added, skipping
>> > [INFO] org/apache/http/impl/ already added, skipping
>> > [INFO] META-INF/NOTICE.txt already added, skipping
>> > [INFO] META-INF/LICENSE.txt already added, skipping
>> > [INFO] META-INF/maven/ already added, skipping
>> > [INFO] META-INF/maven/org.apache.httpcomponents/ already added, skipping
>> > [INFO] META-INF/ already added, skipping
>> > [INFO] META-INF/MANIFEST.MF already added, skipping
>> > [INFO] org/ already added, skipping
>> > [INFO] org/apache/ already added, skipping
>> > [INFO] META-INF/maven/ already added, skipping
>> > [INFO] META-INF/ already added, skipping
>> > [INFO] META-INF/MANIFEST.MF already added, skipping
>> > [INFO] org/ already added, skipping
>> > [INFO] org/apache/ already added, skipping
>> > [INFO] org/apache/commons/ already added, skipping
>> > [INFO] META-INF/LICENSE.txt already added, skipping
>> > [INFO] META-INF/NOTICE.txt already added, skipping
>> > [INFO] META-INF/maven/ already added, skipping
>> > [INFO] Building jar:
>> >
>> D:\projetos\tutorial\target\tutorial-1.0-SNAPSHOT-jar-with-dependencies.jar
>> > [INFO] META-INF/ already added, skipping
>> > [INFO] META-INF/MANIFEST.MF already added, skipping
>> > [INFO] org/ already added, skipping
>> > [INFO] org/apache/ already added, skipping
>> > [INFO] org/apache/http/ already added, skipping
>> > [INFO] org/apache/http/impl/ already added, skipping
>> > [INFO] META-INF/NOTICE.txt already added, skipping
>> > [INFO] META-INF/LICENSE.txt already added, skipping
>> > [INFO] META-INF/maven/ already added, skipping
>> > [INFO] META-INF/maven/org.apache.httpcomponents/ already added, skipping
>> > [INFO] META-INF/ already added, skipping
>> > [INFO] META-INF/MANIFEST.MF already added, skipping
>> > [INFO] org/ already added, skipping
>> > [INFO] org/apache/ already added, skipping
>> > [INFO] META-INF/maven/ already added, skipping
>> > [INFO] META-INF/ already added, skipping
>> > [INFO] META-INF/MANIFEST.MF already added, skipping
>> > [INFO] org/ already added, skipping
>> > [INFO] org/apache/ already added, skipping
>> > [INFO] org/apache/commons/ already added, skipping
>> > [INFO] META-INF/LICENSE.txt already added, skipping
>> > [INFO] META-INF/NOTICE.txt already added, skipping
>> > [INFO] META-INF/maven/ already added, skipping
>> > [INFO]
>> > ------------------------------------------------------------------------
>> > [INFO] BUILD SUCCESS
>> > [INFO]
>> > ------------------------------------------------------------------------
>> > [INFO] Total time: 1.437s
>> > [INFO] Finished at: Tue Apr 17 06:38:42 BRT 2012
>> > [INFO] Final Memory: 4M/15M
>> > [INFO]
>> > ------------------------------------------------------------------------
>> > D:\projetos\tutorial>
>> >
>> >
>> >  Does anyone please have any idea? I am getting crazy with this problem.
>> >
>> > Thank you very much,
>> > Kind regards,
>> >
>> > QL.
>>
>> ---------------------------------------------------------------------
>> 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


Re: Question about Maven Assembly Plugin

Posted by QL 983 <fr...@gmail.com>.
Hi, Anders; thank you for your answer! I tried using useProjectArtifact
false, but it did not work.

Could you please supply me with an example of a executable
jar-with-dependencies?

Kind regards,

QL

On Tue, Apr 17, 2012 at 8:06 AM, Anders Hammar <an...@hammar.net> wrote:

> I think the solution is to set useProjectArtifact to false in the
> assembly descriptor.
>
> /Anders
>
> On Tue, Apr 17, 2012 at 11:44, QL 983 <fr...@gmail.com> wrote:
> > Hi.
> >
> > I am writing a little tutorial in my company about the use of the Maven
> > Assembly Plugin to build a executable jar, with all dependencies inside
> it.
> >
> > When I was using Maven 2.2.1, the following would done the job:
> >
> > ...
> >  <build>
> >  <plugins>
> > ...
> >   <plugin>
> >    <artifactId>maven-assembly-plugin</artifactId>
> >    <configuration>
> >     <source>1.5</source>
> >     <target>1.5</target>
> >     <archive>
> >      <manifest>
> >       <mainClass>com.company.classX</mainClass>
> >      </manifest>
> >     </archive>
> >     <descriptorRefs>
> >      <descriptorRef>jar-with-dependencies</descriptorRef>
> >     </descriptorRefs>
> >    </configuration>
> >   </plugin>
> > ...
> >  </plugins>
> >  </build>
> > ...
> >
> >
> > This time, however, I am using Maven 3.0.4, and I am getting this
> warning:
> >
> >
> > [WARNING] Cannot include project artifact: com.company.class; it doesn't
> > have an associated file or directory.
> >
> >
> > I read the plugin's documentation, but could not figure what is the
> problem.
> >
> > Here is the complete pom I am using now:
> >
> >
> > <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.company</groupId>
> >  <artifactId>tutorial</artifactId>
> >  <version>1.0-SNAPSHOT</version>
> >  <packaging>jar</packaging>
> >  <name>someName</name>
> >  <url>http://maven.apache.org</url>
> >  <properties>
> >    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
> >  <compileSource>1.6</compileSource>
> >  </properties>
> >  <build>
> >    <plugins>
> >      <plugin>
> >        <artifactId>maven-compiler-plugin</artifactId>
> >        <version>2.0.2</version>
> >        <configuration>
> >          <source>${compileSource}</source>
> >    <target>${compileSource}</target>
> >        </configuration>
> >      </plugin>
> >
> >  <plugin>
> >  <artifactId>maven-assembly-plugin</artifactId>
> >        <version>2.3</version>
> >        <configuration>
> >
> >   <archive>
> >    <manifest>
> >     <mainClass>com.company.classX</mainClass>
> >    </manifest>
> >   </archive>
> >          <descriptorRefs>
> >            <descriptorRef>jar-with-dependencies</descriptorRef>
> >          </descriptorRefs>
> >        </configuration>
> >        <executions>
> >          <execution>
> >            <id>make-assembly</id> <!-- this is used for inheritance
> merges
> > -->
> >            <phase>package</phase> <!-- bind to the packaging phase -->
> >            <goals>
> >              <goal>single</goal>
> >            </goals>
> >          </execution>
> >        </executions>
> >  </plugin>
> >
> >    </plugins>
> >  </build>
> >
> >  <dependencies>
> >
> >  <dependency>
> >  <groupId>org.apache.httpcomponents</groupId>
> >  <artifactId>httpclient</artifactId>
> >  <version>4.1.3</version>
> >  </dependency>
> >
> >  </dependencies>
> >
> > </project>
> >
> >
> >  The resulting jar contains httpclient and all the dependencies it has,
> but
> > no code of mine is added in the jar, and I get this output in command
> line:
> >
> >
> > D:\projetos\tutorial>mvn assembly:single
> > [INFO] Scanning for projects...
> > [INFO]
> > [INFO]
> > ------------------------------------------------------------------------
> > [INFO] Building tutorial 1.0-SNAPSHOT
> > [INFO]
> > ------------------------------------------------------------------------
> > [INFO]
> > [INFO] --- maven-assembly-plugin:2.3:single (default-cli) @ tutorial ---
> > *[WARNING] Cannot include project artifact:
> > com.company:tutorial:jar:1.0-SNAPSHOT; it doesn't have an associated file
> > or directory.*
> > [INFO] META-INF/ already added, skipping
> > [INFO] META-INF/MANIFEST.MF already added, skipping
> > [INFO] org/ already added, skipping
> > [INFO] org/apache/ already added, skipping
> > [INFO] org/apache/http/ already added, skipping
> > [INFO] org/apache/http/impl/ already added, skipping
> > [INFO] META-INF/NOTICE.txt already added, skipping
> > [INFO] META-INF/LICENSE.txt already added, skipping
> > [INFO] META-INF/maven/ already added, skipping
> > [INFO] META-INF/maven/org.apache.httpcomponents/ already added, skipping
> > [INFO] META-INF/ already added, skipping
> > [INFO] META-INF/MANIFEST.MF already added, skipping
> > [INFO] org/ already added, skipping
> > [INFO] org/apache/ already added, skipping
> > [INFO] META-INF/maven/ already added, skipping
> > [INFO] META-INF/ already added, skipping
> > [INFO] META-INF/MANIFEST.MF already added, skipping
> > [INFO] org/ already added, skipping
> > [INFO] org/apache/ already added, skipping
> > [INFO] org/apache/commons/ already added, skipping
> > [INFO] META-INF/LICENSE.txt already added, skipping
> > [INFO] META-INF/NOTICE.txt already added, skipping
> > [INFO] META-INF/maven/ already added, skipping
> > [INFO] Building jar:
> >
> D:\projetos\tutorial\target\tutorial-1.0-SNAPSHOT-jar-with-dependencies.jar
> > [INFO] META-INF/ already added, skipping
> > [INFO] META-INF/MANIFEST.MF already added, skipping
> > [INFO] org/ already added, skipping
> > [INFO] org/apache/ already added, skipping
> > [INFO] org/apache/http/ already added, skipping
> > [INFO] org/apache/http/impl/ already added, skipping
> > [INFO] META-INF/NOTICE.txt already added, skipping
> > [INFO] META-INF/LICENSE.txt already added, skipping
> > [INFO] META-INF/maven/ already added, skipping
> > [INFO] META-INF/maven/org.apache.httpcomponents/ already added, skipping
> > [INFO] META-INF/ already added, skipping
> > [INFO] META-INF/MANIFEST.MF already added, skipping
> > [INFO] org/ already added, skipping
> > [INFO] org/apache/ already added, skipping
> > [INFO] META-INF/maven/ already added, skipping
> > [INFO] META-INF/ already added, skipping
> > [INFO] META-INF/MANIFEST.MF already added, skipping
> > [INFO] org/ already added, skipping
> > [INFO] org/apache/ already added, skipping
> > [INFO] org/apache/commons/ already added, skipping
> > [INFO] META-INF/LICENSE.txt already added, skipping
> > [INFO] META-INF/NOTICE.txt already added, skipping
> > [INFO] META-INF/maven/ already added, skipping
> > [INFO]
> > ------------------------------------------------------------------------
> > [INFO] BUILD SUCCESS
> > [INFO]
> > ------------------------------------------------------------------------
> > [INFO] Total time: 1.437s
> > [INFO] Finished at: Tue Apr 17 06:38:42 BRT 2012
> > [INFO] Final Memory: 4M/15M
> > [INFO]
> > ------------------------------------------------------------------------
> > D:\projetos\tutorial>
> >
> >
> >  Does anyone please have any idea? I am getting crazy with this problem.
> >
> > Thank you very much,
> > Kind regards,
> >
> > QL.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Question about Maven Assembly Plugin

Posted by Anders Hammar <an...@hammar.net>.
I think the solution is to set useProjectArtifact to false in the
assembly descriptor.

/Anders

On Tue, Apr 17, 2012 at 11:44, QL 983 <fr...@gmail.com> wrote:
> Hi.
>
> I am writing a little tutorial in my company about the use of the Maven
> Assembly Plugin to build a executable jar, with all dependencies inside it.
>
> When I was using Maven 2.2.1, the following would done the job:
>
> ...
>  <build>
>  <plugins>
> ...
>   <plugin>
>    <artifactId>maven-assembly-plugin</artifactId>
>    <configuration>
>     <source>1.5</source>
>     <target>1.5</target>
>     <archive>
>      <manifest>
>       <mainClass>com.company.classX</mainClass>
>      </manifest>
>     </archive>
>     <descriptorRefs>
>      <descriptorRef>jar-with-dependencies</descriptorRef>
>     </descriptorRefs>
>    </configuration>
>   </plugin>
> ...
>  </plugins>
>  </build>
> ...
>
>
> This time, however, I am using Maven 3.0.4, and I am getting this warning:
>
>
> [WARNING] Cannot include project artifact: com.company.class; it doesn't
> have an associated file or directory.
>
>
> I read the plugin's documentation, but could not figure what is the problem.
>
> Here is the complete pom I am using now:
>
>
> <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.company</groupId>
>  <artifactId>tutorial</artifactId>
>  <version>1.0-SNAPSHOT</version>
>  <packaging>jar</packaging>
>  <name>someName</name>
>  <url>http://maven.apache.org</url>
>  <properties>
>    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>  <compileSource>1.6</compileSource>
>  </properties>
>  <build>
>    <plugins>
>      <plugin>
>        <artifactId>maven-compiler-plugin</artifactId>
>        <version>2.0.2</version>
>        <configuration>
>          <source>${compileSource}</source>
>    <target>${compileSource}</target>
>        </configuration>
>      </plugin>
>
>  <plugin>
>  <artifactId>maven-assembly-plugin</artifactId>
>        <version>2.3</version>
>        <configuration>
>
>   <archive>
>    <manifest>
>     <mainClass>com.company.classX</mainClass>
>    </manifest>
>   </archive>
>          <descriptorRefs>
>            <descriptorRef>jar-with-dependencies</descriptorRef>
>          </descriptorRefs>
>        </configuration>
>        <executions>
>          <execution>
>            <id>make-assembly</id> <!-- this is used for inheritance merges
> -->
>            <phase>package</phase> <!-- bind to the packaging phase -->
>            <goals>
>              <goal>single</goal>
>            </goals>
>          </execution>
>        </executions>
>  </plugin>
>
>    </plugins>
>  </build>
>
>  <dependencies>
>
>  <dependency>
>  <groupId>org.apache.httpcomponents</groupId>
>  <artifactId>httpclient</artifactId>
>  <version>4.1.3</version>
>  </dependency>
>
>  </dependencies>
>
> </project>
>
>
>  The resulting jar contains httpclient and all the dependencies it has, but
> no code of mine is added in the jar, and I get this output in command line:
>
>
> D:\projetos\tutorial>mvn assembly:single
> [INFO] Scanning for projects...
> [INFO]
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Building tutorial 1.0-SNAPSHOT
> [INFO]
> ------------------------------------------------------------------------
> [INFO]
> [INFO] --- maven-assembly-plugin:2.3:single (default-cli) @ tutorial ---
> *[WARNING] Cannot include project artifact:
> com.company:tutorial:jar:1.0-SNAPSHOT; it doesn't have an associated file
> or directory.*
> [INFO] META-INF/ already added, skipping
> [INFO] META-INF/MANIFEST.MF already added, skipping
> [INFO] org/ already added, skipping
> [INFO] org/apache/ already added, skipping
> [INFO] org/apache/http/ already added, skipping
> [INFO] org/apache/http/impl/ already added, skipping
> [INFO] META-INF/NOTICE.txt already added, skipping
> [INFO] META-INF/LICENSE.txt already added, skipping
> [INFO] META-INF/maven/ already added, skipping
> [INFO] META-INF/maven/org.apache.httpcomponents/ already added, skipping
> [INFO] META-INF/ already added, skipping
> [INFO] META-INF/MANIFEST.MF already added, skipping
> [INFO] org/ already added, skipping
> [INFO] org/apache/ already added, skipping
> [INFO] META-INF/maven/ already added, skipping
> [INFO] META-INF/ already added, skipping
> [INFO] META-INF/MANIFEST.MF already added, skipping
> [INFO] org/ already added, skipping
> [INFO] org/apache/ already added, skipping
> [INFO] org/apache/commons/ already added, skipping
> [INFO] META-INF/LICENSE.txt already added, skipping
> [INFO] META-INF/NOTICE.txt already added, skipping
> [INFO] META-INF/maven/ already added, skipping
> [INFO] Building jar:
> D:\projetos\tutorial\target\tutorial-1.0-SNAPSHOT-jar-with-dependencies.jar
> [INFO] META-INF/ already added, skipping
> [INFO] META-INF/MANIFEST.MF already added, skipping
> [INFO] org/ already added, skipping
> [INFO] org/apache/ already added, skipping
> [INFO] org/apache/http/ already added, skipping
> [INFO] org/apache/http/impl/ already added, skipping
> [INFO] META-INF/NOTICE.txt already added, skipping
> [INFO] META-INF/LICENSE.txt already added, skipping
> [INFO] META-INF/maven/ already added, skipping
> [INFO] META-INF/maven/org.apache.httpcomponents/ already added, skipping
> [INFO] META-INF/ already added, skipping
> [INFO] META-INF/MANIFEST.MF already added, skipping
> [INFO] org/ already added, skipping
> [INFO] org/apache/ already added, skipping
> [INFO] META-INF/maven/ already added, skipping
> [INFO] META-INF/ already added, skipping
> [INFO] META-INF/MANIFEST.MF already added, skipping
> [INFO] org/ already added, skipping
> [INFO] org/apache/ already added, skipping
> [INFO] org/apache/commons/ already added, skipping
> [INFO] META-INF/LICENSE.txt already added, skipping
> [INFO] META-INF/NOTICE.txt already added, skipping
> [INFO] META-INF/maven/ already added, skipping
> [INFO]
> ------------------------------------------------------------------------
> [INFO] BUILD SUCCESS
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Total time: 1.437s
> [INFO] Finished at: Tue Apr 17 06:38:42 BRT 2012
> [INFO] Final Memory: 4M/15M
> [INFO]
> ------------------------------------------------------------------------
> D:\projetos\tutorial>
>
>
>  Does anyone please have any idea? I am getting crazy with this problem.
>
> Thank you very much,
> Kind regards,
>
> QL.

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