You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by "Fuke, Amol" <Am...@nielsen.com> on 2011/02/23 11:24:05 UTC

How to compile code using maven

Hi All,

 

I have ant build file and now need to convert it into mvn pom file. My
problem is how do I get my code compiled using pom.xml.

 

I have below pom xml;

***

<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>com.nielsen.outbound</groupId>

  <artifactId>outbound</artifactId>

  <packaging>war</packaging>

  <version>1.0-SNAPSHOT</version>

  <name>outbound</name>

  <url>http://maven.apache.org</url>

  <dependencies>

    <dependency>

      <groupId>junit</groupId>

      <artifactId>junit</artifactId>

      <version>3.8.1</version>

      <scope>test</scope>

    </dependency>

  </dependencies>

  <build>

  <plugins>

  <plugin>

                        <groupId>org.apache.maven.plugins</groupId>

                        <artifactId>maven-compiler-plugin</artifactId>

                        <configuration>

 
<source>src/com/nielsen/outbound/*.java</source>

                              <target>target/classes</target>

                        </configuration>

                  </plugin>

                  <plugin>

                        <groupId>org.apache.maven.plugins</groupId>

                        <artifactId>maven-war-plugin</artifactId>

                        <configuration>

                              <webXml>conf/web.xml</webXml>

 
<webappDirectory>target/work/outbound.war</webappDirectory>

                        </configuration>

                  </plugin>

      <plugin>

                        <groupId>org.apache.maven.plugins</groupId>

                        <artifactId>maven-antrun-plugin</artifactId>

                        <executions>

                              <execution>

                                    <phase>compile</phase>

                                    <configuration>

                                          <tasks>

                                                <echo>Deleting
deployment..</echo>

                                                <delete
includeEmptyDirs="true"

 
dir="C:/Tomcat6/webapps/outbound" />

                                                <mkdir
dir="C:/Tomcat6/webapps/outbound" />

                                          </tasks>

                                    </configuration>

                                    <goals>

                                          <goal>run</goal>

                                    </goals>

                              </execution>

                              <execution>

                                    <phase>compile</phase>

                                    <id>copy-resources2classes</id>

                                    <configuration>

                                          <tasks>

                                                <echo>Copying resources
to WEB-INF/classes..</echo>

                                                <copy todir="src" >

                                                      <fileset
dir="target/classes" >

                                                            <include
name="**/*.properties" />

                                                            <include
name="**/*.*" />

                                                      </fileset>

                                                </copy>

                                          </tasks>

                                    </configuration>

                                    <goals>

                                          <goal>run</goal>

                                    </goals>

                              </execution>

                        </executions>

      </plugin>

      </plugins>                    

</build>

</project>

**

 

Can you please help me ?

 

Thanks,

Amol Fuke

 


Re: Unwanted jars getting copied

Posted by Baptiste MATHUS <ml...@batmat.net>.
Hi,
This is not the right mailing list for this kind of question. This list is
dedicated to Maven development.

Please write to users@maven.apache.org instead.

Cheers
Le 25 févr. 2011 12:34, "Fuke, Amol" <Am...@nielsen.com> a écrit :
> Hi All ,
>
> I am using below snippet to copy dependant jars from lib to war. But this
also copying some unwanted jars like rt.jar and tools.jar.
>
> Is there any way I exclude them from getting copied into my war.
>
>
> <plugin>
> <artifactId>maven-dependency-plugin</artifactId>
> <executions>
> <execution>
> <phase>install</phase>
> <goals>
> <goal>copy-dependencies</goal>
> </goals>
> <configuration>
> <outputDirectory>${project.build.directory}/lib</outputDirectory>
> </configuration>
> </execution>
> </executions>
> </plugin>
>
> Thanks,
> Amol

Unwanted jars getting copied

Posted by "Fuke, Amol" <Am...@nielsen.com>.
Hi All ,

I am using below snippet to copy dependant jars from lib to war. But this also copying some unwanted jars like rt.jar and tools.jar.

Is there any way I exclude them from getting copied into my war.


<plugin> 
       <artifactId>maven-dependency-plugin</artifactId> 
                            <executions> 
                                <execution> 
                                    <phase>install</phase> 
                                    <goals> 
                                        <goal>copy-dependencies</goal> 
                                    </goals> 
                                    <configuration> 
                                        <outputDirectory>${project.build.directory}/lib</outputDirectory> 
                                    </configuration> 
                                </execution> 
                            </executions> 
                    </plugin>

Thanks,
Amol

Re: How to compile code using maven

Posted by Benson Margulies <bi...@gmail.com>.
you deploy them to a repository and then list them as dependencies.

On Feb 24, 2011, at 4:00 AM, "Fuke, Amol" <Am...@nielsen.com> wrote:

