如何将Gradle与Maven合并

huangapple go评论76阅读模式
英文:

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:

&lt;dependencies&gt;
  	&lt;dependency&gt;
  		&lt;groupId&gt;com.sun.xml.ws&lt;/groupId&gt;
  		&lt;artifactId&gt;jaxws-ri&lt;/artifactId&gt;
  		&lt;version&gt;3.0.0-M3&lt;/version&gt;
  		&lt;type&gt;pom&lt;/type&gt;
  	&lt;/dependency&gt;
  	&lt;dependency&gt;
  &lt;groupId&gt;jakarta.xml.ws&lt;/groupId&gt;
  &lt;artifactId&gt;jakarta.xml.ws-api&lt;/artifactId&gt;
  &lt;version&gt;2.3.3&lt;/version&gt;
&lt;/dependency&gt;
  &lt;/dependencies&gt;

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: &#39;com.sun.xml.ws&#39;, name: &#39;jaxws-ri&#39;, version: &#39;3.0.0-M3&#39;, ext: &#39;pom&#39;
compile group: &#39;jakarta.xml.ws&#39;, name: &#39;jakarta.xml.ws-api&#39;, version: &#39;2.3.3&#39;

huangapple
  • 本文由 发表于 2020年8月24日 08:46:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/63553368.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定