maven使用自己資料

liuzongan1985發表於2007-09-25

maven.apache.org/guides/getting-started/index.html#What_is_Maven

新建JAVA普通專案:

mvn archetype:create \
  -DarchetypeGroupId=org.apache.maven.archetypes \
  -DgroupId=com.mycompany.app \
  -DartifactId=my-app

新建WTP web專案:

mvn archetype:create \
    -DarchetypeGroupId=org.apache.maven.archetypes \
    -DarchetypeArtifactId=maven-archetype-webapp \
    -DgroupId=com.mycompany.app \
    -DartifactId=my-webapp

下面是對pom.xml檔案裡面的標籤進行講解:

project This is the top-level element in all Maven pom.xml files. modelVersion This element indicates what version of the object model this POM is using. The version of the model itself changes very infrequently but it is mandatory in order to ensure stability of use if and when the Maven developers deem it necessary to change the model. groupId This element indicates the unique identifier of the organization or group that created the project. The groupId is one of the key identifiers of a project and is typically based on the fully qualified domain name of your organization. For example org.apache.maven.plugins is the designated groupId for all Maven plug-ins. artifactId This element indicates the unique base name of the primary artifact being generated by this project. The primary artifact for a project is typically a JAR file. Secondary artifacts like source bundles also use the artifactId as part of their final name. A typical artifact produced by Maven would have the form <artifactid></artifactid>-<version></version>.<extension></extension> (for example, myapp-1.0.jar ). packaging This element indicates the package type to be used by this artifact (e.g. JAR, WAR, EAR, etc.). This not only means if the artifact produced is JAR, WAR, or EAR but can also indicate a specific lifecycle to use as part of the build process. (The lifecycle is a topic we will deal with further on in the guide. For now, just keep in mind that the indicated packaging of a project can play a part in customizing the build lifecycle.) The default value for the packaging element is JAR so you do not have to specify this for most projects. version This element indicates the version of the artifact generated by the project. Maven goes a long way to help you with version management and you will often see the SNAPSHOT designator in a version, which indicates that a project is in a state of development. We will discuss the use of snapshots and how they work further on in this guide. name This element indicates the display name used for the project. This is often used in Maven's generated documentation. url This element indicates where the project's site can be found. This is often used in Maven's generated documentation. description This element provides a basic description of your project. This is often used in Maven's generated documentation.

以下maven自已的命令格式:
mvn compile

mvn test

mvn test-compile ( simply want to compile your test sources )

mvn clean test-compile

mvn install

mvn clean install

mvn clean  

mvn  install(可將你的專案打包成jar檔案放到你的.m2/repo下面了)

 mvn package

mvn site

mvn resources:resources

mvn idea:idea

mvn eclipse:eclipse  

mvn eclipse:clean

mvn process-resources

mvn process-resources "-Dcommand.line.prop=hello again"

# application.properties
java.version=${java.version}
command.line.prop=${command.line.prop}

# application.properties
application.name=${pom.name}
application.version=${pom.version}
  

<build></build>
  <build></build>
    <resources></resources>
      <resource></resource>
        <directory></directory>src/main/resources
        <filtering></filtering>true
     
   
 


     mvn deploy
java 程式碼
xml 程式碼
  1. [...]   
  2. <distributionManagement>  
  3. <repository>  
  4. <id>proficio-repositoryid>  
  5. <name>Proficio Repositoryname>  
  6. <url>file://${basedir}/target/deployurl>  
  7. repository>  
  8. distributionManagement>  
  9. [...]  


 指定編譯後目錄:

xml 程式碼
  1. <build>  
  2.   <directory>${basedir}/targetdirectory>     
  3. build>  

 

For this example, we will configure the Java compiler to allow JDK 5.0 sources. This is as simple as adding this to your POM:

...
<build></build>
  <plugins></plugins>
    <plugin></plugin>
      <groupid></groupid>org.apache.maven.plugins
      <artifactid></artifactid>maven-compiler-plugin
      <configuration></configuration>
        <source></source>1.5
        <target></target>1.5
     
   
 

...

dependencies

dependency這行依賴

http://www.devzuz.com/web/guest/downloads

相關文章