Maven:配置文件激活取决于 localRepository 属性?
在 Maven 中,我只想在工件尚未安装到存储库时才执行构建。我的想法是使用默认情况下处于非活动状态的配置文件,但如果工件丢失,则会被激活。 到目前为止我还没有成功,因为Maven属性似乎不能用于配置文件激活?
settings.xml:
...
<localRepository>/local/m2repo</localRepository>
...
1)这有效:
pom.xml:
...
<profile>
<id>my-profile</id>
<activation>
<activeByDefault>false</activeByDefault>
<file>
<missing>/local/m2repo/something</missing>
</file>
</activation>
...
</profile>
2)这不起作用:
pom.xml:
...
<profile>
<id>my-profile</id>
<activation>
<activeByDefault>false</activeByDefault>
<file>
<missing>${settings.localRepository}/something</missing>
</file>
</activation>
...
</profile>
3)这也不起作用:
settings.xml:
...
<properties>
<local.repository>${settings.localRepository}</local.repository>
</properties>
...
pom.xml:
<profile>
<id>my-profile</id>
<activation>
<activeByDefault>false</activeByDefault>
<file>
<missing>${local.repository}/something</missing>
</file>
</activation>
</profile>
是否有某种解决方法或替代方法我可以检查我的工件是否存在,并且仅在必要时运行构建? 感谢您的任何想法!
in Maven I want to execute a build only if the artifact has not yet been installed to the repository. My idea is to use a profile which is inactive by default, but will be activated if the artifact is missing.
So far I was not successful because it seems that Maven properties cannot be used for profile activation?
settings.xml:
...
<localRepository>/local/m2repo</localRepository>
...
1) This works:
pom.xml:
...
<profile>
<id>my-profile</id>
<activation>
<activeByDefault>false</activeByDefault>
<file>
<missing>/local/m2repo/something</missing>
</file>
</activation>
...
</profile>
2) This doesn't work:
pom.xml:
...
<profile>
<id>my-profile</id>
<activation>
<activeByDefault>false</activeByDefault>
<file>
<missing>${settings.localRepository}/something</missing>
</file>
</activation>
...
</profile>
3) This won't work either:
settings.xml:
...
<properties>
<local.repository>${settings.localRepository}</local.repository>
</properties>
...
pom.xml:
<profile>
<id>my-profile</id>
<activation>
<activeByDefault>false</activeByDefault>
<file>
<missing>${local.repository}/something</missing>
</file>
</activation>
</profile>
Is there somehow a workaround or alternative how I can check for the existence of my artifact and only run a build if necessary?
Thanks for any ideas!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你不能那样做。
激活文件位置通常相对于当前项目文件夹。
仅在配置文件已定义并开始构建后才会计算属性。
You can't do that.
The activation file location normally are relative to the current project folder.
The properties will be calculated only after the profiles are already defined and build started.