gradle插件怎么上传nexus
时间: 2023-01-11 20:55:36 浏览: 73
上传 gradle 插件到 nexus 私服的方法如下:
1. 配置 gradle 的 `build.gradle` 文件,添加如下代码:
```
apply plugin: 'maven'
def siteUrl = 'http://your_nexus_server/repository/maven-releases'
def deployRepo = 'maven-releases'
uploadArchives {
repositories {
mavenDeployer {
repository(url: "${siteUrl}") {
authentication(userName: "your_username", password: "your_password")
}
pom.project {
packaging 'gradle-plugin'
name 'your_plugin_name'
description 'your_plugin_description'
url 'your_plugin_url'
scm {
connection 'your_scm_connection_url'
developerConnection 'your_scm_developer_connection_url'
url 'your_scm_url'
}
licenses {
license {
name 'The Apache License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id 'your_developer_id'
name 'your_name'
email 'your_email'
}
}
}
}
}
}
```
2. 运行以下命令来上传插件到 nexus 私服:
```
./gradlew clean build uploadArchives
```
3. 在你的应用中使用该插件时,需要在 `build.gradle` 文件中添加如下代码来声明你的私服地址:
```
buildscript {
repositories {
maven {
url 'http://your_nexus_server/repository/maven-releases'
}
}
dependencies {
classpath 'your_group_id:your_artifact_id:your_version'
}
}
```
然后你就可以使用 `apply plugin: 'your_artifact_id'` 来应用插件了。