On 24 February 2011 08:57, Fuke, Amol <[email protected]> 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:[email protected]] > 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 <[email protected]> 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 <[email protected]> > >> > >>> 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: [email protected] > For additional commands, e-mail: [email protected] > >
