【问题标题】:Template not in directory模板不在目录中
【发布时间】:2013-11-19 00:45:46
【问题描述】:

我创建了自己的原型,它模仿了 Eclipse 的新项目向导(不使用 Maven 时 Eclipse 默认执行的方式)。它在其子目录结构中建立了一个纯 Java 项目,没有 Maven/旧 Java 中传统的 main/javatest/java 子目录。

archetype.xml

<archetype>
  <id>java-project</id>
  <allowPartial>true</allowPartial>
  <sources>
    <source>src/App.java</source>
  </sources>
  <resources>
    <resource>src</resource>
  </resources>
  <testSources>
    <source>test/AppTest.java</source>
  </testSources>
  <testResources>
    <resource>test</resource>
  </testResources>
</archetype>

原型构建和安装成功,但用于创建新项目时,

$ mvn archetype:generate -DarchetypeGroupId=com.etretatlogiciels \
        -DarchetypeArtifactId=java-project \
        -DarchetypeVersion=1.0 \
        -DgroupId=com.funk \
        -DartifactId=funk-project \
        -DarchetypeRepository=/home/russ/.m2/repository

它给出了这个 BUILD FAILURE 错误:

[ERROR] 未能执行目标 org.apache.maven.plugins:maven-archetype-plugin:2.2:generate 项目standalone-pom上的(默认cli):模板'src/App.java'不是 在目录 'src/main/java' -> [帮助 1]

我试图确定为什么它听起来像是在尝试使用更复杂的传统 Maven 文件系统结构 (src/main/java/.../App.java),而当我已经明确地定制了 achetype.xml 文件来创建

src/.../App.java
test/.../AppTest.java

即:Eclipse 执行此操作的更简单方式。

谢谢

【问题讨论】:

  • 您是否将文件App.java 正确放置在目录src/main/resources/archetype-resources/src/main/java 中。 src/main/resources/archetype-resources/src?
  • @thomas:是的,我确实这样做了。

标签: eclipse maven


【解决方案1】:

在 META-INF/maven 中定义自定义 archetype-metadata.xml 文件帮助了我

<fileSets>
<fileSet filtered="true" packaged="true" encoding="UTF-8">
  <directory>src/directory>
  <includes>
    <include>**/*.java</include>
  </includes>
</fileSet>

http://maven.apache.org/archetype/archetype-models/archetype-descriptor/archetype-descriptor.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-07-18
    • 2015-06-25
    • 2014-09-15
    • 2012-03-20
    • 2011-06-08
    • 2018-03-31
    • 1970-01-01
    相关资源
    最近更新 更多