Terry.Li-彬

虚其心,可解天下之问;专其心,可治天下之学;静其心,可悟天下之理;恒其心,可成天下之业。

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  143 随笔 :: 344 文章 :: 130 评论 :: 0 Trackbacks

MAVEN 一结
 1.安装:略
 2. make first Maven 78
  cmd: mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-app
notice: archetype==template    -D看cmd-> mvn -help
将产生一个pom.xml(project object model)文件

maven工程产生:
mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-app


文档产生:
mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-app
-DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-site
格式(大概)如下
project
  modelVersion使用pom的版本号
  groupId  组ID 如org.apache.maven.plugins或com.sourceware
  artifactId 类似工程名unique
  packaging打包(jar或war,ear由artifactId的extension定
  version该工程的版本号
  name显示名称在文档里
  url   url在文档里
  description描述在文档里
  更详细的见maven.htm(旁)
 
mvn的命令在maven-command.htm里

MAVEN与ANT整合如下
<project>
  <modelVersion>4.0.0</modelVersion>
  <artifactId>my-test-app</artifactId>
  <groupId>my-test-group</groupId>
  <version>1.0-SNAPSHOT</version>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <phase>generate-sources</phase>
            <configuration>
              <tasks>

                <!--
                  Place any ant task here. You can add anything
                  you can add between <target> and </target> in a
                  build.xml.
                -->

              </tasks>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
So a concrete example would be something like the following:

<project>
  <modelVersion>4.0.0</modelVersion>
  <artifactId>my-test-app</artifactId>
  <groupId>my-test-group</groupId>
  <version>1.0-SNAPSHOT</version>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <phase>generate-sources</phase>
            <configuration>
              <tasks>
                <exec
                  dir="${basedir}"
                  executable="${basedir}/src/main/sh/do-something.sh"
                  failonerror="true">
                  <arg line="arg1 arg2 arg3 arg4" />
                </exec>
              </tasks>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

posted on 2008-01-10 19:42 礼物 阅读(389) 评论(0)  编辑  收藏 所属分类: maven2