Maven 学习


Maven

mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DgroupId=com.mycompany.app -DartifactId=my-app
mvn archetype:create -DgroupId=com.yuwenyi.mvnwork -DartifactId=app1

/src/main/java
/src/test/java

cd /pom dir

mvn clean compile
mvn clean test
mvn clean package
mvn clean install

mvn [plugin]:[goal]
mvn dependency:copy-dependencies
mvn dependency:copy-dependencies -DoutputDirectory=${project.build.directory}/lib
mvn dependency:tree
mvn dependency:list
mvn dependency:sources  # tells Maven to resolve all dependencies and their source attachments, and displays the version.
mvn dependency:build-classpath
mvn dependency:unpack-dependencies -DoutputDirectory=src/main/java
mvn eclipse:eclipse

mvn surefire-report:report

mvn source:jar
mvn source:test-jar
mvn ant:ant
mvn ant:clean

cool

mvn clean dependency:unpack-dependencies -DoutputDirectory=${project.build.directory}/classes package

pom:

<scope>compile</scope>
<scope>test</scope>

<build>
<plugins>
  <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-jar-plugin</artifactId>
      <configuration>
          <archive>
              <manifest>
                  <addClasspath>true</addClasspath>
                  <classpathPrefix>lib/</classpathPrefix>
                  <mainClass>com.yuwenyi.mvnwork.App</mainClass>
              </manifest>
          </archive>
      </configuration>
  </plugin>
</plugins>
</build>

maven eclipse

Standard eclipse goals

  • eclipse:configure-workspace is used to add the classpath variable M2_REPO to Eclipse which points to your local repository and optional to configure other workspace features.
  • eclipse:eclipse generates the Eclipse configuration files.
  • eclipse:clean is used to delete the files used by the Eclipse IDE.

高级用法

mvn eclipse:eclipse -DdownloadSources=true  -DdownloadJavadocs=true
panda /
Published under (CC) BY-NC-SA in categories java  tagged with maven