Last active
May 29, 2021 19:22
-
-
Save gcdd1993/1d4d76b6178e591700f884659205cac9 to your computer and use it in GitHub Desktop.
[maven-publish]maven发布 #maven
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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