个人环境
Macbook Air M1 使用 SDK 工具安装的 Gradle 7.4
一、配置代码
下面是 build.gradle 的配置
plugins {
// 定义上传私服的是一个java库
id 'java-library'
// 上传需要用到 maven-publish 插件
id 'maven-publish'
}
group 'com.example'
version '0.1.1'
repositories {
mavenCentral()
}
publishing {
publications {
// myPublication 是自定义的名字
myPublication(MavenPublication) {
artifactId = rootProject.name
// 用于生成 jar 文件
from components.java
groupId = group
version = version
}
}
repositories {
maven {
// 配置私服的用户名密码
credentials {
// usr与pwd 我个人配置在 .gradle 的 gradle.properties 中
username = "$usr"
password = "$pwd"
}
// 私服的服务地址
url = "http://0.0.0.0:8081/repository/maven-releases/"
// 允许使用 http
allowInsecureProtocol = true
}
}
}
dependencies {
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'org.jetbrains:annotations:23.0.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
}
test {
useJUnitPlatform()
}
此时即可使用 gradle 的 publish 来发布包
总结
相关阅读
版权声明:本文为AhogeK原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。