> Thanks Ben. I did as suggested by Nicolas and able to compile the project. However I am facing another problem.
> How do I copy all the jars in lib folder to my war file which is prepared by 'mvn package'. These jars are required for running my webapp.
>
> Any suggestion ?
>
> Thanks in advance.
>
> Thanks,
> Amol
>
> -----Original Message-----
> From: Benson Margulies [mailto:bimargulies@gmail.com]
> Sent: Wednesday, February 23, 2011 7:23 PM
> To: Maven Developers List
> Subject: Re: How to compile code using maven
>
> are you sure you want a maven build? if you have an elaborate ant
> build you can use the maven any tasks to consume and/or produce
> artifacts.
>
> On Feb 23, 2011, at 8:45 AM, oliver <ol...@gmail.com> wrote:
>
>> Hi,
>>
>> as suggested by Nicolas you should adapt you project structure according the maven guideline. But as I know from several projects moved from Ant to Maven this is not always possible. You can tell Maven your project structure as described on my blog at http://oli.blogger.de/stories/1689356/:
>>
>> <build>
>> ...
>> <sourceDirectory>${basedir}/src</sourceDirectory>
>> <testSourceDirectory>${basedir}/test</testSourceDirectory>
>> <resources>
>>   <resource>
>>     <directory>src</directory>
>>   </resource>
>> </resources>
>> <testResources>
>>   <testResource>
>>     <directory>test</directory>
>>   </testResource>
>> </testResources>
>> ...
>> </build>
>>
>> Hope that helps
>> Oliver
>>
>>
>>
>> Am 23.02.2011 um 11:34 schrieb nicolas de loof:
>>
>>> Don't consider Maven as a scripting engine
>>> Maven works based on conventions, and plugins use them to avoid
>>> configuration and scripting
>>>
>>> Don't try to override conventions as you do in compiler, war plugin. Follow
>>> them and discover how the plugins can naturaly run in your build without
>>> anything to configure.
>>>
>>> Move your java source folder at "src/main/java"
>>> Move your web application descriptor at src/main/webapp/WEB-INF
>>> remove all your configuration stuff, especially your antrun attempt to
>>> script the build
>>> just run "mvn install"
>>>
>>> you will get a packaged WAR you can deploy on tomcat,
>>> you can also configure your local tomcat instance to use the exploded war at
>>> target/youratifact-version
>>>
>>> Good luck with Maven
>>> (I just suggest you to take few minutes and read a good introduction to
>>> maven to better understand its principles)
>>>
>>> Nicolas
>>>
>>> 2011/2/23 Fuke, Amol <Am...@nielsen.com>
>>>
>>>> Hi All,
>>>>
>>>>
>>>>
>>>> I have ant build file and now need to convert it into mvn pom file. My
>>>> problem is how do I get my code compiled using pom.xml.
>>>>
>>>>
>>>>
>>>> I have below pom xml;
>>>>
>>>> ***
>>>>
>>>> <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>com.nielsen.outbound</groupId>
>>>>
>>>> <artifactId>outbound</artifactId>
>>>>
>>>> <packaging>war</packaging>
>>>>
>>>> <version>1.0-SNAPSHOT</version>
>>>>
>>>> <name>outbound</name>
>>>>
>>>> <url>http://maven.apache.org</url>
>>>>
>>>> <dependencies>
>>>>
>>>> <dependency>
>>>>
>>>>   <groupId>junit</groupId>
>>>>
>>>>   <artifactId>junit</artifactId>
>>>>
>>>>   <version>3.8.1</version>
>>>>
>>>>   <scope>test</scope>
>>>>
>>>> </dependency>
>>>>
>>>> </dependencies>
>>>>
>>>> <build>
>>>>
>>>> <plugins>
>>>>
>>>> <plugin>
>>>>
>>>>                     <groupId>org.apache.maven.plugins</groupId>
>>>>
>>>>                     <artifactId>maven-compiler-plugin</artifactId>
>>>>
>>>>                     <configuration>
>>>>
>>>>
>>>> <source>src/com/nielsen/outbound/*.java</source>
>>>>
>>>>                           <target>target/classes</target>
>>>>
>>>>                     </configuration>
>>>>
>>>>               </plugin>
>>>>
>>>>               <plugin>
>>>>
>>>>                     <groupId>org.apache.maven.plugins</groupId>
>>>>
>>>>                     <artifactId>maven-war-plugin</artifactId>
>>>>
>>>>                     <configuration>
>>>>
>>>>                           <webXml>conf/web.xml</webXml>
>>>>
>>>>
>>>> <webappDirectory>target/work/outbound.war</webappDirectory>
>>>>
>>>>                     </configuration>
>>>>
>>>>               </plugin>
>>>>
>>>>   <plugin>
>>>>
>>>>                     <groupId>org.apache.maven.plugins</groupId>
>>>>
>>>>                     <artifactId>maven-antrun-plugin</artifactId>
>>>>
>>>>                     <executions>
>>>>
>>>>                           <execution>
>>>>
>>>>                                 <phase>compile</phase>
>>>>
>>>>                                 <configuration>
>>>>
>>>>                                       <tasks>
>>>>
>>>>                                             <echo>Deleting
>>>> deployment..</echo>
>>>>
>>>>                                             <delete
>>>> includeEmptyDirs="true"
>>>>
>>>>
>>>> dir="C:/Tomcat6/webapps/outbound" />
>>>>
>>>>                                             <mkdir
>>>> dir="C:/Tomcat6/webapps/outbound" />
>>>>
>>>>                                       </tasks>
>>>>
>>>>                                 </configuration>
>>>>
>>>>                                 <goals>
>>>>
>>>>                                       <goal>run</goal>
>>>>
>>>>                                 </goals>
>>>>
>>>>                           </execution>
>>>>
>>>>                           <execution>
>>>>
>>>>                                 <phase>compile</phase>
>>>>
>>>>                                 <id>copy-resources2classes</id>
>>>>
>>>>                                 <configuration>
>>>>
>>>>                                       <tasks>
>>>>
>>>>                                             <echo>Copying resources
>>>> to WEB-INF/classes..</echo>
>>>>
>>>>                                             <copy todir="src" >
>>>>
>>>>                                                   <fileset
>>>> dir="target/classes" >
>>>>
>>>>                                                         <include
>>>> name="**/*.properties" />
>>>>
>>>>                                                         <include
>>>> name="**/*.*" />
>>>>
>>>>                                                   </fileset>
>>>>
>>>>                                             </copy>
>>>>
>>>>                                       </tasks>
>>>>
>>>>                                 </configuration>
>>>>
>>>>                                 <goals>
>>>>
>>>>                                       <goal>run</goal>
>>>>
>>>>                                 </goals>
>>>>
>>>>                           </execution>
>>>>
>>>>                     </executions>
>>>>
>>>>   </plugin>
>>>>
>>>>   </plugins>
>>>>
>>>> </build>
>>>>
>>>> </project>
>>>>
>>>> **
>>>>
>>>>
>>>>
>>>> Can you please help me ?
>>>>
>>>>
>>>>
>>>> Thanks,
>>>>
>>>> Amol Fuke
>>>>
>>>>
>>>>
>>>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>

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


