I have two profiles in pom.xml, and I have some resource files which I have added into target resource directory: ${project.build.outputDirectory}/resources
during execution of the first profile. What I need to do is remove those resource files during execution of the second profile.
Is there any way to remove or delete existing files from target directory?
相关问题
- Include pom.xml in Jar with gradle
- What order does maven find its dependencies?
- proguard causing EnumMap NPE on dynamically declar
- Maven: How to read the Parent POM version
- enableHiveSupport throws error in java spark code
相关文章
- IDEA2020 安装maven 插件后,springboot程序 SpringBootApplic
- pom文件中的插件定义
- pom.xml中的project为何报红
- Hibernate Tutorial - Where to put Mapping File?
- Cannot use org.jvnet.jax-ws-commons.jaxws-maven-pl
- New Maven install: mvn -version java.lang.ClassNot
- What's the difference between archetype.xml an
- NoNodeAvailableException[None of the configured no
thanks to above answers. finally i came to something like:
if you want to just delete some directories in target folder, you have to create some construct like this.
this for instance deletes just all contents of folders:
excludeDefaultDirectories allows to not delete complete target folder.
i used it to clean up target folder before lint analysis.
Solution with Apache Maven AntRun Plugin 1.8:
I needed only a couple of files deleted from the output directory, the following worked fine for me.
I also figured that you can run any ant commands here replace what ever task you need in between the
<tasks> .... </tasks>
and it will work.List of ant tasks that you can perform are here
Ref: http://maven.apache.org/plugins/maven-antrun-plugin/usage.html
I got the solution..!!
for reference - http://maven.apache.org/guides/mini/guide-building-for-different-environments.html
I do agree with Matthew's observations, but I got the impression that the original poster was asking how to automate execution of
clean
during (normal) "execution" of a profile.You can define a plugin execution for the Maven Clean Plugin. It is normally only bound to
clean
, but by defining a plugin execution you can bindclean:clean
(that is theclean
goal of theclean
plugin) to whichever lifecycle phase you want. The documentation of the Maven Clean Plugin has an example of how to do this. The documentation also has an example of deleting additional files. Merged the two looks like this:mvn clean
will remove thetarget
directory (and therefore all the files in it). If you want to remove only certain files from thetarget
directory, a combination of:excludeDefaultDirectories
to stop it from deleting the whole directory, andfilesets
to tell it what to deleteref: http://maven.apache.org/plugins/maven-clean-plugin/clean-mojo.html