捡来的笔记

快速搭建私有仓库Artifactory

转载请注明出处:
http://dyhdyh.com/archives/75.html

准备

JFrog提供了开源的Artifactory环境包,官网:https://www.jfrog.com

下载地址:https://api.bintray.com/content/jfrog/artifactory/jfrog-artifactory-oss-%24latest.zip;bt_package=jfrog-artifactory-oss-zip

 

步骤

1.解压后的目录结构如图:

2.搭建的方法有两种:

方法一:

1 直接将webapps的war包放到tomcat目录下的webapps,如图

2 再启动tomcat就大功告成了.

 

方法二:

1 如果是Windows就运行artifactory.bat,Linux就运行artifactory.sh

 

 

效果

http://ip:8081/,账号:admin;密码:password

 

使用Gradle上传代码

1.在project的build.gradle声明Gradle插件

dependencies {
     classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.1.1'
}

2.在library的module的build.gradle中加入

apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'

def artifactVersion = '1.3'//发布的版本号
publishing {
    publications {
        aar(MavenPublication) {
            groupId = "com.dyhdyh.loadingbar"//发布的library项目包名
            artifactId project.name
            version = artifactVersion //版本号
            artifact "${project.buildDir}/outputs/aar/${project.name}-release.aar"
        }
    }
}

artifactory {
    contextUrl = "http://localhost:8081/artifactory"//仓库地址
    publish {
        repository {
            // The Artifactory repository key to publish to
            repoKey = artifactVersion.endsWith('SNAPSHOT') ? 'libs-snapshot-local' : 'libs-release-local'
            username = "admin" // artifactory用户名
            password = "password" // artifactory密码
            maven = true
        }
        defaults {
            publishArtifacts = true
            publications('aar')
            publishPom = true //Publish generated POM files to Artifactory (true by default)
            publishIvy = false //Publish generated Ivy descriptor files to Artifactory (true by default)
        }
    }
    resolve {
        repository {
            repoKey = 'jcenter'
            username = "admin" // artifactory用户名
            password = "password" // artifactory密码
        }
    }
}

3.在Android Studio的Terminal执行命令

gradlew assembleRelease artifactoryPublish

 

引用依赖库

1.在project的build.gradle加入

repositories {
    //release仓库url
    maven { url "http://localhost:8081/artifactory/libs-release-local" }
    //snapshot仓库url
    maven { url "http://localhost:8081/artifactory/libs-snapshot-local" }
}

2.在要引用的module的build.gradle中加入

        //发布的library项目包名   //module名 //版本号
compile 'com.dyhdyh.loadingbar:loadingbar:1.3'

3.最后编译一下或者直接运行,就会自动下载并引入刚才上传的librar了

点赞
  1. 路过 路过说道:

    很详细,学习了

发表评论