Re: How to compile code using maven

Posted by Stephen Connolly <st...@gmail.com>.
On 24 February 2011 08:57, Fuke, Amol <Am...@nielsen.com> wrote:

> Thanks Ben. I did as suggested by Nicolas and able to compile the project.
> However I am facing another problem.
> How do I copy all the jars in lib folder to my war file which is prepared
> by 'mvn package'. These jars are required for running my webapp.
>

You don't

I'm not being glib

You declare dependencies for the jars that you want to end up in the
WEB-INF/lib folder (either transitively or directly in the war module) and
Maven will find the jars (from the maven repository) and copy them in place
for you...

If your jars are not available in a public maven repository you can either
install them into your local maven repository (i.e. the cache on your
machine) with mvn install:install-file or you can use a maven repository
manager (i.e. nexus or artifactory) and deploy them to that (another option
is to publish the jars to a public maven repository, but typically that is
not a real option unless they are open source jars)

There are numerous "hacks" that people try and use to work around the above
2.5 solutions.... such hacks will cause you to hate maven and say it is a
useless build tool, so don't do them

-Stephen

>
> Any suggestion ?
>
> Thanks in advance.
>
> Thanks,
> Amol
>
> -----Original Message-----
> From: Benson Margulies [mailto:bimargulies@gmail.com]
> Sent: Wednesday, February 23, 2011 7:23 PM
> To: Maven Developers List
> Subject: Re: How to compile code using maven
>
> are you sure you want a maven build? if you have an elaborate ant
> build you can use the maven any tasks to consume and/or produce
> artifacts.
>
> On Feb 23, 2011, at 8:45 AM, oliver <ol...@gmail.com> wrote:
>
> > Hi,
> >
> > as suggested by Nicolas you should adapt you project structure according
> the maven guideline. But as I know from several projects moved from Ant to
> Maven this is not always possible. You can tell Maven your project structure
> as described on my blog at http://oli.blogger.de/stories/1689356/:
> >
> > <build>
> >  ...
> >  <sourceDirectory>${basedir}/src</sourceDirectory>
> >  <testSourceDirectory>${basedir}/test</testSourceDirectory>
> >  <resources>
> >    <resource>
> >      <directory>src</directory>
> >    </resource>
> >  </resources>
> >  <testResources>
> >    <testResource>
> >      <directory>test</directory>
> >    </testResource>
> >  </testResources>
> >  ...
> > </build>
> >
> > Hope that helps
> > Oliver
> >
> >
> >
> > Am 23.02.2011 um 11:34 schrieb nicolas de loof:
> >
> >> Don't consider Maven as a scripting engine
> >> Maven works based on conventions, and plugins use them to avoid
> >> configuration and scripting
> >>
> >> Don't try to override conventions as you do in compiler, war plugin.
> Follow
> >> them and discover how the plugins can naturaly run in your build without
> >> anything to configure.
> >>
> >> Move your java source folder at "src/main/java"
> >> Move your web application descriptor at src/main/webapp/WEB-INF
> >> remove all your configuration stuff, especially your antrun attempt to
> >> script the build
> >> just run "mvn install"
> >>
> >> you will get a packaged WAR you can deploy on tomcat,
> >> you can also configure your local tomcat instance to use the exploded
> war at
> >> target/youratifact-version
> >>
> >> Good luck with Maven
> >> (I just suggest you to take few minutes and read a good introduction to
> >> maven to better understand its principles)
> >>
> >> Nicolas
> >>
> >> 2011/2/23 Fuke, Amol <Am...@nielsen.com>
> >>
> >>> Hi All,
> >>>
> >>>
> >>>
> >>> I have ant build file and now need to convert it into mvn pom file. My
> >>> problem is how do I get my code compiled using pom.xml.
> >>>
> >>>
> >>>
> >>> I have below pom xml;
> >>>
> >>> ***
> >>>
> >>> <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>com.nielsen.outbound</groupId>
> >>>
> >>> <artifactId>outbound</artifactId>
> >>>
> >>> <packaging>war</packaging>
> >>>
> >>> <version>1.0-SNAPSHOT</version>
> >>>
> >>> <name>outbound</name>
> >>>
> >>> <url>http://maven.apache.org</url>
> >>>
> >>> <dependencies>
> >>>
> >>>  <dependency>
> >>>
> >>>    <groupId>junit</groupId>
> >>>
> >>>    <artifactId>junit</artifactId>
> >>>
> >>>    <version>3.8.1</version>
> >>>
> >>>    <scope>test</scope>
> >>>
> >>>  </dependency>
> >>>
> >>> </dependencies>
> >>>
> >>> <build>
> >>>
> >>> <plugins>
> >>>
> >>> <plugin>
> >>>
> >>>                      <groupId>org.apache.maven.plugins</groupId>
> >>>
> >>>                      <artifactId>maven-compiler-plugin</artifactId>
> >>>
> >>>                      <configuration>
> >>>
> >>>
> >>> <source>src/com/nielsen/outbound/*.java</source>
> >>>
> >>>                            <target>target/classes</target>
> >>>
> >>>                      </configuration>
> >>>
> >>>                </plugin>
> >>>
> >>>                <plugin>
> >>>
> >>>                      <groupId>org.apache.maven.plugins</groupId>
> >>>
> >>>                      <artifactId>maven-war-plugin</artifactId>
> >>>
> >>>                      <configuration>
> >>>
> >>>                            <webXml>conf/web.xml</webXml>
> >>>
> >>>
> >>> <webappDirectory>target/work/outbound.war</webappDirectory>
> >>>
> >>>                      </configuration>
> >>>
> >>>                </plugin>
> >>>
> >>>    <plugin>
> >>>
> >>>                      <groupId>org.apache.maven.plugins</groupId>
> >>>
> >>>                      <artifactId>maven-antrun-plugin</artifactId>
> >>>
> >>>                      <executions>
> >>>
> >>>                            <execution>
> >>>
> >>>                                  <phase>compile</phase>
> >>>
> >>>                                  <configuration>
> >>>
> >>>                                        <tasks>
> >>>
> >>>                                              <echo>Deleting
> >>> deployment..</echo>
> >>>
> >>>                                              <delete
> >>> includeEmptyDirs="true"
> >>>
> >>>
> >>> dir="C:/Tomcat6/webapps/outbound" />
> >>>
> >>>                                              <mkdir
> >>> dir="C:/Tomcat6/webapps/outbound" />
> >>>
> >>>                                        </tasks>
> >>>
> >>>                                  </configuration>
> >>>
> >>>                                  <goals>
> >>>
> >>>                                        <goal>run</goal>
> >>>
> >>>                                  </goals>
> >>>
> >>>                            </execution>
> >>>
> >>>                            <execution>
> >>>
> >>>                                  <phase>compile</phase>
> >>>
> >>>                                  <id>copy-resources2classes</id>
> >>>
> >>>                                  <configuration>
> >>>
> >>>                                        <tasks>
> >>>
> >>>                                              <echo>Copying resources
> >>> to WEB-INF/classes..</echo>
> >>>
> >>>                                              <copy todir="src" >
> >>>
> >>>                                                    <fileset
> >>> dir="target/classes" >
> >>>
> >>>                                                          <include
> >>> name="**/*.properties" />
> >>>
> >>>                                                          <include
> >>> name="**/*.*" />
> >>>
> >>>                                                    </fileset>
> >>>
> >>>                                              </copy>
> >>>
> >>>                                        </tasks>
> >>>
> >>>                                  </configuration>
> >>>
> >>>                                  <goals>
> >>>
> >>>                                        <goal>run</goal>
> >>>
> >>>                                  </goals>
> >>>
> >>>                            </execution>
> >>>
> >>>                      </executions>
> >>>
> >>>    </plugin>
> >>>
> >>>    </plugins>
> >>>
> >>> </build>
> >>>
> >>> </project>
> >>>
> >>> **
> >>>
> >>>
> >>>
> >>> Can you please help me ?
> >>>
> >>>
> >>>
> >>> Thanks,
> >>>
> >>> Amol Fuke
> >>>
> >>>
> >>>
> >>>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>

