maven--composer

Posted szllq2000

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了maven--composer相关的知识,希望对你有一定的参考价值。

场景:
最近再整系统的自动部署流程,由于公司的jar包在svn以及mvn的仓库上都存在,开发人员在开发的过程中都依赖mvn仓库中的Jar 包,在jar上线的时候,配置管理人员把jar 从svn管理的工作目录直接commit到svn的仓库中,同时也执行mvn deploy命令,把该Jar包deploy 的mvn仓库中。
由于每次执行mvn deploy的时候,mvn会重新打jar,而在打出的jar包中的META-INF目录下包括一个pom.properties文件,该文件记录的是打 成该jar包的时间,这样导致每次执行mvn deploy的时候,这个时间都不同,当进行MD5比较的时候,虽然class没有任何变化,但是由于该文件的变化,而导致对同样的代码mvn deploy成的Jar的md5值不一样




解决办法:
当用mvn install 打出jar 包后,如果需要把该jar原封不动的deploy到mvn仓库中,可以执行如下命令:
mvn deploy:deploy-file -Durl=url  -DrepositoryId=repositoryId -Dfile=file -DpomFile=pom.xml -Dversion=1.0

-Durl                   是指要deploy到仓库的路径
-DrepositoryId    jar 包的repositoryid
-Dfile                  jar包的具体路径
-DpomFile          jar对应的pom路径
-Dversion           jar的版本
其实在官网上写的很清楚,如需要查看更加详细的用法,请见官网:
http://maven.apache.org/plugins/maven-deploy-plugin/usage.html

 

--checkstyle-http://blog.csdn.net/kongxx/article/details/7750015

<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>2.10</version> <executions> <execution> <id>checkstyle</id> <phase>validate</phase> <goals> <goal>check</goal> </goals> <configuration> <failOnViolation>true</failOnViolation> </configuration> </execution> </executions> </plugin>

--------jenkins mvn

 http://www.cnblogs.com/zhangchuan210/p/3413811.html

 

 

 

<build>

         <directory>target</directory>

         <sourceDirectory>src</sourceDirectory>

         <testSourceDirectory>test</testSourceDirectory>

         <outputDirectory>build</outputDirectory>

         <testOutputDirectory>build/test-classes</testOutputDirectory>               

         <resources>

               <resource>

                    <directory>src</directory>

                    <excludes>

                         <exclude>**/*.java</exclude>

                    </excludes>

               </resource>

         </resources>            

     </build> 

 

 

Look in your settings.xml (or, possibly your project\'s parent or corporate parent POM) for the <repositories> element. It will look something like the below.

<repositories>
    <repository>
        <id>central</id>
        <url>http://gotoNexus</url>
        <snapshots>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
        </snapshots>
        <releases>
            <enabled>true</enabled>
            <updatePolicy>daily</updatePolicy>
        </releases>
    </repository>
</repositories>

Note the <updatePolicy> element. The example tells Maven to contact the remote repo (Nexus in my case, Maven Central if you\'re not using your own remote repo) any time Maven needs to retrieve a snapshot artifact during a build, checking to see if there\'s a newer copy. The metadata is required for this. If there is a newer copy Maven downloads it to your local repo.

In the example, for releases, the policy is daily so it will check during your first build of the day. never is also a valid option, as described in Maven settings docs.

Plugins are resolved separately. You may have repositories configured for those as well, with different update policies if desired.

<pluginRepositories>
    <pluginRepository>
        <id>central</id>
        <url>http://gotoNexus</url>
        <snapshots>
            <enabled>true</enabled>
            <updatePolicy>daily</updatePolicy>
        </snapshots>
        <releases>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
        </releases>
    </pluginRepository>
</pluginRepositories>

Someone else mentioned the -o option. If you use that, Maven runs in "offline" mode. It knows it has a local repo only, and it won\'t contact the remote repo to refresh the artifacts no matter what update policies you use.

 

 

以上是关于maven--composer的主要内容,如果未能解决你的问题,请参考以下文章

VSCode自定义代码片段——CSS选择器

谷歌浏览器调试jsp 引入代码片段,如何调试代码片段中的js

片段和活动之间的核心区别是啥?哪些代码可以写成片段?

VSCode自定义代码片段——.vue文件的模板

VSCode自定义代码片段6——CSS选择器

VSCode自定义代码片段——声明函数