You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by solo1970 <so...@ericsson.com> on 2009/03/23 20:22:27 UTC

Re: super-beginner question - fail to properly package maven project.

Hello

You can play with the classpath in the Manifest file:

Example:

               <plugin>
                 <artifactId>maven-jar-plugin</artifactId>
                 <configuration>
                  <archive>
                    <manifest>
                      <addClasspath>true</addClasspath>
                      <mainClass>com.yourMainClass</mainClass>
                    </manifest>
                  </archive>
                 </configuration>
               </plugin>

http://maven.apache.org/plugins/maven-jar-plugin/jar-mojo.html
http://maven.apache.org/shared/maven-archiver/

Sonia


alfonz19 wrote:
> 
> Hi,
> 
> I've got maven project here, with specified compile-scoped dependencies
> and ejb packaging. I can build&deploy it successfully but then it crashes
> because when I examine procucted .jar it does not contain needed .jar
> libraries even if those exists in my local repository. I've tried to find
> an anwer to this behavior, but did not succeed. Can anybody give me a hint
> what's wrong? 
> 
> thanks in advance,
> martin.
> 

-- 
View this message in context: http://www.nabble.com/super-beginner-question---fail-to-properly-package-maven-project.-tp22667119p22667293.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: super-beginner question - fail to properly package maven project.

Posted by alfonz19 <al...@seznam.cz>.
thanks a lot, I'll try it. But let me ask some more (ok, I know that I'm so
annoying)

I've started out with premise, that guy responsible for building apps and so
on in our firm knows, what is he doing. False. So let me ask once more, for
more generic question.

We have here few packages. It's some .jar (with session beans), some .wars.
I can declare dependencies, that's no problem. So let's assume, that I need
to work on some .jar and test it, so I need another .jars (which I didn't
modify), some .wars, then I need to build them into .ear and deploy it into
my local AS.

I've tried to create my own maven project in NB with JEE 5 EAR archetype.
Added dependency to single .jar (with some session beans). It get included
in libs folder, build was ok, .ear deployed ok into jboss but when I check
jmx console there are no session beans loaded even if I can see that ear to
be uploaded in NB in services pane under jboss node. So ear was uploaded
without error, but that .jar library (which is included in ear) was not (and
no error was printed). Moreover even if it is ear, there still are no
libraries that .jar said is dependant on.

So what steps would you take to create, build and deploy such application
with maven? For simplicity let's assume, that I've got single .war and
single .jar with some dependencies and want to produce .ear which I can
later deploy on server. I would also want, that those libraries gets
packaged into either ear or jar, since it's (I think) nonsense to deploy
them to server by hand. Is it a good approach or is there a better way how
to do it? I'm sorry that I keep asking, but I have a lot of duty to do and
on top of them I have to fix why configuration some guy have written does
not work, while I do not know almost anything about maven ...
-- 
View this message in context: http://www.nabble.com/super-beginner-question---fail-to-properly-package-maven-project.-tp22667119p22682101.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: super-beginner question - fail to properly package maven project.

Posted by solo1970 <so...@ericsson.com>.
Bear with me, I am also a beginner with Maven!  ;o)

If I understand correctly you want the dependecies to be in the .jar,
right????

If so, do this:

  <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-dependency-plugin</artifactId>
                 <executions>
                   <execution>
                     <id>unpack-dependencies</id>
                     <goals>
                       <goal>unpack-dependencies</goal>
                     </goals>
                     <configuration>
                       <excludeTransitive>true</excludeTransitive>
                      
<outputDirectory>${project.build.directory}/classes</outputDirectory>
                     </configuration>
                   </execution>
                 </executions>
              </plugin>






