maven怎样自动构建非maven结构的web项目
王佳佳
2012-02-07
公司之前做了一个中等的web项目,之前没有自动化构建和部署,现在要实现一套自动化(自动化测试,自动化构建,自动化部署)任务,目前比较急的就是自动化构建和部署
然后就在网上查找相关资料,发现svn+maven+hudson+cargo可实现自动化构建和发布,而且在青蕃茄上还借了一本《maven实战》的书参考,但发现构建传统的web项目必须是maven本身的web结构,而且我本身项目已经把所有的jar包都下载好了,就不需要maven再配置仓库依赖包了 我的项目(hudson从svn构建下来一样的结构)结构如下: 引用 项目名 +src +com.xxx.xxx +com.xxx.xxx +config +properties +xxx.xml +WebRoot +WEB-INF +lib +xx.jar +web.xml +jscss +index.jsp 怎样利用maven构建这样的web项目并打成war包? |
|
shengye49
2012-02-07
把maven换成ant吧。必须有依赖项才能编译好像。就算阔以不创建依赖但是pom.xml文件是必须要写的。目录结构可以在pom.xml文件里描述。
|
|
shengye49
2012-02-07
你建依赖。下好的jar包。可以直接放到本地仓库。。执行mvn构建的时候应该可以带入本地仓库地址的。默认是%/.m2/ 下
|
|
王佳佳
2012-02-09
1.java文件直接采用src/
2.web目录对应WebRoot 3.jar文件直接对应lib下的jar 4.利用cargo插件可直接部署到tomcat里(目前不同机器之间部署还有问题) 5.还有资源路径还是默认的src/main/resources(还不知道怎么改自定义位置) 我的配置如下: 引用 <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <groupId>com.xxx</groupId> <artifactId>xxxx-xxx</artifactId> <packaging>war</packaging> <version>1.0.0-SNAPSHOT</version> <name>xxx-xxx</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version>2.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>3.6.1.Final</version> <scope>system</scope> <systemPath>${basedir}/WebRoot/WEB-INF/lib/hibernate-core-3.6.1.Final.jar</systemPath> </dependency> <dependency> <groupId>org.hibernate.javax.persistence</groupId> <artifactId>hibernate-jpa-2.0-api</artifactId> <version>1.0.0.Final</version> <scope>system</scope> <systemPath>${basedir}/WebRoot/WEB-INF/lib/hibernate-jpa-2.0-api-1.0.0.Final.jar</systemPath> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>3.0.5.RELEASE</version> <scope>system</scope> <systemPath>${basedir}/WebRoot/WEB-INF/lib/spring-webmvc-3.0.5.RELEASE.jar</systemPath> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>3.0.5.RELEASE</version> <scope>system</scope> <systemPath>${basedir}/WebRoot/WEB-INF/lib/spring-core-3.0.5.RELEASE.jar</systemPath> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>3.0.5.RELEASE</version> <scope>system</scope> <systemPath>${basedir}/WebRoot/WEB-INF/lib/spring-context-3.0.5.RELEASE.jar</systemPath> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>3.0.5.RELEASE</version> <scope>system</scope> <systemPath>${basedir}/WebRoot/WEB-INF/lib/spring-context-support-3.0.5.RELEASE.jar</systemPath> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>3.0.5.RELEASE</version> <scope>system</scope> <systemPath>${basedir}/WebRoot/WEB-INF/lib/spring-beans-3.0.5.RELEASE.jar</systemPath> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>3.0.5.RELEASE</version> <scope>system</scope> <systemPath>${basedir}/WebRoot/WEB-INF/lib/spring-jdbc-3.0.5.RELEASE.jar</systemPath> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>3.0.5.RELEASE</version> <scope>system</scope> <systemPath>${basedir}/WebRoot/WEB-INF/lib/spring-web-3.0.5.RELEASE.jar</systemPath> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>3.0.5.RELEASE</version> <scope>system</scope> <systemPath>${basedir}/WebRoot/WEB-INF/lib/spring-orm-3.0.5.RELEASE.jar</systemPath> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>3.0.5.RELEASE</version> <scope>system</scope> <systemPath>${basedir}/WebRoot/WEB-INF/lib/spring-tx-3.0.5.RELEASE.jar</systemPath> </dependency> <dependency> <groupId>com.mortennobel</groupId> <artifactId>java-image-scaling</artifactId> <version>0.8.5</version> <scope>system</scope> <systemPath>${basedir}/WebRoot/WEB-INF/lib/java-image-scaling-0.8.5.jar</systemPath> </dependency> <dependency> <groupId>com.googlecode.xmemcached</groupId> <artifactId>xmemcached</artifactId> <version>1.3.3</version> <scope>system</scope> <systemPath>${basedir}/WebRoot/WEB-INF/lib/xmemcached-1.3.3.jar</systemPath> </dependency> <dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> <version>20030203.000129</version> <scope>system</scope> <systemPath>${basedir}/WebRoot/WEB-INF/lib/commons-lang.jar</systemPath> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.6.1</version> <scope>system</scope> <systemPath>${basedir}/WebRoot/WEB-INF/lib/slf4j-api-1.6.1.jar</systemPath> </dependency> <dependency> <groupId>com.alibaba.fastjson</groupId> <artifactId>fastjson</artifactId> <version>1.0.6</version> <scope>system</scope> <systemPath>${basedir}/WebRoot/WEB-INF/lib/fastjson-1.0.6.jar</systemPath> </dependency> <dependency> <groupId>com.alibaba.fastjson</groupId> <artifactId>org.jsoup</artifactId> <version>1.5.2</version> <scope>system</scope> <systemPath>${basedir}/WebRoot/WEB-INF/lib/jsoup-1.5.2.jar</systemPath> </dependency> <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>1.2.1</version> <scope>system</scope> <systemPath>${basedir}/WebRoot/WEB-INF/lib/commons-fileupload-1.2.1.jar</systemPath> </dependency> <dependency> <groupId>commons-beanutils</groupId> <artifactId>commons-beanutils</artifactId> <version>1.8.0</version> <scope>system</scope> <systemPath>${basedir}/WebRoot/WEB-INF/lib/commons-beanutils-1.8.0.jar</systemPath> </dependency> <dependency> <groupId>org.freemarker</groupId> <artifactId>freemarker</artifactId> <version>2.3.14</version> <scope>system</scope> <systemPath>${basedir}/WebRoot/WEB-INF/lib/freemarker.jar</systemPath> </dependency> <dependency> <groupId>org.dom4j</groupId> <artifactId>dom4j</artifactId> <version>1.6.1</version> <scope>system</scope> <systemPath>${basedir}/WebRoot/WEB-INF/lib/dom4j-1.6.1.jar</systemPath> </dependency> <dependency> <groupId>net.sf.ehcache</groupId> <artifactId>ehcache-core</artifactId> <version>2.3.0</version> <scope>system</scope> <systemPath>${basedir}/WebRoot/WEB-INF/lib/ehcache-core-2.3.0.jar</systemPath> </dependency> <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> <version>1.4</version> <scope>system</scope> <systemPath>${basedir}/WebRoot/WEB-INF/lib/commons-codec-1.4.jar</systemPath> </dependency> <dependency> <groupId>org.apache.tools</groupId> <artifactId>ant</artifactId> <version>20120207</version> <scope>system</scope> <systemPath>${basedir}/WebRoot/WEB-INF/lib/ant.jar</systemPath> </dependency> </dependencies> <build> <!-- 默认的主代码目录 --> <!-- <sourceDirectory>src</sourceDirectory> --> <!-- <testSourceDirectory>src/test/java</testSourceDirectory> --> <finalName>xxx</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <configuration> <encoding>UTF-8</encoding> </configuration> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>1.7</version> <executions> <execution> <id>add-source</id> <phase>generate-sources</phase> <goals> <goal>add-source</goal> </goals> <configuration> <sources> <source>src</source> </sources> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <configuration> <!-- 设置WebRoot目录为Web目录 --> <warSourceDirectory>WebRoot</warSourceDirectory> </configuration> </plugin> <plugin> <groupId>org.codehaus.cargo</groupId> <artifactId>cargo-maven2-plugin</artifactId> <version>1.2.0</version> <configuration> <container> <containerId>tomcat6x</containerId> <type>remote</type> </container> <configuration> <type>runtime</type> <properties> <cargo.remote.username>maven</cargo.remote.username> <cargo.remote.password>maven</cargo.remote.password> <cargo.tomcat.manager.url>http://127.0.0.1:8080/manager</cargo.tomcat.manager.url> </properties> </configuration> <deployer> <type>remote</type> <deployables> <deployable> <groupId>com.ttpod</groupId> <artifactId>ttpod-atj</artifactId> <type>war</type> <properties> <context>atj</context> </properties> <pingURL>http://127.0.0.1:8080/xxx</pingURL> <pingTimeout>30000</pingTimeout> </deployable> </deployables> </deployer> </configuration> </plugin> </plugins> <outputDirectory>WebRoot/WEB-INF/classes</outputDirectory> </build> </project> |