英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论