如果文件不存在,则跳过Maven插件的执行 [英] Skip execution of a maven plugin if a file does not exist

查看:121
本文介绍了如果文件不存在,则跳过Maven插件的执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将hibernate3-maven-plugin放在我的父pom中,如果给定文件不存在于子模块中,则跳过执行.

I want to put the hibernate3-maven-plugin in my parent pom and have execution skipped in child modules if a given file does not exist in that module.

有什么办法吗?

到目前为止,我必须这样做:

Up to now, I have had to do this:

<plugin>
   ...
   <configuration>
      <skip>true</skip>
      <propertyfile>target/test-classes/jdbc.properties</propertyfile>
   </configuration>
</plugin>

在父POM中,并且:

<plugin>
   ...
   <configuration>
      <skip>${maven.test.skip}</skip>
   </configuration>
</plugin>

在我要执行的所有子POM中.即那些实际上拥有jdbc.properties文件的人.

In all child POMs where I want it to execute. I.E Those actually having a jdbc.properties file.

推荐答案

您可以使用配置文件执行此操作,但是我想您可能不想在父项目中运行它,这可能会出现问题. br> 以下是个人资料上的一些链接:

You may be able to do this with profiles, but I suppose you'd probably not want to run it in the parent project, which may be problematic.
Here are some links on profiles:

  • http://maven.apache.org/guides/introduction/introduction-to-profiles.html
  • http://www.sonatype.com/books/mvnref-book/reference/profiles.html
  • http://mindthegab.com/2008/12/02/howto-give-your-multimodule-maven-build-subprojectenvironment-specific-behavior/

这个问题,存在类似的问题,无法通过配置文件解决:
activate-different-maven-profiles-depending-on-current-module

This question, had a similar issue and was not able to solve it with profiles:
activate-different-maven-profiles-depending-on-current-module

这篇关于如果文件不存在,则跳过Maven插件的执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