如何在 Maven 中正确包含 Java 源代码? [英] How to properly include Java sources in Maven?
问题描述
我正在用 Java 开发一个非常简单的博客引擎,以便学习多种技术.
I'm working on a very simple blog engine in Java in order to learn multiple technologies.
技术:Spring IoC、Hibernate、jUnit、GWT 和 Maven.
Tech: Spring IoC, Hibernate, jUnit, GWT, and Maven.
我创建了两个 Maven 项目:一个核心项目和一个 GWT 项目(其中有一个核心项目的引用)
I created two Maven projects: a core project and a GWT project (which has a reference on the core one)
代码可在 https://github.com/LaurentT/BlogEngineCore
我的目标如下:我想包含 Java 源代码和 XML,因为我的 GWT 项目将需要 Java 源代码将其编译为 JavaScript.
My goal is the following: I want to include Java sources and XML since my GWT project is going to need the Java sources to compile it into JavaScript.
我尝试在
元素中使用以下代码:
I tried to use the following code in the <build>
element:
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.java</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.*xml</include>
<include>**/*.*properties</include>
</includes>
</resource>
</resources>
我的 jUnit 测试曾经在添加之前通过并完成,但现在它们甚至还没有完成,它们正在挂起......
My jUnit tests used to pass and finish before that add but now they are not even finishing they are hanging...
我不知道发生了什么,所以我想知道是否有其他方法可以包含 Java 源代码,或者我是否只是做错了.
I have no clue what's going on, so I want to know if there are other ways to include Java sources or if I'm just doing it wrong.
有什么线索吗?
推荐答案
尝试在目录路径前包含 ${basedir}.
try including the ${basedir} in front of the directory path.
<resource>
<directory>${basedir}/src/main/java</directory>
</resource>
这篇关于如何在 Maven 中正确包含 Java 源代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!