apply plugin: 'maven-publish' apply from: 'config.gradle' //打包main目录下代码和资源的 task task androidSourcesJar(type: Jar) { classifier = 'sources' from android.sourceSets.main.java.srcDirs } String GROUP_ID = "extra.common" String ARTIFACT_ID = "user" String versionName = "$ext.atmob_user_version_name" String publishUrl afterEvaluate { publishing { publications { // Creates a Maven publication called "release". release(MavenPublication) { // Applies the component for the release build variant. from components.release // You can then customize attributes of the publication as shown below. groupId = GROUP_ID artifactId = ARTIFACT_ID version = versionName publishUrl = "${atmob_maven_url}/repository/android-release/" } // Creates a Maven publication called “debug”. debug(MavenPublication) { // Applies the component for the debug build variant. from components.debug groupId = GROUP_ID artifactId = ARTIFACT_ID version = "$versionName-SNAPSHOT" publishUrl = "${atmob_maven_url}/repository/android-snapshot/" } } repositories { maven { name = "nexus" allowInsecureProtocol true credentials { username = "$atmob_maven_username" password = "$atmob_maven_password" } url = publishUrl } } } }