publish.gradle 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. task sourcesJar(type: Jar) {
  2. baseName "${baseName}"
  3. classifier 'sources'
  4. from sourceSets.main.allSource
  5. }
  6. artifacts {
  7. archives sourcesJar
  8. }
  9. apply plugin: 'distribution'
  10. distributions {
  11. main {
  12. baseName = archivesBaseName
  13. contents {
  14. from { libsDir }
  15. }
  16. }
  17. docs {
  18. baseName = "$archivesBaseName-docs"
  19. contents {
  20. from(libsDir) {
  21. include sourcesJar.archiveName
  22. }
  23. }
  24. }
  25. }
  26. ext {
  27. artifactoryBaseUrl = 'http://113.105.74.141:8081/artifactory'
  28. artifactorySnapshotRepoUrl = "$artifactoryBaseUrl/libs-snapshot-local"
  29. artifactoryReleaseRepoUrl = "$artifactoryBaseUrl/libs-release-local"
  30. }
  31. apply plugin: 'maven-publish'
  32. publishing {
  33. publications {
  34. plugin(MavenPublication) {
  35. from components.java
  36. artifactId "${artifactId}"
  37. pom.withXml {
  38. def root = asNode()
  39. root.appendNode('name', "${baseName}")
  40. root.appendNode('description', '商城轮播服务')
  41. root.appendNode('inceptionYear', '2017')
  42. def developer = root.appendNode('developers').appendNode('developer')
  43. developer.appendNode('id', 'yangck')
  44. developer.appendNode('name', '杨朝坤')
  45. developer.appendNode('email', 'yangck@usoftchina.com')
  46. }
  47. artifact sourcesJar
  48. }
  49. }
  50. repositories {
  51. maven {
  52. name 'myLocal'
  53. url "file://$projectDir/repo"
  54. }
  55. maven {
  56. name 'remoteArtifactory'
  57. url project.version.endsWith('-SNAPSHOT') ? artifactorySnapshotRepoUrl : artifactoryReleaseRepoUrl
  58. credentials {
  59. username = 'yingp'
  60. password = '111111'
  61. }
  62. }
  63. }
  64. }