gradle常用配置

修改maven仓库地址

allprojects {
    repositories {
        google()
        jcenter()
//        maven {
//			  自定义的仓库Url
//			  url uri('repo') //本地
//            url uri('http://192.168.12.15:8081/repository/maven-releases/')
//        }
    }
}

上传到maven

apply plugin: 'maven'
uploadArchives {
    repositories.mavenDeployer {
        //本地文件夹作为仓库
        //repository(url: uri('../repo'))
        //虚拟机作为仓库
        repository(url: uri('http://192.168.178.128:8081/repository/maven-releases/'))
                {
					 //账号密码
                    authentication(userName: "admin", password: "admin")
                }
        // 唯一标识
        pom.groupId = "com.chow"
        // 项目名称
        pom.artifactId = "android.plugin"
        // 版本号
        pom.version = "1.0.0"
    }
}

上传plugin到bintray

apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'
//gradlew bintrayUpload
/*library版本*/
version = "1.0.0"
///*github上的项目主页以及git仓库地址*/
def siteUrl = 'https://github.com/xxxx/chow-plugin'
def gitUrl = 'https://github.com/xxxx/chow-plugin.git'
///*maven group ID 这个gruop很重要,参考 compile 'groupId:artifactId:version'     groupId就是这个,artifactId就是包名,version就是顶部那个*/
group = "com.xxxx.android"
install {
    repositories.mavenInstaller {
        // This generates POM.xml with proper parameters
        pom {
            project {
                packaging 'jar'
                /*项目描述*/
                name 'a test'
                url siteUrl
                /*设置证书s*/
                licenses {
                    license {
                        name 'The Apache Software License, Version 2.0'
                        url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                    }
                }
                developers {
                    developer {
                        id 'xxx'
                        name 'xxx'
                        email 'xxx@qq.com'
                    }
                }
                scm {
                    connection gitUrl
                    developerConnection gitUrl
                    url siteUrl
                }
            }
        }
    }
}

Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
bintray {
    user = properties.getProperty("bintray.user")
    key = properties.getProperty("bintray.apikey")
    configurations = ['archives']
    pkg {
        repo = "maven"
        //对应bintray账号上的仓库名称;发布到Bintray的那个仓库,即你在bintray网站建立的仓库名,若该仓库不存在,会报错。
        name = "xxxx-plugin"    //发布到JCenter仓库下的项目名字
        websiteUrl = siteUrl
        vcsUrl = gitUrl
        licenses = ["Apache-2.0"]
        publish = true
    }
}

//如果需要发布,要上传源码并进行审核
//上传源码
//tasks.withType(Javadoc) {//防止编码问题
//    options.addStringOption('Xdoclint:none', '-quiet')
//    options.addStringOption('encoding', 'UTF-8')
//    options.addStringOption('charSet', 'UTF-8')
//}
//
//task sourcesJar(type: Jar) {
//    classifier = 'sources'
//    from sourceSets.main.allSource
//}
//
//
//task javadocJar(type: Jar, dependsOn: javadoc) {
//    classifier = 'javadoc'
//    from javadoc.destinationDir
//}
//
//artifacts {
//    archives javadocJar
//    archives sourcesJar
//}

上传arr到bintray

apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'
/*library版本*/
version = "1.0.0"
/*github上的项目主页以及git仓库地址*/
def siteUrl = 'https://github.com/xxx/xxxx-sdk'
def gitUrl = 'https://github.com/xxx/xxxx-sdk.git'
/*maven group ID 这个gruop很重要,参考 compile 'groupId:artifactId:version'     groupId就是这个,artifactId就是包名,version就是顶部那个*/

group = "com.chow.android"
install {
    repositories.mavenInstaller {
        // This generates POM.xml with proper parameters
        pom {
            project {
                packaging 'aar'
                /*项目描述*/
                name 'xxx arr'
                url siteUrl
                /*设置证书s*/
                licenses {
                    license {
                        name 'The Apache Software License, Version 2.0'
                        url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                    }
                }
                developers {
                    developer {
                        id 'xxxx'
                        name 'xxxxx'
                        email 'xxx@qq.com'
                    }
                }
                scm {
                    connection gitUrl
                    developerConnection gitUrl
                    url siteUrl
                }
            }
        }
    }
}

Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
bintray {
    user = properties.getProperty("bintray.user")
    key = properties.getProperty("bintray.apikey")
    configurations = ['archives']
    pkg {
        repo = "maven"
        //对应bintray账号上的仓库名称;发布到Bintray的那个仓库,即你在bintray网站建立的仓库名,若该仓库不存在,会报错。
        name = "xxx-xxxx"    //发布到JCenter仓库下的项目名字
        websiteUrl = siteUrl
        vcsUrl = gitUrl
        licenses = ["Apache-2.0"]
        publish = true
    }
}

//上传源码
//tasks.withType(Javadoc) {//防止编码问题
//    options.addStringOption('Xdoclint:none', '-quiet')
//    options.addStringOption('encoding', 'UTF-8')
//    options.addStringOption('charSet', 'UTF-8')
//}
//
//task sourcesJar(type: Jar) {
//    from android.sourceSets.main.java.srcDirs
//    classifier = 'sources'
//}
//
//task javadoc(type: Javadoc) {
//    source = android.sourceSets.main.java.srcDirs
//    classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
//}
//
//task javadocJar(type: Jar, dependsOn: javadoc) {
//    classifier = 'javadoc'
//    from javadoc.destinationDir
//}
//
//artifacts {
//    archives javadocJar
//    archives sourcesJar
//}

先Install,后bintrayUpload

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值