Skip to content

Commit

Permalink
添加发布脚本
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan3058 committed Jan 3, 2018
1 parent 54960a4 commit a6f18e3
Show file tree
Hide file tree
Showing 2 changed files with 149 additions and 0 deletions.
118 changes: 118 additions & 0 deletions deploy.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
apply from: 'build.gradle'

apply plugin: 'maven'
apply plugin: 'signing'

def isReleaseBuild() {
return VERSION_NAME.contains("SNAPSHOT") == false
}

def getReleaseRepositoryUrl() {
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
}

def getSnapshotRepositoryUrl() {
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
: "https://oss.sonatype.org/content/repositories/snapshots/"
}

def getRepositoryUsername() {
return hasProperty('MAVEN_USERNAME') ? MAVEN_USERNAME : ""
}

def getRepositoryPassword() {
return hasProperty('MAVEN_PASSWORD') ? MAVEN_PASSWORD : ""
}

uploadArchives {
repositories {
mavenDeployer {
configurePOM(pom)

beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

repository(url: getReleaseRepositoryUrl()) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
}
snapshotRepository(url: getSnapshotRepositoryUrl()) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
}
}
}
}

signing {
required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}

javadoc {
failOnError false
options{
encoding "UTF-8"
charSet 'UTF-8'
author true
version true
links "http://docs.oracle.com/javase/7/docs/api"
title 'ctosb core document'
}
}
task javadocsJar(type: Jar,dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}

task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}


artifacts {
archives jar
archives javadocsJar
archives sourcesJar
}

private configurePOM(def pom) {
pom.project {
groupId POM_GROUP_ID
artifactId POM_ARTIFACT_ID
version VERSION_NAME
name POM_NAME
packaging POM_PACKAGING
description POM_DESCRIPTION
url POM_URL
inceptionYear POM_INCEPTION_YEAR

scm {
url POM_SCM_URL
connection POM_SCM_CONNECTION
developerConnection POM_SCM_DEV_CONNECTION
}

licenses {
license {
name POM_LICENCE_NAME
url POM_LICENCE_URL
distribution POM_LICENCE_DIST
comments POM_LICENCE_COMMENTS
}
}

developers {
developer {
id POM_DEVELOPER_ID
name POM_DEVELOPER_NAME
email POM_DEVELOPER_EMAIL
url POM_DEVELOPER_URL
}
}

issueManagement {
system POM_ISSUE_MANAGEMENT_SYSTEM
url POM_ISSUE_MANAGEMENT_URL
}
}
}
31 changes: 31 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
POM_GROUP_ID=com.ctosb
POM_DESCRIPTION=ctosb codebuild web
POM_URL=https://github.com/Alan3058/ctosb-codebuild-web
POM_SCM_URL=https://github.com/Alan3058/ctosb-codebuild-web
POM_SCM_CONNECTION=scm:git@github.com:Alan3058/ctosb-codebuild-web.git
POM_SCM_DEV_CONNECTION=scm:git@github.com:Alan3058/ctosb-codebuild-web.git
POM_LICENCE_COMMENTS=A business-friendly OSS license
POM_LICENCE_NAME=The Apache Software License, Version 2.0
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=wen3058
POM_DEVELOPER_NAME=liliangang
POM_DEVELOPER_EMAIL=361225485@qq.com
POM_DEVELOPER_URL=http://www.ctosb.com
POM_ISSUE_MANAGEMENT_SYSTEM=Github
POM_ISSUE_MANAGEMENT_URL=https://github.com/Alan3058/ctosb-codebuild-web/issues
POM_INCEPTION_YEAR=2017

POM_NAME=ctosb codebuild web
POM_ARTIFACT_ID=ctosb-codebuild-web
POM_PACKAGING=jar

VERSION_NAME=1.0.0-SNAPSHOT
VERSION_CODE=1

#全局隐私配置,移植到本地目录
#signing.keyId=xxxx
#signing.password=xxxx
#signing.secretKeyRingFile=C:/Users/dell/AppData/Roaming/gnupg/secring.gpg
#MAVEN_USERNAME=xxx
#MAVEN_PASSWORD=xxxx

0 comments on commit a6f18e3

Please sign in to comment.