英文:
How to merge gradle with maven
问题
I imported a gradle project on my eclipse. (I am using Java 11.) I had codes which uses jakarta.xml libraries.
import jakarta.xml.soap.*;
For it to function, I added Maven dependencies for jaxws-rt:
<dependencies>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-ri</artifactId>
<version>3.0.0-M3</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>jakarta.xml.ws</groupId>
<artifactId>jakarta.xml.ws-api</artifactId>
<version>2.3.3</version>
</dependency>
</dependencies>
But when I try to generate the build, it shows following error:
error: package jakarta.xml.soap does not exist
import jakarta.xml.soap.*;
If I refresh the project as a Maven project the gradle feature gets disabled. If I run it as a gradle project, the maven dependencies get disabled. Can you please suggest how to run the build?
英文:
I imported a gradle project on my eclipse. (I am using Java 11.) I had codes which uses jakarta.xml libraries.
import jakarta.xml.soap.*;
For it to function, I added Maven dependencies for jaxws-rt:
<dependencies>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-ri</artifactId>
<version>3.0.0-M3</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>jakarta.xml.ws</groupId>
<artifactId>jakarta.xml.ws-api</artifactId>
<version>2.3.3</version>
</dependency>
</dependencies>
But when I try to generate the build, it shows following error:
error: package jakarta.xml.soap does not exist
import jakarta.xml.soap.*;
If I refresh the project as a Maven project the gradle feature gets disabled. If I run it as a gradle project, the maven dependencies get disabled. Can you please suggest how to run the build?
答案1
得分: 1
不要在两个不同的构建平台上管理单独的依赖关系。
您应该选择使用 Maven
或者 Gradle
其中之一。拥有两个构建系统会导致不必要的重复工作,并且仍然需要持续维护。沿着这个方向继续前进将要求您管理两个相同类型的单独构建文件。您在 Gradle 配置中的每个依赖项也需要添加到您的 Maven 配置中。
与其试图为 Maven 构建创建一个 pom.xml
,您应该确定要提取的库的 Gradle 等效物。
compile group: 'com.sun.xml.ws', name: 'jaxws-ri', version: '3.0.0-M3', ext: 'pom'
compile group: 'jakarta.xml.ws', name: 'jakarta.xml.ws-api', version: '2.3.3'
英文:
Do not manage separate dependencies on two different build platforms.
You will want to choose either Maven
or Gradle
. Having two build systems will cause unnecessary duplicate work and still requires continued maintenance. Going down this path will require you to manage two separate build files that are identical in nature. Every dependency in your gradle config will also need to be added to your maven config.
Instead of trying to create a pom.xml
for the Maven build, you will want to determine the Gradle equivalent for the libraries you want to pull.
compile group: 'com.sun.xml.ws', name: 'jaxws-ri', version: '3.0.0-M3', ext: 'pom'
compile group: 'jakarta.xml.ws', name: 'jakarta.xml.ws-api', version: '2.3.3'
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论