Last active
August 29, 2015 14:26
-
-
Save zhengzhou/721c26c9db4123b7c449 to your computer and use it in GitHub Desktop.
custom gradle plugin.
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
class PublishPlugin implements Plugin<Project>{ | |
def mavenName = 'my maven' | |
@Override | |
void apply(Project target) { | |
PublishExtension extension = project.extensions.create('publish', PublishExtension) | |
project.apply([plugin: 'maven']) | |
} | |
void attachArtifacts(Project project) { | |
project.uploadArchives{ | |
repositories.mavenDeployer { | |
name = mavenName | |
//release版本 | |
repository(url: "http://192.168.1.200:8081/nexus/content/repositories/releases/") { | |
authentication(userName: 'admin', password: '123') | |
} | |
//snapshot版本 | |
snapshotRepository(url: "http://192.168.1.200:8081/nexus/content/repositories/snapshots/") { | |
authentication(userName: 'admin', password: '123') | |
} | |
pom.version = project.publish.version | |
pom.artifactId = project.publish.artifactId | |
pom.groupId = project.publish.packaging | |
pom.packaging = 'aar' | |
} | |
} | |
//Artifact artifacts = project.plugins.hasPlugin('com.android.library') ? new AndroidArtifacts() : new JavaArtifacts() | |
} | |
} | |
class PublishExtension { | |
String pomString = 'package:artifact:1.0.0'; | |
String getPackaging(){ | |
pomString.split(':').first() | |
} | |
String getArtifactId(){ | |
pomString.split(':')[1] | |
} | |
String getVersion(){ | |
pomString.split(':').last() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment