我有一个专有的jar,我想作为依赖添加到我的pom.
但我不想将它添加到存储库.原因是我希望我的常用maven命令等mvn compile开箱即用.(没有要求开发人员将其自己添加到某个存储库中).
我希望jar在源代码控制中位于第3方库中,并通过pom.xml文件的相对路径链接到它.
可以这样做吗?怎么样?
我有一个多模块项目,像这样:
main-project/
module1/
module2/
sub-module1/
sub-module2/
sub-module3/
...
module3/
module4/
...
Run Code Online (Sandbox Code Playgroud)
我需要在Maven2中定义一组属性(取决于我想要释放项目的环境).我不会使用<properties>因为有很多属性...因此,我使用Properties Maven2插件.
属性文件位于main-project/目录中.如何在主pom.xml中设置正确的目录,以便为任何子项指定在哪里找到属性文件?
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-1</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>???/env_${env}.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
如果我只设置<file>env_${env}.properties</file>,那么当Maven2编译第一个模块时,它将找不到该main-project/env_dev.properties文件.如果我设置<file>../env_${env}.properties</file>,那么将在父级别或任何子模块级别引发错误...
在多模块maven项目中,是否有一个指向根项目文件夹的变量?
${project.basedir} 指向当前项目的目录,${project.parent.basedir} 指向父项目的目录, 但是有一个变量总是指向根目录(执行maven命令的目录),无论反应堆内的哪个项目?
我意识到我想要解决的问题几乎无法解决.我想要一个指向project.basedir,project.parent.basedir,project.parent.parent.basedir等的变量,以较高者为准.但是由于项目的父pom不一定是文件系统中的父项,我的整个方法都无济于事.所以我接受Pascal的答案,因为它回答了我的问题(即使我的问题没有解决我的问题).