如何使用Maven原型创建空文件夹? [英] How to create empty folders with maven archetype?
问题描述
此方法存在一个问题,位于 Codehaus JIRA#ARCHETYPE-57 ,但此票证中列出的所有说明对我而言都失败了.也是marekdec的博客文章
There is an existing issue for this approach, located on Codehaus JIRA #ARCHETYPE-57, but all instructions listed in this ticket failed for me. Also the blog post of marekdec How to get maven archetype to generate empty directories fails for me.
archetype.xml
中带有尾随/
的技巧对我不起作用:
The trick within the archetype.xml
with the trailing /
doesnt works for me:
<resources>
<resource>src/main/webapp/</resource>
Unable to find resource 'archetype-resources/src/main/webapp/'
archetype-metadata.xml
中的fileSet
目录也不适用于我:
Also the fileSet
directory in archetype-metadata.xml
does not work for me:
<fileSet filtered="true" encoding="UTF-8">
<directory>src/main/webapp/</directory>
</fileSet>
我使用以下maven-archetype-plugin创建我的自定义原型.
I use the following maven-archetype-plugin to create my custom archetype.
mvn org.apache.maven.plugins:maven-archetype-plugin:2.0-alpha-5:create
还有其他解决方案吗?还是我错过了什么?谢谢
Is there any other solution? Or did i miss something? Thanks
推荐答案
我做了一个快速测试,...对我有用.首先,我创建了一个原型:
I did a quick test and... it worked for me. First, I created an archetype:
$ mvn archetype:generate -B -DarchetypeArtifactId=maven-archetype-archetype \
-DgroupId=com.stackoverflow \
-DartifactId=Q2786966 \
-Dversion=1.0-SNAPSHOT \
我将archetype.xml
重命名为archetype-metadata.xml
(前者用于Archetype 1.0.X,后者用于Archetype 2.0.X),因此项目看起来像:
I renamed the archetype.xml
into archetype-metadata.xml
(the former is for Archetype 1.0.X, the later is for Archetype 2.0.X) so the project looks like:
$ tree .
.
├── pom.xml
└── src
└── main
└── resources
├── archetype-resources
│ ├── pom.xml
│ └── src
│ ├── main
│ │ └── java
│ │ └── App.java
│ └── test
│ └── java
│ └── AppTest.java
└── META-INF
└── maven
└── archetype-metadata.xml
archetype-metadata.xml
包含:
<?xml version="1.0" encoding="UTF-8"?>
<archetype-descriptor name="Q2786966">
<fileSets>
<fileSet filtered="true" encoding="UTF-8">
<directory>src/main/webapp</directory>
</fileSet>
<fileSet filtered="true" packaged="true">
<directory>src/main/java</directory>
<includes>
<include>**/*.java</include>
</includes>
</fileSet>
</fileSets>
</archetype-descriptor>
然后我安装了原型并用它来创建一个项目:
Then I installed the archetype and used it to create a project:
$ mvn install
$ cd ~/tmp
$ mvn archetype:generate -B -DarchetypeGroupId=com.stackoverflow \
-DarchetypeArtifactId=Q2786966 \
-DarchetypeVersion=1.0-SNAPSHOT \
-DgroupId=my.group \
-DartifactId=my-artifact \
-Dversion=1.0-SNAPSHOT
结果项目如下:
$ tree my-artifact/
my-artifact/
├── pom.xml
└── src
└── main
├── java
│ └── my-group
│ └── App.java
└── webapp
空的webapp目录在那里.
The empty webapp directory is there.
这篇关于如何使用Maven原型创建空文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!