Maven Notes

There is a few different confusing Tag and URL in Maven pom.xm

 

  • <scm> url points to SVN URL which hold the subversion code you check in/out.
  • <repository> points to library url when pom.xml has dependency, it will pull out from there (<snapshots>true</snapshots> means it support snapshot lookup and checkout)
  • <distributionManagement> points to the location where the release code will be put (the release will check out code from URL in <scm> and create release file and save in the url.

<distributionManage>

 

	<distributionManagement>
		<downloadUrl>https://xxxx/</downloadUrl>
		<repository>
			<uniqueVersion>false</uniqueVersion>
			<id>es-maven</id>
			<name>xxx systems Maven Repository</name>
			<url>sftp://xxx/export/web/maven2/</url>
			<layout>default</layout>
		</repository>
		<site>
			<id>es-maven-site</id>
			<url>sftp://xxxx/export/web/site/${artifactId}</url>
		</site>
	</distributionManagement>

 

- it contains url where when you run "mvn deploy" the new generated snapshot file will be uploaded there

 

<repository>

 

   <repository>
			<id>xx-maven</id>
			<name>xxx Systems Maven Repository</name>
			<url>https://xxx/maven2</url>
			<snapshots>
				<enabled>true</enabled>
			</snapshots>
			<releases>
				<enabled>true</enabled>
			</releases>
		</repository>

 The red "true" "false" means when you do "mvn deploy" it will be able to create snapshot or not

 

  • if "true" every deploy, it will create new snapshot on deploy server location (defined in distributionmanage tag)
  • if "false" every deploy, it will overwrite previous snapshot on deploy server location  (defined in distributionmanage tag)

 

1. Maven release:prepare

 

  1. Verify that there are no uncommitted changes in the workspace.
  2. Prompt the user for the desired tag, release and development version names.
  3. Modify and commit release information into the pom.xml file.
  4. Tag the entire project source tree with the new tag name.
Because prepare will tag the project, we need the following
  • project.scm.developerConnection

    The current location of the development trunk. A valid SCM URL format appropriate to the SCM provider. The "SCM:Provider:" prefix is used to determine the provider being used.

  • tagbase
  • The new location to record a tagged release. A valid SCM URL format appropriate to the SCM provider without the "SCM:Provider:" prefix.

    2. Maven release

     

    1. Extract file revisions versioned under the new tag name.
    2. Execute the maven build lifecycle on the extracted instance of the project.
    3. Deploy the versioned artifacts to appropriate local and remote repositories.

     

    Reference:  http://maven.apache.org/guides/mini/guide-releasing.html

     

    Compared with local reporsitory and deploy/release remote server, the structure of maven snapshot release, and release are same. because everything is done locally before sending to server??? That is my understanding

     

    Why configure remote repository in settings.xml

    (reference: http://juvenshun.iteye.com/blog/359256)

    Suppose you work on 3 project at the same time, they all point to same remote repository, so you need configure them in 3 POM for the 3 different projects, right? repeated code, hard to maintain???

     

    So the solution is adding to your own .m2/settings.xml file

     

        <settings>  
          ...  
          <profiles>  
            <profile>  
              <id>dev</id>  
              <!-- repositories and pluginRepositories here-->  
            </profile>  
          </profiles>  
          <activeProfiles>  
            <activeProfile>dev</activeProfile>  
          </activeProfiles>  
          ...  
        </settings>  
     

    Deploy to remote repository

    (reference: http://juvenshun.iteye.com/blog/359256)

     <distributionManagement>    
    <repository>    
    ...
    <snapshotRepository>    
    ....

     This is the keyword I have been searching for a while:

    "Maven会根据你项目的版本来判断将构件分发到哪个仓库" according to juvenshun from Iteye.

     

    你可能感兴趣的:(maven,xml,SVN,subversion)