solo1970 wrote:
> 
> Hello
> 
> You can play with the classpath in the Manifest file:
> 
> Example:
> 
>                <plugin>
>                  <artifactId>maven-jar-plugin</artifactId>
>                  <configuration>
>                   <archive>
>                     <manifest>
>                       <addClasspath>true</addClasspath>
>                       <mainClass>com.yourMainClass</mainClass>
>                     </manifest>
>                   </archive>
>                  </configuration>
>                </plugin>
> 
> http://maven.apache.org/plugins/maven-jar-plugin/jar-mojo.html
> http://maven.apache.org/shared/maven-archiver/
> 
> Sonia
> 
> Hi, I've tried to add the code fragment you've specified into my pom, but
> nothing changes at all. I've tried to understand from that plugin
> descriptions what I've just said to be done, but did not notice any
> explicit possibility how to change packaging. So I looked at it "if I
> include this code in pom, then my libraries will be included", but that
> did not happen.
> 
> I've tried to change packaging to ear as noted, but that did not do
> anything also. I still end up with .jar file which compile ok, but does
> not include any libraries into final .jar.
> 
> 
> here is our pom.xml, which probably will contain handfull of errors and
> lot of nonsenses, but all I need at this time to be able to create usable
> (with included libraries) build.
> 
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <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/maven-v4_0_0.xsd">
>     <modelVersion>4.0.0</modelVersion>
>     <groupId>something</groupId>
>     <artifactId>core</artifactId>
>     <packaging>ejb</packaging>
>     <name>EIRA Core</name>
>     <version>1.0</version>
>     <description>something</description>
>     <url>something</url>
>     <inceptionYear>2009</inceptionYear>
>     <issueManagement>
>         <system>Bugzilla</system>
>         <url>something</url>
>     </issueManagement>
>     <ciManagement>
>         <system>TeamCity</system>
>         <url>something</url>
>     </ciManagement>
>     <scm>
>         <connection>something</connection>
>         <developerConnection>something</developerConnection>
>         <url>something</url>
>     </scm>
>     <organization>
>         <name>something</name>
>         <url>something</url>
>     </organization>
> 
>  
>     <reporting>
>         <plugins>
>             <plugin>
>                 <groupId>org.apache.maven.plugins</groupId>
>                 <artifactId>maven-checkstyle-plugin</artifactId>
>             </plugin>
>             <plugin>
>                 <groupId>org.apache.maven.plugins</groupId>
>                 <artifactId>maven-javadoc-plugin</artifactId>
>             </plugin>
>             <plugin>
>                 <groupId>org.apache.maven.plugins</groupId>
>                 <artifactId>maven-pmd-plugin</artifactId>
>                 <version>2.3</version>
>                 <configuration>
>                     <targetJdk>${compileSource}</targetJdk>
>                 </configuration>
>             </plugin>
>             <plugin>
>                 <groupId>org.apache.maven.plugins</groupId>
>                 <artifactId>maven-surefire-report-plugin</artifactId>
>                 <version>2.4.2</version>
>             </plugin>
>             <plugin>
>                 <groupId>org.codehaus.mojo</groupId>
>                 <artifactId>taglist-maven-plugin</artifactId>
>                 <version>2.3</version>
>             </plugin>
>             <plugin>
>                 <groupId>org.codehaus.mojo</groupId>
>                 <artifactId>jdepend-maven-plugin</artifactId>
>             </plugin>
>             <plugin>
>                 <groupId>org.apache.maven.plugins</groupId>
>                 <artifactId>maven-changelog-plugin</artifactId>
>                 <configuration>
>                     <conectionType>developerConnection</conectionType>
>                     <username>SVNReader</username>
>                     <password>something</password>
>                 </configuration>
>             </plugin>
>             <plugin>
>                 <groupId>org.apache.maven.plugins</groupId>
>                 <artifactId>maven-changes-plugin</artifactId>
>                 <reportSets>
>                     <reportSet>
>                         <reports>
>                             <report>changes-report</report>
>                         </reports>
>                     </reportSet>
>                 </reportSets>
>             </plugin>
>             <plugin>
>                 <groupId>org.apache.maven.plugins</groupId>
>                 <artifactId>maven-jxr-plugin</artifactId>
>             </plugin>
>         </plugins>
>     </reporting>
>     <repositories>
>         <repository>
>             <id>jboss</id>
>             <url>http://repository.jboss.com/maven2</url>
>         </repository>
>     </repositories>
>     <dependencies>
>         <dependency>
>             <groupId>javax.servlet</groupId>
>             <artifactId>jstl</artifactId>
>             <version>1.2</version>
>         </dependency>
>         <dependency>
>             <groupId>javax.servlet</groupId>
>             <artifactId>servlet-api</artifactId>
>             <version>2.5</version>
>         </dependency>
>         <dependency>
>             <groupId>net.sf.json-lib</groupId>
>             <artifactId>json-lib</artifactId>
>             <version>2.2.3</version>            
>         </dependency>
>         <dependency>
>             <groupId>org.hibernate</groupId>
>             <artifactId>hibernate-annotations</artifactId>
>             <version>3.4.0.GA</version>
>         </dependency>
>         <dependency>
>             <groupId>javax.ejb</groupId>
>             <artifactId>ejb-api</artifactId>
>             <version>3.0</version>
>         </dependency>
>         <dependency>
>             <groupId>commons-httpclient</groupId>
>             <artifactId>commons-httpclient</artifactId>
>             <version>3.1</version>
>         </dependency>
>         <dependency>
>             <groupId>javax.persistence</groupId>
>             <artifactId>persistence-api</artifactId>
>             <version>1.0</version>
>             <scope>provided</scope>
>         </dependency>
>         <dependency>
>             <groupId>javax.ejb</groupId>
>             <artifactId>ejb-api</artifactId>
>             <version>3.0</version>
>             <scope>provided</scope>
>         </dependency>
>         <dependency>
>             <groupId>jboss</groupId>
>             <artifactId>jboss-annotations-ejb3</artifactId>
>             <version>4.2.3.GA</version>
>             <scope>provided</scope>
>         </dependency>
>         <dependency>
>             <groupId>jboss</groupId>
>             <artifactId>jboss-ejb3x</artifactId>
>             <version>4.2.3.GA</version>
>             <scope>provided</scope>
>         </dependency>
>         <dependency>
>             <groupId>hibernate</groupId>
>             <artifactId>hibernate3</artifactId>
>             <version>3.2.3.GA</version>
>             <scope>provided</scope>
>         </dependency>
>         <dependency>
>             <groupId>log4j</groupId>
>             <artifactId>log4j</artifactId>
>             <version>1.2.14</version>
>             <scope>provided</scope>
>         </dependency>
>         
>         <dependency>
> 					<groupId>commons-fileupload</groupId>
> 					<artifactId>commons-fileupload</artifactId>
> 					<version>1.2.1</version>
> 				</dependency>
> 				
> 				<dependency>
> 					<groupId>commons-io</groupId>
> 					<artifactId>commons-io</artifactId>
> 					<version>1.4</version>
> 				</dependency>
>         
>         <dependency>
> 					<groupId>eu.medsea.mimeutil</groupId>
> 					<artifactId>mime-util</artifactId>
> 					<version>1.3</version>
> 					<scope>system</scope>
> 				
> <systemPath>${basedir}/src/main/webapp/WEB-INF/lib/mime-util-1.3.jar</systemPath>
> 				</dependency>
>     </dependencies>
>     <build>
>         <plugins>
>             <plugin>
>                 <artifactId>maven-compiler-plugin</artifactId>
>                 <configuration>
>                     <source>${compileSource}</source>
>                     <target>${compileSource}</target>
>                 </configuration>
>             </plugin>
> 
>             <plugin>
>                 <groupId>org.apache.maven.plugins</groupId>
>                 <artifactId>maven-ejb-plugin</artifactId>
>                 <configuration>
>                    <ejbVersion>3.0</ejbVersion>
>                 </configuration>
>             </plugin>
> 
> 
>              <plugin>
>                  <artifactId>maven-jar-plugin</artifactId>
>                  <configuration>
>                   <archive>
>                     <manifest>
>                       <addClasspath>true</addClasspath>
>                       <mainClass/>
>                     </manifest>
>                   </archive>
>                  </configuration>
>                 </plugin>
> 
>         </plugins>
>     </build>
>     <distributionManagement>
>         <site>
>             <id>core</id>
>             <name>EIRA Core</name>
>             <url>file:///c:/Inetpub/wwwroot/EIRA/core</url>
>         </site>
>     </distributionManagement>
>     <properties>
>         <compileSource>1.5</compileSource>
>         <netbeans.hint.deploy.server>JBoss4</netbeans.hint.deploy.server>
>     </properties>
> 
> </project>
> 
> 