RE: How to compile code using maven

Posted by "Fuke, Amol" <Am...@nielsen.com>.
Thanks Ben. I did as suggested by Nicolas and able to compile the project. However I am facing another problem.
How do I copy all the jars in lib folder to my war file which is prepared by 'mvn package'. These jars are required for running my webapp.

Any suggestion ?

Thanks in advance.

Thanks,
Amol

-----Original Message-----
From: Benson Margulies [mailto:bimargulies@gmail.com] 
Sent: Wednesday, February 23, 2011 7:23 PM
To: Maven Developers List
Subject: Re: How to compile code using maven

are you sure you want a maven build? if you have an elaborate ant
build you can use the maven any tasks to consume and/or produce
artifacts.

On Feb 23, 2011, at 8:45 AM, oliver <ol...@gmail.com> wrote:

> Hi,
>
> as suggested by Nicolas you should adapt you project structure according the maven guideline. But as I know from several projects moved from Ant to Maven this is not always possible. You can tell Maven your project structure as described on my blog at http://oli.blogger.de/stories/1689356/:
>
> <build>
>  ...
>  <sourceDirectory>${basedir}/src</sourceDirectory>
>  <testSourceDirectory>${basedir}/test</testSourceDirectory>
>  <resources>
>    <resource>
>      <directory>src</directory>
>    </resource>
>  </resources>
>  <testResources>
>    <testResource>
>      <directory>test</directory>
>    </testResource>
>  </testResources>
>  ...
> </build>
>
> Hope that helps
> Oliver
>
>
>
> Am 23.02.2011 um 11:34 schrieb nicolas de loof:
>
>> Don't consider Maven as a scripting engine
>> Maven works based on conventions, and plugins use them to avoid
>> configuration and scripting
>>
>> Don't try to override conventions as you do in compiler, war plugin. Follow
>> them and discover how the plugins can naturaly run in your build without
>> anything to configure.
>>
>> Move your java source folder at "src/main/java"
>> Move your web application descriptor at src/main/webapp/WEB-INF
>> remove all your configuration stuff, especially your antrun attempt to
>> script the build
>> just run "mvn install"
>>
>> you will get a packaged WAR you can deploy on tomcat,
>> you can also configure your local tomcat instance to use the exploded war at
>> target/youratifact-version
>>
>> Good luck with Maven
>> (I just suggest you to take few minutes and read a good introduction to
>> maven to better understand its principles)
>>
>> Nicolas
>>
>> 2011/2/23 Fuke, Amol <Am...@nielsen.com>
>>
>>> Hi All,
>>>
>>>
>>>
>>> I have ant build file and now need to convert it into mvn pom file. My
>>> problem is how do I get my code compiled using pom.xml.
>>>
>>>
>>>
>>> I have below pom xml;
>>>
>>> ***
>>>
>>> <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>com.nielsen.outbound</groupId>
>>>
>>> <artifactId>outbound</artifactId>
>>>
>>> <packaging>war</packaging>
>>>
>>> <version>1.0-SNAPSHOT</version>
>>>
>>> <name>outbound</name>
>>>
>>> <url>http://maven.apache.org</url>
>>>
>>> <dependencies>
>>>
>>>  <dependency>
>>>
>>>    <groupId>junit</groupId>
>>>
>>>    <artifactId>junit</artifactId>
>>>
>>>    <version>3.8.1</version>
>>>
>>>    <scope>test</scope>
>>>
>>>  </dependency>
>>>
>>> </dependencies>
>>>
>>> <build>
>>>
>>> <plugins>
>>>
>>> <plugin>
>>>
>>>                      <groupId>org.apache.maven.plugins</groupId>
>>>
>>>                      <artifactId>maven-compiler-plugin</artifactId>
>>>
>>>                      <configuration>
>>>
>>>
>>> <source>src/com/nielsen/outbound/*.java</source>
>>>
>>>                            <target>target/classes</target>
>>>
>>>                      </configuration>
>>>
>>>                </plugin>
>>>
>>>                <plugin>
>>>
>>>                      <groupId>org.apache.maven.plugins</groupId>
>>>
>>>                      <artifactId>maven-war-plugin</artifactId>
>>>
>>>                      <configuration>
>>>
>>>                            <webXml>conf/web.xml</webXml>
>>>
>>>
>>> <webappDirectory>target/work/outbound.war</webappDirectory>
>>>
>>>                      </configuration>
>>>
>>>                </plugin>
>>>
>>>    <plugin>
>>>
>>>                      <groupId>org.apache.maven.plugins</groupId>
>>>
>>>                      <artifactId>maven-antrun-plugin</artifactId>
>>>
>>>                      <executions>
>>>
>>>                            <execution>
>>>
>>>                                  <phase>compile</phase>
>>>
>>>                                  <configuration>
>>>
>>>                                        <tasks>
>>>
>>>                                              <echo>Deleting
>>> deployment..</echo>
>>>
>>>                                              <delete
>>> includeEmptyDirs="true"
>>>
>>>
>>> dir="C:/Tomcat6/webapps/outbound" />
>>>
>>>                                              <mkdir
>>> dir="C:/Tomcat6/webapps/outbound" />
>>>
>>>                                        </tasks>
>>>
>>>                                  </configuration>
>>>
>>>                                  <goals>
>>>
>>>                                        <goal>run</goal>
>>>
>>>                                  </goals>
>>>
>>>                            </execution>
>>>
>>>                            <execution>
>>>
>>>                                  <phase>compile</phase>
>>>
>>>                                  <id>copy-resources2classes</id>
>>>
>>>                                  <configuration>
>>>
>>>                                        <tasks>
>>>
>>>                                              <echo>Copying resources
>>> to WEB-INF/classes..</echo>
>>>
>>>                                              <copy todir="src" >
>>>
>>>                                                    <fileset
>>> dir="target/classes" >
>>>
>>>                                                          <include
>>> name="**/*.properties" />
>>>
>>>                                                          <include
>>> name="**/*.*" />
>>>
>>>                                                    </fileset>
>>>
>>>                                              </copy>
>>>
>>>                                        </tasks>
>>>
>>>                                  </configuration>
>>>
>>>                                  <goals>
>>>
>>>                                        <goal>run</goal>
>>>
>>>                                  </goals>
>>>
>>>                            </execution>
>>>
>>>                      </executions>
>>>
>>>    </plugin>
>>>
>>>    </plugins>
>>>
>>> </build>
>>>
>>> </project>
>>>
>>> **
>>>
>>>
>>>
>>> Can you please help me ?
>>>
>>>
>>>
>>> Thanks,
>>>
>>> Amol Fuke
>>>
>>>
>>>
>>>
>

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


