upload.gradle 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // 打包源代码,为了方便查看源码及调试,把源码也上传到nexus仓库中
  2. task sourcesJar(type: Jar, dependsOn: classes) {
  3. archiveClassifier = 'sources'
  4. from sourceSets.main.allSource
  5. }
  6. // 打javadoc包,为了方便查看注释,需要把javadoc也上传到nexus仓库中
  7. task javadocJar(type: Jar, dependsOn: javadoc) {
  8. classifier = 'javadoc'
  9. from javadoc.destinationDir
  10. }
  11. tasks.withType(Javadoc) {
  12. options.addStringOption('Xdoclint:none', '-quiet')
  13. options.addStringOption('encoding', 'UTF-8')
  14. options.addStringOption('charSet', 'UTF-8')
  15. }
  16. artifacts {
  17. archives sourcesJar
  18. archives javadocJar
  19. }
  20. apply plugin: 'maven-publish'
  21. publishing {
  22. publications {
  23. maven(MavenPublication) {
  24. groupId this.group
  25. artifactId project.name
  26. if ("unspecified".equals(project.version)) {
  27. version parent.version
  28. } else {
  29. version project.version
  30. }
  31. from components.java
  32. versionMapping {
  33. usage('java-api') {
  34. fromResolutionOf('runtimeClasspath')
  35. }
  36. usage('java-runtime') {
  37. fromResolutionResult()
  38. }
  39. }
  40. artifact sourcesJar
  41. }
  42. }
  43. repositories {
  44. maven {
  45. def version;
  46. if ("unspecified".equals(project.version)) {
  47. version = parent.version
  48. } else {
  49. version = project.version
  50. }
  51. if (version.endsWith('-SNAPSHOT')) {
  52. url = REPOSITORY_SNAPSHOT_URL
  53. } else {
  54. url = REPOSITORY_RELEASE_URL
  55. }
  56. credentials {
  57. username 'publicaccount'
  58. password 'publicaccount@2022'
  59. }
  60. }
  61. }
  62. }