对于maven远程仓库的一些整理

1. mvn deploy 相关

  • 首先要在settings.xml中指定远程服务器的登录名和密码
    <servers>
    	<server>
    		<id>snapshots</id>
    		<username>username</username> 
       		<password>password</password> 
    	</server>
    	<server>
    	   <id>releases</id>
    	   <username>username</username> 
    	   <password>password</password> 
    	</server>
      </servers>

  • 之后,配置项目POM文件,加入远程仓库的url
     <distributionManagement>
             <repository>
                  <id>releases</id>
                  <name>localhost-releases</name>
                  <url></url>
             </repository>
            <snapshotRepository>
                <id>snapshots</id>
                <name>localhost-snapshots</name>
                <url></url>
            </snapshotRepository>
        </distributionManagement>

最终上传至url/groupid/artifactid目录下;

2. maven-assembly-plugin

通过以上方式上传时,maven会将项目构建后上传;当需要上传的文件不是一个maven工程时,需要寻找解决方法;
方案就是使用maven-assembly-plugin 打包;

  • 首先需要在pom中引入maven-assembly-plugin 并进行相关配置
     <build>
           <plugins>
              <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.1.0</version>
        		<configuration>
        			<descriptors>
        				<descriptor>assembly.xml</descriptor>
        			</descriptors>
                       <!--使得包后缀名不加上Assembly.xml 中的id-->
        			<appendAssemblyId>false</appendAssemblyId>
        		</configuration>
        			<executions>
                  <execution>
                    <id>assembly</id> <!-- this is used for inheritance merges -->
                    <phase>package</phase> <!-- bind to the packaging phase -->
                    <goals>
                      <goal>single</goal>
                    </goals>
                  </execution>
                </executions>
             </plugin>
          </plugins>
      </build>
  • 其次需要一个打包的描述文件,这里叫做assembly.xml
    <assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
      <id>assembly</id>
      <formats>
          <!--打包格式-->
        <format>tar.gz</format>
      </formats>
        <fileSets>
            <fileSet>
                <!--源文件路径-->
                <directory>dic</directory>
                <!--输出路径-->
    		    <outputDirectory>/</outputDirectory>
            </fileSet>
    
        </fileSets>
    </assembly>

具体的参数配置可以参考: Apache Maven Assembly Plugin

  • 不生成jar包的方法是在pom中设置打包格式为pom:
    	<packaging> pom</packaging>

3. Artifactory RESTful API

对于使用JFrog创建的maven仓库,可以使用其提供的RESTful API来进行操作;

但这样的方式更新仓库时,相应的配置文件(maven_metadata.xml)不会更新;

3.1 artifactory java client

使用java创建一个client访问;

具体教程参考:artifactory java client

3.2 curl

具体教程参考:curl

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值