摘要
一、将项目推送到远程仓库,如 Github
或者Gitee
二、注册 Sonatype
账户
三、登录 Sonatype 创建Namespace
前三个步骤与 发布Jar到Maven中央仓库--Maven版(最新方式) 相同,不在赘述。
四、发布
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 plugins { id 'io.spring.dependency-management' version '1.1.6' id 'java-library' id 'maven-publish' id 'org.jreleaser' version '1.13.1' } group = 'io.github.hanqunfeng' version = '1.0.1' sourceCompatibility = '1.8' java { withJavadocJar() withSourcesJar() } repositories { maven { url 'https://maven.aliyun.com/repository/public/' } mavenLocal() mavenCentral() } dependencyManagement { imports { mavenBom("software.amazon.awssdk:bom:2.23.10" ) } } dependencies { compileOnly 'org.projectlombok:lombok:1.18.32' annotationProcessor 'org.projectlombok:lombok:1.18.32' api 'software.amazon.awssdk:s3' api 'software.amazon.awssdk:apache-client' api 'software.amazon.awssdk:s3-transfer-manager' api 'software.amazon.awssdk:aws-crt-client' api 'org.springframework:spring-core:5.3.29' } [compileJava, compileTestJava]*.options *.encoding = 'UTF-8' publishing { publications { maven(MavenPublication) { groupId = project .group artifactId = project .name version = project .version from components.java pom { name = 'aws-s3-v2-tools-gradle' description = 'AWS S3 Tools.' url = 'https://blog.hanqunfeng.com' licenses { license { name = 'The Apache License, Version 2.0' url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' } } developers { developer { id = 'hanqf' name = 'han qunfeng' email = 'qunfeng_han@126.com' } } scm { connection = 'scm:git:https://github.com/hanqunfeng/aws-s3-v2-tools-gradle.git' developerConnection = 'scm:git:https://github.com:hanqunfeng/aws-s3-v2-tools-gradle.git' url = 'https://github.com/hanqunfeng/aws-s3-v2-tools-gradle' } } versionMapping { usage('java-api' ) { fromResolutionOf('runtimeClasspath' ) } usage('java-runtime' ) { fromResolutionResult() } } } } repositories { maven { url = layout.buildDirectory.dir('staging-deploy' ) } } } tasks.withType(JavaCompile) { options .encoding = 'UTF-8' } tasks.withType(Javadoc) { options .version = true options .author = true options .encoding = "UTF-8" options .charSet = "UTF-8" } javadoc { if (JavaVersion.current().isJava9Compatible()) { options .addBooleanOption('html5' , true ) } if (JavaVersion.current().isJava8Compatible()) { tasks.withType(Javadoc) { options .addStringOption('Xdoclint:none' , '-quiet' ) } } } jreleaser { signing { active = 'ALWAYS' armored = true mode = 'FILE' publicKey = '/Users/hanqf/develop_soft/gpg_key/hanqf/public.pgp' secretKey = '/Users/hanqf/develop_soft/gpg_key/hanqf/private.pgp' } deploy { maven { mavenCentral { sonatype { active = 'ALWAYS' url = 'https://central.sonatype.com/api/v1/publisher' stagingRepository('build/staging-deploy' ) } } } } }
1 2 3 4 5 6 7 8 9 10 JRELEASER_MAVENCENTRAL_USERNAME = "<your-publisher-portal-username>" JRELEASER_MAVENCENTRAL_PASSWORD = "<your-publisher-portal-password>" JRELEASER_NEXUS2_USERNAME = "<your-sonatype-account-username>" JRELEASER_NEXUS2_PASSWORD = "<your-sonatype-account-password>" JRELEASER_GPG_PASSPHRASE = "<your-pgp-passphrase>" JRELEASER_GITHUB_TOKEN = "<your-github-token"
1 2 3 ./gradlew jreleaserConfig ./gradlew clean publish ./gradlew jreleaserFullRelease