Re: How to compile code using maven

Posted by Benson Margulies <bi...@gmail.com>.
are you sure you want a maven build? if you have an elaborate ant
build you can use the maven any tasks to consume and/or produce
artifacts.

On Feb 23, 2011, at 8:45 AM, oliver <ol...@gmail.com> wrote:

> Hi,
>
> as suggested by Nicolas you should adapt you project structure according the maven guideline. But as I know from several projects moved from Ant to Maven this is not always possible. You can tell Maven your project structure as described on my blog at http://oli.blogger.de/stories/1689356/:
>
> <build>
>  ...
>  <sourceDirectory>${basedir}/src</sourceDirectory>
>  <testSourceDirectory>${basedir}/test</testSourceDirectory>
>  <resources>
>    <resource>
>      <directory>src</directory>
>    </resource>
>  </resources>
>  <testResources>
>    <testResource>
>      <directory>test</directory>
>    </testResource>
>  </testResources>
>  ...
> </build>
>
> Hope that helps
> Oliver
>
>
>
> Am 23.02.2011 um 11:34 schrieb nicolas de loof:
>
>> Don't consider Maven as a scripting engine
>> Maven works based on conventions, and plugins use them to avoid
>> configuration and scripting
>>
>> Don't try to override conventions as you do in compiler, war plugin. Follow
>> them and discover how the plugins can naturaly run in your build without
>> anything to configure.
>>
>> Move your java source folder at "src/main/java"
>> Move your web application descriptor at src/main/webapp/WEB-INF
>> remove all your configuration stuff, especially your antrun attempt to
>> script the build
>> just run "mvn install"
>>
>> you will get a packaged WAR you can deploy on tomcat,
>> you can also configure your local tomcat instance to use the exploded war at
>> target/youratifact-version
>>
>> Good luck with Maven
>> (I just suggest you to take few minutes and read a good introduction to
>> maven to better understand its principles)
>>
>> Nicolas
>>
>> 2011/2/23 Fuke, Amol <Am...@nielsen.com>
>>
>>> Hi All,
>>>
>>>
>>>
>>> I have ant build file and now need to convert it into mvn pom file. My
>>> problem is how do I get my code compiled using pom.xml.
>>>
>>>
>>>
>>> I have below pom xml;
>>>
>>> ***
>>>
>>> <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>com.nielsen.outbound</groupId>
>>>
>>> <artifactId>outbound</artifactId>
>>>
>>> <packaging>war</packaging>
>>>
>>> <version>1.0-SNAPSHOT</version>
>>>
>>> <name>outbound</name>
>>>
>>> <url>http://maven.apache.org</url>
>>>
>>> <dependencies>
>>>
>>>  <dependency>
>>>
>>>    <groupId>junit</groupId>
>>>
>>>    <artifactId>junit</artifactId>
>>>
>>>    <version>3.8.1</version>
>>>
>>>    <scope>test</scope>
>>>
>>>  </dependency>
>>>
>>> </dependencies>
>>>
>>> <build>
>>>
>>> <plugins>
>>>
>>> <plugin>
>>>
>>>                      <groupId>org.apache.maven.plugins</groupId>
>>>
>>>                      <artifactId>maven-compiler-plugin</artifactId>
>>>
>>>                      <configuration>
>>>
>>>
>>> <source>src/com/nielsen/outbound/*.java</source>
>>>
>>>                            <target>target/classes</target>
>>>
>>>                      </configuration>
>>>
>>>                </plugin>
>>>
>>>                <plugin>
>>>
>>>                      <groupId>org.apache.maven.plugins</groupId>
>>>
>>>                      <artifactId>maven-war-plugin</artifactId>
>>>
>>>                      <configuration>
>>>
>>>                            <webXml>conf/web.xml</webXml>
>>>
>>>
>>> <webappDirectory>target/work/outbound.war</webappDirectory>
>>>
>>>                      </configuration>
>>>
>>>                </plugin>
>>>
>>>    <plugin>
>>>
>>>                      <groupId>org.apache.maven.plugins</groupId>
>>>
>>>                      <artifactId>maven-antrun-plugin</artifactId>
>>>
>>>                      <executions>
>>>
>>>                            <execution>
>>>
>>>                                  <phase>compile</phase>
>>>
>>>                                  <configuration>
>>>
>>>                                        <tasks>
>>>
>>>                                              <echo>Deleting
>>> deployment..</echo>
>>>
>>>                                              <delete
>>> includeEmptyDirs="true"
>>>
>>>
>>> dir="C:/Tomcat6/webapps/outbound" />
>>>
>>>                                              <mkdir
>>> dir="C:/Tomcat6/webapps/outbound" />
>>>
>>>                                        </tasks>
>>>
>>>                                  </configuration>
>>>
>>>                                  <goals>
>>>
>>>                                        <goal>run</goal>
>>>
>>>                                  </goals>
>>>
>>>                            </execution>
>>>
>>>                            <execution>
>>>
>>>                                  <phase>compile</phase>
>>>
>>>                                  <id>copy-resources2classes</id>
>>>
>>>                                  <configuration>
>>>
>>>                                        <tasks>
>>>
>>>                                              <echo>Copying resources
>>> to WEB-INF/classes..</echo>
>>>
>>>                                              <copy todir="src" >
>>>
>>>                                                    <fileset
>>> dir="target/classes" >
>>>
>>>                                                          <include
>>> name="**/*.properties" />
>>>
>>>                                                          <include
>>> name="**/*.*" />
>>>
>>>                                                    </fileset>
>>>
>>>                                              </copy>
>>>
>>>                                        </tasks>
>>>
>>>                                  </configuration>
>>>
>>>                                  <goals>
>>>
>>>                                        <goal>run</goal>
>>>
>>>                                  </goals>
>>>
>>>                            </execution>
>>>
>>>                      </executions>
>>>
>>>    </plugin>
>>>
>>>    </plugins>
>>>
>>> </build>
>>>
>>> </project>
>>>
>>> **
>>>
>>>
>>>
>>> Can you please help me ?
>>>
>>>
>>>
>>> Thanks,
>>>
>>> Amol Fuke
>>>
>>>
>>>
>>>
>

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


