参考资料 https://www.baeldung.com/gradle-build-to-maven-pom https://www.cnblogs.com/clipboard/p/13762512.html
https://www.programminghunter.com/article/475187316/

一开始是新版本2021 Idea运行一些低版本的gradle工程报错,下载老版本2020 idea runtime也进行的替换成jdk1.8最终还是不行。

改造Gradle

  1. plugins {
  2. id 'nebula.netflixoss' version '2.2.10'
  3. }
  4. // https://www.baeldung.com/gradle-build-to-maven-pom
  5. // Establish version and status
  6. ext.githubProjectName = rootProject.name // Change if github project name is not the same as the root project's name
  7. apply plugin: 'maven'
  8. subprojects {
  9. apply plugin: 'nebula.netflixoss'
  10. apply plugin: 'java'
  11. version = '1.0'
  12. sourceCompatibility = 1.8
  13. targetCompatibility = 1.8
  14. group = "com.netflix.ribbon" // TEMPLATE: Set to organization of project
  15. repositories {
  16. jcenter()
  17. }
  18. if (project.hasProperty('useMavenLocal')) {
  19. repositories {
  20. mavenLocal()
  21. }
  22. }
  23. if (project.getProperty('status').equals("snapshot")) {
  24. repositories {
  25. maven { url 'http://oss.jfrog.org/oss-snapshot-local' }
  26. }
  27. }
  28. }
  29. task writeNewPom << {
  30. pom {
  31. project {
  32. inceptionYear '2008'
  33. licenses {
  34. license {
  35. name 'The Apache Software License, Version 2.0'
  36. url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
  37. distribution 'repo'
  38. }
  39. }
  40. }
  41. }.writeTo("$buildDir/pom.xml")
  42. }

执行命令

  1. ./gradlew clean install
  2. ./gradlew writeNewPom

脚本

把生成的pom.xml全部移出来

  1. #!/bin/sh
  2. clear
  3. function showMsg()
  4. {
  5. echo -e "\033[32m$1\033[0m"
  6. }
  7. pomDefaultFile="build/publications/mavenNebula/pom-default.xml"
  8. DIR="$( cd "$( dirname "$0" )" && pwd )"
  9. dir=$(ls)
  10. for item in $dir
  11. do
  12. mv $DIR/$item/$pomDefaultFile $DIR/$item/pom.xml
  13. # showMsg "$DIR/$item"
  14. showMsg "$item"
  15. done