我有一个带有 build.gradle 的示例应用程序,如下所示。我正在尝试将其转换为 Maven
我是 gradle 和 Maven 的新手,但对 Maven 的了解稍微多一点,所以现在想坚持使用它。
我读到了一些说明 https://dzone.com/articles/how-to-convert-maven-to-gradle-and-vice-versa
我将“apply plugin maven”行放入其中,以获取按照说明生成的 pom 文件。当我运行 gradlew install 时出现以下错误
Execution failed for task ':install'.
Could not publish configuration 'archives' Cannot publish artifact 'hello-world-java.jar' (C:\Users\xxx\IdeaProjects\HelloWorld-Java\build\libs\hello-world-java-0.1.0.jar) as it does not exist.
我之前一直在这个项目上工作得很好(从 InteliJ IDEA 运行它)。 我之前还成功地将另一个项目(基于控制台)转换为 Maven。
我也见过https://docs.gradle.org/current/userguide/publishing_overview.html#sec:configuring_publishing_tasks 然而我实际上并不想发布存档,我只是想要等效的 pom.xml。我注意到如果我没有 Maven 插件,安装任务就不存在。我也尝试只进行 gradlew 编译,但它没有生成 pom.xml。我想我需要阅读更多关于 mavin 插件的内容
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.1.0.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
bootJar{
mainClassName = 'com.intuit.developer.helloworld.Application'
}
jar {
archiveBaseName = 'hello-world-java'
archiveVersion = '0.1.0'
}
repositories {
mavenCentral()
mavenLocal()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile("com.intuit.quickbooks-online:ipp-v3-java-data:4.0.1")
compile (group: 'com.intuit.quickbooks-online', name: 'ipp-v3-java-devkit', version: '4.0.1', classifier: 'jar-with-dependencies')
compile (group: 'com.intuit.quickbooks-online', name: 'oauth2-platform-api', version: '4.0.1', classifier: 'jar-with-dependencies')
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
compile("org.springframework.data:spring-data-rest-webmvc")
compile("org.json:json")
compile("log4j:log4j:1.2.17")
compile (group: 'ant', name: 'ant', version: '1.7.0')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
wrapper {
gradleVersion = '2.3'
}
最佳答案
Gradle 构建生成的 Maven POM 仅包含项目使用者所需的信息:依赖项。 POM 将没有关于使用 Maven 构建库本身的配置,例如插件和其他东西。
关于java - 将 gradle 转换为 Maven,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58188348/