Re: How to compile code using maven

Posted by oliver <ol...@gmail.com>.
Hi,

as suggested by Nicolas you should adapt you project structure according the maven guideline. But as I know from several projects moved from Ant to Maven this is not always possible. You can tell Maven your project structure as described on my blog at http://oli.blogger.de/stories/1689356/:

<build>
  ...
  <sourceDirectory>${basedir}/src</sourceDirectory>
  <testSourceDirectory>${basedir}/test</testSourceDirectory>
  <resources>
    <resource>
      <directory>src</directory>
    </resource>
  </resources>
  <testResources>
    <testResource>
      <directory>test</directory>
    </testResource>
  </testResources>
  ...
</build>

Hope that helps
Oliver



Am 23.02.2011 um 11:34 schrieb nicolas de loof:

> Don't consider Maven as a scripting engine
> Maven works based on conventions, and plugins use them to avoid
> configuration and scripting
> 
> Don't try to override conventions as you do in compiler, war plugin. Follow
> them and discover how the plugins can naturaly run in your build without
> anything to configure.
> 
> Move your java source folder at "src/main/java"
> Move your web application descriptor at src/main/webapp/WEB-INF
> remove all your configuration stuff, especially your antrun attempt to
> script the build
> just run "mvn install"
> 
> you will get a packaged WAR you can deploy on tomcat,
> you can also configure your local tomcat instance to use the exploded war at
> target/youratifact-version
> 
> Good luck with Maven
> (I just suggest you to take few minutes and read a good introduction to
> maven to better understand its principles)
> 
> Nicolas
> 
> 2011/2/23 Fuke, Amol <Am...@nielsen.com>
> 
>> Hi All,
>> 
>> 
>> 
>> I have ant build file and now need to convert it into mvn pom file. My
>> problem is how do I get my code compiled using pom.xml.
>> 
>> 
>> 
>> I have below pom xml;
>> 
>> ***
>> 
>> <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>com.nielsen.outbound</groupId>
>> 
>> <artifactId>outbound</artifactId>
>> 
>> <packaging>war</packaging>
>> 
>> <version>1.0-SNAPSHOT</version>
>> 
>> <name>outbound</name>
>> 
>> <url>http://maven.apache.org</url>
>> 
>> <dependencies>
>> 
>>   <dependency>
>> 
>>     <groupId>junit</groupId>
>> 
>>     <artifactId>junit</artifactId>
>> 
>>     <version>3.8.1</version>
>> 
>>     <scope>test</scope>
>> 
>>   </dependency>
>> 
>> </dependencies>
>> 
>> <build>
>> 
>> <plugins>
>> 
>> <plugin>
>> 
>>                       <groupId>org.apache.maven.plugins</groupId>
>> 
>>                       <artifactId>maven-compiler-plugin</artifactId>
>> 
>>                       <configuration>
>> 
>> 
>> <source>src/com/nielsen/outbound/*.java</source>
>> 
>>                             <target>target/classes</target>
>> 
>>                       </configuration>
>> 
>>                 </plugin>
>> 
>>                 <plugin>
>> 
>>                       <groupId>org.apache.maven.plugins</groupId>
>> 
>>                       <artifactId>maven-war-plugin</artifactId>
>> 
>>                       <configuration>
>> 
>>                             <webXml>conf/web.xml</webXml>
>> 
>> 
>> <webappDirectory>target/work/outbound.war</webappDirectory>
>> 
>>                       </configuration>
>> 
>>                 </plugin>
>> 
>>     <plugin>
>> 
>>                       <groupId>org.apache.maven.plugins</groupId>
>> 
>>                       <artifactId>maven-antrun-plugin</artifactId>
>> 
>>                       <executions>
>> 
>>                             <execution>
>> 
>>                                   <phase>compile</phase>
>> 
>>                                   <configuration>
>> 
>>                                         <tasks>
>> 
>>                                               <echo>Deleting
>> deployment..</echo>
>> 
>>                                               <delete
>> includeEmptyDirs="true"
>> 
>> 
>> dir="C:/Tomcat6/webapps/outbound" />
>> 
>>                                               <mkdir
>> dir="C:/Tomcat6/webapps/outbound" />
>> 
>>                                         </tasks>
>> 
>>                                   </configuration>
>> 
>>                                   <goals>
>> 
>>                                         <goal>run</goal>
>> 
>>                                   </goals>
>> 
>>                             </execution>
>> 
>>                             <execution>
>> 
>>                                   <phase>compile</phase>
>> 
>>                                   <id>copy-resources2classes</id>
>> 
>>                                   <configuration>
>> 
>>                                         <tasks>
>> 
>>                                               <echo>Copying resources
>> to WEB-INF/classes..</echo>
>> 
>>                                               <copy todir="src" >
>> 
>>                                                     <fileset
>> dir="target/classes" >
>> 
>>                                                           <include
>> name="**/*.properties" />
>> 
>>                                                           <include
>> name="**/*.*" />
>> 
>>                                                     </fileset>
>> 
>>                                               </copy>
>> 
>>                                         </tasks>
>> 
>>                                   </configuration>
>> 
>>                                   <goals>
>> 
>>                                         <goal>run</goal>
>> 
>>                                   </goals>
>> 
>>                             </execution>
>> 
>>                       </executions>
>> 
>>     </plugin>
>> 
>>     </plugins>
>> 
>> </build>
>> 
>> </project>
>> 
>> **
>> 
>> 
>> 
>> Can you please help me ?
>> 
>> 
>> 
>> Thanks,
>> 
>> Amol Fuke
>> 
>> 
>> 
>> 