-- 
View this message in context: http://www.nabble.com/super-beginner-question---fail-to-properly-package-maven-project.-tp22667119p22681420.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: super-beginner question - fail to properly package maven project.

Posted by alfonz19 <al...@seznam.cz>.


Hello

You can play with the classpath in the Manifest file:

Example:

               <plugin>
                 <artifactId>maven-jar-plugin</artifactId>
                 <configuration>
                  <archive>
                    <manifest>
                      <addClasspath>true</addClasspath>
                      <mainClass>com.yourMainClass</mainClass>
                    </manifest>
                  </archive>
                 </configuration>
               </plugin>

http://maven.apache.org/plugins/maven-jar-plugin/jar-mojo.html
http://maven.apache.org/shared/maven-archiver/

Sonia

Hi, I've tried to add the code fragment you've specified into my pom, but
nothing changes at all. I've tried to understand from that plugin
descriptions what I've just said to be done, but did not notice any explicit
possibility how to change packaging. So I looked at it "if I include this
code in pom, then my libraries will be included", but that did not happen.

I've tried to change packaging to ear as noted, but that did not do anything
also. I still end up with .jar file which compile ok, but does not include
any libraries into final .jar.


here is our pom.xml, which probably will contain handfull of errors and lot
of nonsenses, but all I need at this time to be able to create usable (with
included libraries) build.


