Maven 집합 과 계승

18408 단어 maven
모이다
1.새 account 항목,POM 파일 은
<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/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<groupId>com.iteye.xujava</groupId>
	<artifactId>account</artifactId>
	<version>1.0.0</version>
	<packaging>pom</packaging>
	<name>account</name>

	<modules>
		<module>account-email</module>
		<module>account-persist</module>
	</modules>
</project>

 
2.Eclipse 에서 account-email,account-persist 를 삭제 하고 두 항목 의 폴 더 를 account 폴 더 에 두 고 Eclipse 에서 이 두 항목 을 다시 도입 합 니 다.account-persist 의 service.properties 내용 은 persist.file=E:/mavenspace/account/account-persist/target/test-classes/persist-data.xml 입 니 다.
 
3.mvn clean test 실행
4.mvn clean install 실행
 
상속
세 개의 작업 과 POM 파일 을 수정 합 니 다.
account 의 POM 파일
<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/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<groupId>com.iteye.xujava</groupId>
	<artifactId>account</artifactId>
	<version>1.0.0</version>
	<packaging>pom</packaging>
	<name>Account</name>

	<modules>
		<module>account-email</module>
		<module>account-persist</module>
	</modules>

	<properties>
		<springframework.version>2.5.6</springframework.version>
		<junit.version>4.9</junit.version>
	</properties>

	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-core</artifactId>
				<version>${springframework.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-beans</artifactId>
				<version>${springframework.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-context</artifactId>
				<version>${springframework.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-context-support</artifactId>
				<version>${springframework.version}</version>
			</dependency>
			<dependency>
				<groupId>junit</groupId>
				<artifactId>junit</artifactId>
				<version>${junit.version}</version>
				<scope>test</scope>
			</dependency>
		</dependencies>
	</dependencyManagement>
	
	<build>
		<pluginManagement>
			<plugins>
				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-resources-plugin</artifactId>
					<configuration>
						<encoding>UTF-8</encoding>
					</configuration>
				</plugin>
			</plugins>
		</pluginManagement>
	</build>
</project>

 
account-email 의 POM 파일
<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/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<parent>
		<groupId>com.iteye.xujava</groupId>
		<artifactId>account</artifactId>
		<version>1.0.0</version>
                <!--      POM    ,      relativePath -->
		<relativePath>../pom.xml</relativePath>
	</parent>

	<artifactId>account-email</artifactId>
	<name>Account Email</name>

	<properties>
		<javax.mail.version>1.4.1</javax.mail.version>
		<greenmail.version>1.3.1b</greenmail.version>
	</properties>

	<dependencies>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-core</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-beans</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context-support</artifactId>
		</dependency>
		<dependency>
			<groupId>javax.mail</groupId>
			<artifactId>mail</artifactId>
			<version>${javax.mail.version}</version>
		</dependency>
		<dependency>
			<groupId>com.icegreen</groupId>
			<artifactId>greenmail</artifactId>
			<version>${greenmail.version}</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
		</dependency>
	</dependencies>
</project>

 
account persist 의 POM 파일
<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/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<parent>
		<groupId>com.iteye.xujava</groupId>
		<artifactId>account</artifactId>
		<version>1.0.0</version>
		<relativePath>../pom.xml</relativePath>
	</parent>

	<artifactId>account-persist</artifactId>
	<name>Account Persist</name>

	<properties>
		<dom4j.version>1.6.1</dom4j.version>
	</properties>

	<dependencies>
		<dependency>
			<groupId>dom4j</groupId>
			<artifactId>dom4j</artifactId>
			<version>${dom4j.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-core</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-beans</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context</artifactId>
		</dependency>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
		</dependency>
	</dependencies>

	<build>
		<testResources>
			<testResource>
				<directory>src/test/resources</directory>
				<filtering>true</filtering>
			</testResource>
		</testResources>
	</build>
</project>

 
화면 음악 n clean test 실행
화면 음악 n clean install 실행
 
슈퍼 POM
    슈퍼 POM 위 치 는%M2HOME%/lib/maven-model-builder-3.0.5.jar\org\apache\maven\\model 에서 pom-4.0.0.xml 입 니 다.
내용 은 다음 과 같다.
<?xml version="1.0" encoding="UTF-8"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->

<!-- START SNIPPET: superpom -->
<project>
  <modelVersion>4.0.0</modelVersion>

  <!--    -->
  <repositories>
    <repository>
      <id>central</id>
      <name>Central Repository</name>
      <url>http://repo.maven.apache.org/maven2</url>
      <layout>default</layout>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </repository>
  </repositories>

  <!--      -->
  <pluginRepositories>
    <pluginRepository>
      <id>central</id>
      <name>Central Repository</name>
      <url>http://repo.maven.apache.org/maven2</url>
      <layout>default</layout>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <releases>
        <updatePolicy>never</updatePolicy>
      </releases>
    </pluginRepository>
  </pluginRepositories>

  <build>
    <!--         -->
    <directory>${project.basedir}/target</directory>
	<!--           -->
    <outputDirectory>${project.build.directory}/classes</outputDirectory>
	<!--           -->
    <finalName>${project.artifactId}-${project.version}</finalName>
	<!--           -->
    <testOutputDirectory>${project.build.directory}/test-classes</testOutputDirectory>
	<!--       -->
    <sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
	<!--        -->
    <scriptSourceDirectory>src/main/scripts</scriptSourceDirectory>
	<!--        -->
    <testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>
    <resources>
      <resource>
	    <!--       -->
        <directory>${project.basedir}/src/main/resources</directory>
      </resource>
    </resources>
    <testResources>
      <testResource>
		<!--        -->
        <directory>${project.basedir}/src/test/resources</directory>
      </testResource>
    </testResources>
    <pluginManagement>
      <!-- NOTE: These plugins will be removed from future versions of the super POM -->
      <!-- They are kept for the moment as they are very unlikely to conflict with lifecycle mappings (MNG-4453) -->
	  <!--          -->
      <plugins>
        <plugin>
          <artifactId>maven-antrun-plugin</artifactId>
          <version>1.3</version>
        </plugin>
        <plugin>
          <artifactId>maven-assembly-plugin</artifactId>
          <version>2.2-beta-5</version>
        </plugin>
        <plugin>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>2.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-release-plugin</artifactId>
          <version>2.0</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

  <reporting>
    <outputDirectory>${project.build.directory}/site</outputDirectory>
  </reporting>

  <profiles>
    <!-- NOTE: The release profile will be removed from future versions of the super POM -->
    <profile>
      <id>release-profile</id>

      <activation>
        <property>
          <name>performRelease</name>
          <value>true</value>
        </property>
      </activation>

      <build>
        <plugins>
          <plugin>
            <inherited>true</inherited>
            <artifactId>maven-source-plugin</artifactId>
            <executions>
              <execution>
                <id>attach-sources</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <inherited>true</inherited>
            <artifactId>maven-javadoc-plugin</artifactId>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <inherited>true</inherited>
            <artifactId>maven-deploy-plugin</artifactId>
            <configuration>
              <updateReleaseInfo>true</updateReleaseInfo>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
<!-- END SNIPPET: superpom -->

 
원자로
    1.다 중 모듈 의 Maven 프로젝트 에서 원자로 란 모든 모듈 로 구 성 된 구축 구 조 를 말한다.
    2.원자로 재단
      -am:--also-make 열 거 된 모듈 의 의존 모듈 을 동시에 구축 합 니 다.
      -amd:-also-make-dependents 는 열 거 된 모듈 에 의존 하 는 모듈 을 동시에 구축 합 니 다.
      -pl:--projects 지정 한 모듈 을 구축 하고 모듈 간 에 쉼표 로 구분 합 니 다.
      -rf:-resume-from지정 모듈 에서 원자로 회복
    3.예
      화면 음악 clean install(기본 값)
 
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Account ........................................... SUCCESS [1.341s]
[INFO] Account Email ..................................... SUCCESS [3.637s]
[INFO] Account Persist ................................... SUCCESS [2.348s]
[INFO] Account Captcha ................................... SUCCESS [3.149s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS

  화면 음악 n clean install-pl account-email,account-persist(구 축 된 모듈 지정)
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Account Email ..................................... SUCCESS [4.316s]
[INFO] Account Persist ................................... SUCCESS [2.152s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
 
    화면 음악 n clean install-pl account-email-am(지정 한 모듈 의 의존 모듈 구축)
 
[INFO] Reactor Summary:
[INFO]
[INFO] Account ........................................... SUCCESS [0.739s]
[INFO] Account Email ..................................... SUCCESS [3.627s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
 
    화면 음악 n clean install-pl account-parent-amd(열 거 된 모듈 에 의존 하 는 모듈 을 동시에 구축 합 니 다.account-parent 모듈 이 있다 고 가정 하면 다른 모듈 은 모두 이에 의존 합 니 다) 
 
 
    화면 음악 n clean install-rf account-persist(전체 원자로 구축 순 서 를 바탕 으로 어느 모듈 부터 구축 할 지 지정 합 니 다.원래 큰 줄 은 실행 되 지 않 습 니 다.원래 account 와 account Email 은 account Persist 앞 에 있 습 니 다.기본 실행 을 참고 하 십시오)
 
[INFO] Reactor Summary:
[INFO]
[INFO] Account Persist ................................... SUCCESS [4.326s]
[INFO] Account Captcha ................................... SUCCESS [2.864s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS

 
 mvn clean install-pl account-parent-amd-rf account-captcha(우선-pl account-parent 는 Email,Persist,Captcha 세 모듈 을 구축 한 다음-rf account-captcha 는 Captcha 부터 구축 하고 Capthca 는 완전한 원자로 에서 마지막 으로 구축 되 며 최종 적 으로 Captcha 만 구축한다.account-parent 모듈 이 있다 고 가정 하면 다른 모듈 은 모두 그것 에 의존 합 니 다) 

좋은 웹페이지 즐겨찾기