Maven依赖与可重复使用的构建目标

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

Maven dependency with reusable build goals

问题

我在开发一个Java SDK。项目的构建工具是Maven。这个SDK提供了用于编写API代码的类(助手)。它还提供了一个构建配置,可以以特定方式构建应用程序(本地镜像)。

为了使用SDK中的构建配置,我(认为我)需要将其打包为pom,然后将其用作父级。然而,为了使用所有SDK类,我需要将其打包为jar

在上述描述的方式中使用Maven依赖是否可行?或者我实际上需要两个项目,一个只是SDK,另一个提供构建配置?

英文:

I'm working on a Java SDK. The project's build tool is Maven. The SDK provides classes (helpers) to write code for an API. It also provides a build configuration which makes it possible to build the application in a specific way (native image).

To use the build configuration from the SDK I (think I) need to package it as a pom, and then use it as a parent. However, to use all the SDK classes, I need to package it as a jar.

Is it possible to use a Maven dependency is the above described way? Or maybe I actually need two projects, one for just the SDK, and the other one which would provide the build configuration?

答案1

得分: 1

你不能混合这两个方面。

要提供一个依赖项,你需要构建一个JAR文件。

要提供构建配置,你可以提供一个父POM。不过要注意,很多人已经在使用父POM,而且你不能同时使用两个父POM。因此,最好提供一个XML片段,供复制粘贴到POM文件中。

英文:

You cannot mix the two aspects.

To provide a dependency, you build a JAR.

To provide build configuration, you can provide a parent POM. Beware, though, that many people already use parent POMs and you cannot have two parent POMs at the same time. So it might be better to provide an XML snippet to copy&paste into the POM.

huangapple
  • 本文由 发表于 2023年5月11日 19:51:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/76227350.html
匿名

发表评论

匿名网友

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

确定