Re: How to compile code using maven

Posted by nicolas de loof <ni...@gmail.com>.
Don't consider Maven as a scripting engine
Maven works based on conventions, and plugins use them to avoid
configuration and scripting

Don't try to override conventions as you do in compiler, war plugin. Follow
them and discover how the plugins can naturaly run in your build without
anything to configure.

Move your java source folder at "src/main/java"
Move your web application descriptor at src/main/webapp/WEB-INF
remove all your configuration stuff, especially your antrun attempt to
script the build
just run "mvn install"

you will get a packaged WAR you can deploy on tomcat,
you can also configure your local tomcat instance to use the exploded war at
target/youratifact-version

Good luck with Maven
(I just suggest you to take few minutes and read a good introduction to
maven to better understand its principles)

Nicolas

2011/2/23 Fuke, Amol <Am...@nielsen.com>

> Hi All,
>
>
>
> I have ant build file and now need to convert it into mvn pom file. My
> problem is how do I get my code compiled using pom.xml.
>
>
>
> I have below pom xml;
>
> ***
>
> <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>com.nielsen.outbound</groupId>
>
>  <artifactId>outbound</artifactId>
>
>  <packaging>war</packaging>
>
>  <version>1.0-SNAPSHOT</version>
>
>  <name>outbound</name>
>
>  <url>http://maven.apache.org</url>
>
>  <dependencies>
>
>    <dependency>
>
>      <groupId>junit</groupId>
>
>      <artifactId>junit</artifactId>
>
>      <version>3.8.1</version>
>
>      <scope>test</scope>
>
>    </dependency>
>
>  </dependencies>
>
>  <build>
>
>  <plugins>
>
>  <plugin>
>
>                        <groupId>org.apache.maven.plugins</groupId>
>
>                        <artifactId>maven-compiler-plugin</artifactId>
>
>                        <configuration>
>
>
> <source>src/com/nielsen/outbound/*.java</source>
>
>                              <target>target/classes</target>
>
>                        </configuration>
>
>                  </plugin>
>
>                  <plugin>
>
>                        <groupId>org.apache.maven.plugins</groupId>
>
>                        <artifactId>maven-war-plugin</artifactId>
>
>                        <configuration>
>
>                              <webXml>conf/web.xml</webXml>
>
>
> <webappDirectory>target/work/outbound.war</webappDirectory>
>
>                        </configuration>
>
>                  </plugin>
>
>      <plugin>
>
>                        <groupId>org.apache.maven.plugins</groupId>
>
>                        <artifactId>maven-antrun-plugin</artifactId>
>
>                        <executions>
>
>                              <execution>
>
>                                    <phase>compile</phase>
>
>                                    <configuration>
>
>                                          <tasks>
>
>                                                <echo>Deleting
> deployment..</echo>
>
>                                                <delete
> includeEmptyDirs="true"
>
>
> dir="C:/Tomcat6/webapps/outbound" />
>
>                                                <mkdir
> dir="C:/Tomcat6/webapps/outbound" />
>
>                                          </tasks>
>
>                                    </configuration>
>
>                                    <goals>
>
>                                          <goal>run</goal>
>
>                                    </goals>
>
>                              </execution>
>
>                              <execution>
>
>                                    <phase>compile</phase>
>
>                                    <id>copy-resources2classes</id>
>
>                                    <configuration>
>
>                                          <tasks>
>
>                                                <echo>Copying resources
> to WEB-INF/classes..</echo>
>
>                                                <copy todir="src" >
>
>                                                      <fileset
> dir="target/classes" >
>
>                                                            <include
> name="**/*.properties" />
>
>                                                            <include
> name="**/*.*" />
>
>                                                      </fileset>
>
>                                                </copy>
>
>                                          </tasks>
>
>                                    </configuration>
>
>                                    <goals>
>
>                                          <goal>run</goal>
>
>                                    </goals>
>
>                              </execution>
>
>                        </executions>
>
>      </plugin>
>
>      </plugins>
>
> </build>
>
> </project>
>
> **
>
>
>
> Can you please help me ?
>
>
>
> Thanks,
>
> Amol Fuke
>
>
>
>