<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>something</groupId>
    <artifactId>core</artifactId>
    <packaging>ejb</packaging>
    <name>EIRA Core</name>
    <version>1.0</version>
    <description>something</description>
    <url>something</url>
    <inceptionYear>2009</inceptionYear>
    <issueManagement>
        <system>Bugzilla</system>
        <url>something</url>
    </issueManagement>
    <ciManagement>
        <system>TeamCity</system>
        <url>something</url>
    </ciManagement>
    <scm>
        <connection>something</connection>
        <developerConnection>something</developerConnection>
        <url>something</url>
    </scm>
    <organization>
        <name>something</name>
        <url>something</url>
    </organization>

 
    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-pmd-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <targetJdk>${compileSource}</targetJdk>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <version>2.4.2</version>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>taglist-maven-plugin</artifactId>
                <version>2.3</version>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jdepend-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-changelog-plugin</artifactId>
                <configuration>
                    <conectionType>developerConnection</conectionType>
                    <username>SVNReader</username>
                    <password>something</password>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-changes-plugin</artifactId>
                <reportSets>
                    <reportSet>
                        <reports>
                            <report>changes-report</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jxr-plugin</artifactId>
            </plugin>
        </plugins>
    </reporting>
    <repositories>
        <repository>
            <id>jboss</id>
            <url>http://repository.jboss.com/maven2</url>
        </repository>
    </repositories>
    <dependencies>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
        </dependency>
        <dependency>
            <groupId>net.sf.json-lib</groupId>
            <artifactId>json-lib</artifactId>
            <version>2.2.3</version>            
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-annotations</artifactId>
            <version>3.4.0.GA</version>
        </dependency>
        <dependency>
            <groupId>javax.ejb</groupId>
            <artifactId>ejb-api</artifactId>
            <version>3.0</version>
        </dependency>
        <dependency>
            <groupId>commons-httpclient</groupId>
            <artifactId>commons-httpclient</artifactId>
            <version>3.1</version>
        </dependency>
        <dependency>
            <groupId>javax.persistence</groupId>
            <artifactId>persistence-api</artifactId>
            <version>1.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.ejb</groupId>
            <artifactId>ejb-api</artifactId>
            <version>3.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jboss</groupId>
            <artifactId>jboss-annotations-ejb3</artifactId>
            <version>4.2.3.GA</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jboss</groupId>
            <artifactId>jboss-ejb3x</artifactId>
            <version>4.2.3.GA</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>hibernate</groupId>
            <artifactId>hibernate3</artifactId>
            <version>3.2.3.GA</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.14</version>
            <scope>provided</scope>
        </dependency>
        
        <dependency>
					<groupId>commons-fileupload</groupId>
					<artifactId>commons-fileupload</artifactId>
					<version>1.2.1</version>
				</dependency>
				
				<dependency>
					<groupId>commons-io</groupId>
					<artifactId>commons-io</artifactId>
					<version>1.4</version>
				</dependency>
        
        <dependency>
					<groupId>eu.medsea.mimeutil</groupId>
					<artifactId>mime-util</artifactId>
					<version>1.3</version>
					<scope>system</scope>
				
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/mime-util-1.3.jar</systemPath>
				</dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${compileSource}</source>
                    <target>${compileSource}</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-ejb-plugin</artifactId>
                <configuration>
                   <ejbVersion>3.0</ejbVersion>
                </configuration>
            </plugin>


             <plugin>
                 <artifactId>maven-jar-plugin</artifactId>
                 <configuration>
                  <archive>
                    <manifest>
                      <addClasspath>true</addClasspath>
                      <mainClass/>
                    </manifest>
                  </archive>
                 </configuration>
                </plugin>

        </plugins>
    </build>
    <distributionManagement>
        <site>
            <id>core</id>
            <name>EIRA Core</name>
            <url>file:///c:/Inetpub/wwwroot/EIRA/core</url>
        </site>
    </distributionManagement>
    <properties>
        <compileSource>1.5</compileSource>
        <netbeans.hint.deploy.server>JBoss4</netbeans.hint.deploy.server>
    </properties>

</project>

-- 
View this message in context: http://www.nabble.com/super-beginner-question---fail-to-properly-package-maven-project.-tp22667119p22679382.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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