【问题标题】:maven-eclipse-plugin configuration of directoriesmaven-eclipse-plugin 目录配置
【发布时间】:2013-08-26 13:47:00
【问题描述】:

maven-eclipse-plugin 目录配置

嗨, 我被分配为现有的 Eclipse 项目添加 Maven 支持。源代码在 Groovy 中。 我们的想法是我们将有一个 pom.xml 文件指定所有项目参数和依赖项,以及 我们将简单地运行 mvn eclipse:eclipse 来生成必要的 Eclipse .project 和 .classpath 文件。

重要提示:该项目具有我们想要继续使用的特定目录结构,即我们不想要 切换到 Maven 结构。

我尝试使用 pom 文件中的以下条目来解决此问题,但没有成功:

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-eclipse-plugin</artifactId>
       <version>2.9</version>
       <configuration>  
         <sourceDirectory>src</sourceDirectory>
         <outputDirectory>bin</outputDirectory>     
    <additionalProjectnatures>    <projectnature>org.eclipse.jdt.groovy.core.groovyNature</projectnature>                    </additionalProjectnatures>
       </configuration>
</plugin>
....
....
</build>

我希望这会在 .classpath 文件中创建以下行: 但事实并非如此。 我得到的唯一相关条目是: 我猜这是某种默认值。

我尝试了来自 stackoverflow 和谷歌搜索的各种建议,但没有成功。 唯一给我一些进步的想法是使用以下命令行: mvn eclipse:eclipse -DoutputSirectory=bin 这确实为我在类路径文件中提供了所需的输出路径。然而: mvn eclipse:eclipse -DsourceSirectory=src 不工作。

我是 Maven 新手,虽然我知道它有利于约定而不是配置,但我觉得很难相信 它根本不允许任何这种配置。

关于如何在 Maven 生成的 .classpath 文件中精确指定源和输出 (bin) 目录的任何想法 日食插件?

提前致谢。

【问题讨论】:

  • 你知道maven eclipse插件与最新版本的eclipse不兼容吗?现在的标准方法是使用 m2e 并忘记 eclipse:eclipse

标签: eclipse maven groovy


【解决方案1】:

尝试先执行 mvn eclipse:clean,然后再执行 eclipse:eclipse。这里还有一些额外的配置,我发现在 Eclipse 中使用 groovy 时很有帮助

<configuration>
<additionalProjectnatures>
    <projectnature>org.eclipse.jdt.groovy.core.groovyNature</projectnature>
</additionalProjectnatures>
<!-- Source includes is helpfule to allow groovy files in the java folder, else eclipse might throw a filtering exception -->
<sourceIncludes>
    <sourceInclude>**/*.groovy</sourceInclude>
</sourceIncludes>

【讨论】:

  • @Hilikus:谢谢!我不知道。我正在使用基于 Juno Service Release 2 Build id: 20130225-0426 的“面向汽车软件开发人员的 Eclipse IDE”,所以我想目前应该没问题。但如果从现在开始的标准是 m2e,那么我们可能应该朝着这个方向前进。
  • @Hilikus:你知道是否可以使用 m2e 配置所有 eclipse .classpath 详细信息吗?例如,我的“原始” .classpath(eclipse 生成)具有以下理想条目:
  • 到目前为止,我还没有找到一种方法来“说服” mvn eclipse:eclipse 来生成这些,无论我在我的 pom 文件中放了什么。 (我是 Maven 的新手,但我可能缺少基本知识)。
  • 这是你可以做的。从标准的 java-maven 项目开始,然后将其转换为使用您的文件夹结构。至少这样你就可以对这个问题进行三角测量。
猜你喜欢
  • 1970-01-01
  • 2014-10-15
  • 1970-01-01
  • 1970-01-01
  • 2016-11-18
  • 2017-05-24
  • 2015-03-05
  • 2019-03-03
  • 1970-01-01
相关资源
最近更新 更多