publish.gradle 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. apply plugin: 'maven-publish'
  2. apply from: 'config.gradle'
  3. //打包main目录下代码和资源的 task
  4. task androidSourcesJar(type: Jar) {
  5. classifier = 'sources'
  6. from android.sourceSets.main.java.srcDirs
  7. }
  8. String GROUP_ID = "extra.common"
  9. String ARTIFACT_ID = "user"
  10. String versionName = "$ext.atmob_user_version_name"
  11. String publishUrl
  12. afterEvaluate {
  13. publishing {
  14. publications {
  15. // Creates a Maven publication called "release".
  16. release(MavenPublication) {
  17. // Applies the component for the release build variant.
  18. from components.release
  19. // You can then customize attributes of the publication as shown below.
  20. groupId = GROUP_ID
  21. artifactId = ARTIFACT_ID
  22. version = versionName
  23. publishUrl = "${atmob_maven_url}/repository/android-release/"
  24. }
  25. // Creates a Maven publication called “debug”.
  26. debug(MavenPublication) {
  27. // Applies the component for the debug build variant.
  28. from components.debug
  29. groupId = GROUP_ID
  30. artifactId = ARTIFACT_ID
  31. version = "$versionName-SNAPSHOT"
  32. publishUrl = "${atmob_maven_url}/repository/android-snapshot/"
  33. }
  34. }
  35. repositories {
  36. maven {
  37. name = "nexus"
  38. allowInsecureProtocol true
  39. credentials {
  40. username = "$atmob_maven_username"
  41. password = "$atmob_maven_password"
  42. }
  43. url = publishUrl
  44. }
  45. }
  46. }
  47. }