task sourcesJar(type: Jar) { baseName "${baseName}" classifier 'sources' from sourceSets.main.allSource } artifacts { archives sourcesJar } apply plugin: 'distribution' distributions { main { baseName = archivesBaseName contents { from { libsDir } } } docs { baseName = "$archivesBaseName-docs" contents { from(libsDir) { include sourcesJar.archiveName } } } } ext { artifactoryBaseUrl = 'http://113.105.74.141:8081/artifactory' artifactorySnapshotRepoUrl = "$artifactoryBaseUrl/libs-snapshot-local" artifactoryReleaseRepoUrl = "$artifactoryBaseUrl/libs-release-local" } apply plugin: 'maven-publish' publishing { publications { plugin(MavenPublication) { from components.java artifactId "${artifactId}" pom.withXml { def root = asNode() root.appendNode('name', 'base-OAuth2-service') root.appendNode('description', '用户授权服务') root.appendNode('inceptionYear', '2017') def developer = root.appendNode('developers').appendNode('developer') developer.appendNode('id', 'yingp') developer.appendNode('name', '应鹏') developer.appendNode('email', 'yingp@usoftchina.com') } artifact sourcesJar } } repositories { maven { name 'myLocal' url "file://$projectDir/repo" } maven { name 'remoteArtifactory' url project.version.endsWith('-SNAPSHOT') ? artifactorySnapshotRepoUrl : artifactoryReleaseRepoUrl credentials { username = 'yingp' password = '111111' } } } }