打包步驟
生成gpg密鑰
gpg --full-generate-key
gpg (GnuPG) 2.2.12; Copyright (C) 2018 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
請選擇您要使用的密鑰類型:
(1) RSA 和 RSA (默認)
(2) DSA 和 Elgamal
(3) DSA(僅用于簽名)
(4) RSA(僅用于簽名)
您的選擇是? 4
RSA 密鑰的長度應在 1024 位與 4096 位之間。
您想要使用的密鑰長度?(2048)
請求的密鑰長度是 2048 位
請設定這個密鑰的有效期限。
0 = 密鑰永不過期
<n> = 密鑰在 n 天后過期
<n>w = 密鑰在 n 周后過期
<n>m = 密鑰在 n 月后過期
<n>y = 密鑰在 n 年后過期
密鑰的有效期限是?(0) 0
密鑰永遠不會過期
這些內容正確嗎? (y/N) y
GnuPG 需要構建用戶標識以辨認您的密鑰。
真實姓名: dounine
電子郵件地址: xxxxx@gamil.com
注釋: for lake
您選定了此用戶標識:
“dounine (for lake) <xxxxx@gamil.com>”
更改姓名(N)、注釋(C)、電子郵件地址(E)或確定(O)/退出(Q)? O
我們需要生成大量的隨機字節。在質數生成期間做些其他操作(敲打鍵盤
、移動鼠標、讀寫硬盤之類的)將會是一個不錯的主意;這會讓隨機數
發生器有更好的機會獲得足夠的熵。
gpg: 密鑰 87FC6DD218033D5F 被標記為絕對信任
gpg: 吊銷證書已被存儲為‘/Users/huanghuanlai/.gnupg/openpgp-revocs.d/9C70D54B941D7831E4B97C8387FC6DD218033D5F.rev’
公鑰和私鑰已經生成并被簽名。
請注意這個密鑰不能用于加密。您可能想要使用“--edit-key”命令來
生成一個用于此用途的子密鑰。
pub rsa2048 2019-01-07 [SC]
9C70D54B941D7831E4B97C8387FC6DD218033D5F
uid dounine (for lake) <xxxxx@gamil.com>
上傳公鑰到兩臺服務器上
keys.gnupg.net 與 keyserver.ubuntu.com
gpg --keyserver keys.gnupg.net --send-keys 9C70D54B941D7831E4B97C8387FC6DD218033D5F
gpg: 正在發送密鑰 87FC6DD218033D5F 到 hkp://hkps.pool.sks-keyservers.net
gpg: 發送至公鑰服務器失敗:No route to host
gpg: 發送至公鑰服務器失敗:No route to host
# 不要慌,使用IP地扯即可 ping keys.gnupg.net 得到 51.38.91.189 地扯
gpg --keyserver 51.38.91.189 --send-keys 9C70D54B941D7831E4B97C8387FC6DD218033D5F
gpg --keyserver keyserver.ubuntu.com --send-keys 9C70D54B941D7831E4B97C8387FC6DD218033D5F
~/.gradle/gradle.properties 配置
pub 是一個40位的密鑰,如果你把它復制上傳肯定會報這么一個錯
The key ID must be in a valid form ...
keyId 其實就是pub最后面8位 或者使用gpg --list-keys --keyid-format short
查看
signing.keyId=18033D5F
signing.password=gpg設置的密碼
signing.secretKeyRingFile=/Users/lake/.gnupg/secring.gpg
NEXUS_USERNAME=NEXUS帳號
NEXUS_PASSWORD=NEXUS密碼
NEXUS_EMAIL=email
build.gradle 演示案例配置文件
group = 'com.dounine.scala'
version = '1.0.0'
apply plugin: 'signing'
apply plugin: 'scala'
apply plugin: 'maven-publish'
sourceCompatibility = 1.8
task sourcesJar(type: Jar) {
from sourceSets.main.allJava
classifier = 'sources'
}
task javadocJar(type: Jar) {
from javadoc
classifier = 'javadoc'
}
publishing {
publications {
mavenJava(MavenPublication) {
artifactId = 'scala-filebeat'
from components.java
artifact sourcesJar
artifact javadocJar
pom {
name = 'scala-filebeat'
description = 'scala version filebeat'
url = 'https://github.com/dounine/scala-filebeat'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'lake'
name = 'lake'
email = 'hello@gmail.com'
}
}
scm {
connection = 'scm:git:git://github.com/dounine/scala-filebeat.git'
developerConnection = 'scm:git:ssh://github.com/dounine/scala-filebeat.git'
url = 'https://github.com/dounine/scala-filebeat'
}
}
}
}
repositories {
maven {
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username NEXUS_USERNAME
password NEXUS_PASSWORD
}
}
}
}
jar {
manifest {
attributes 'Implementation-Title': 'ScalaFilebeat',
'Implementation-Version': version
}
}
signing {
sign publishing.publications.mavenJava
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile 'org.scala-lang:scala-library:2.11.12'
compile group: 'commons-io', name: 'commons-io', version: '2.6'
}
打包
gradle clean build -xtest -Ppro
發布到NEXUS倉庫
gradle publish
最后一步
登錄 NEXUS倉庫
找到自己上傳的項目,點擊close
等待close狀態全部通過即可發布Release版本