Skip to content

Instantly share code, notes, and snippets.

@gcdd1993
Last active May 29, 2021 19:22
Show Gist options
  • Save gcdd1993/1d4d76b6178e591700f884659205cac9 to your computer and use it in GitHub Desktop.
Save gcdd1993/1d4d76b6178e591700f884659205cac9 to your computer and use it in GitHub Desktop.
[maven-publish]maven发布 #maven
//plugins {
// id 'java-library'
// id 'maven-publish'
//}
// or
//plugins {
// id 'java-platform'
// id 'maven-publish'
//}
// apply from 'maven-publish.gradle'
def artifactory = 'https://packages.aliyun.com/maven/repository/'
def releasePath = "xxxx"
def snapshotsPath = "xxxx"
def mavenName = 'xxx'
afterEvaluate { Project project ->
if (project.plugins.hasPlugin("maven-publish")) {
if (project.plugins.hasPlugin("java")) {
java {
withSourcesJar()
}
}
publishing {
repositories {
maven {
name "${mavenName}"
url = "${artifactory}${(version.endsWith('SNAPSHOT') ? snapshotsPath : releasePath)}"
credentials {
username "${maven_username}"
password "${maven_password}"
}
authentication {
basic(BasicAuthentication)
}
}
}
publications {
tabbyApp(MavenPublication) {
from components.java
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment