如何在Maven中正确包含Java源代码? [英] How to properly include Java sources in Maven?

查看:187
本文介绍了如何在Maven中正确包含Java源代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

技术:Spring IoC,Hibernate,jUnit,GWT和Maven 。

我创建了两个Maven项目:一个核心项目和一个GWT项目(在核心项目中有一个参考)

代码可通过 https://github.com/LaurentT/BlogEngineCore 进行访问



我的目标如下:我想包含Java源代码和XML,因为我的GWT项目需要Java源代码将其编译为JavaScript。



我尝试在< build> 元素中使用以下代码:

 < resources> 
< resource>
<目录> src / main / java< / directory>
<包括>
< include> ** / *。java< / include>
< / includes>
< / resource>
< resource>
<目录> src / main / resources< /目录>
<包括>
< include> ** / *。* xml< / include>
< include> ** / *。*属性< / include>
< / includes>
< / resource>
< /资源>

我的jUnit测试用于在添加之前传递并完成,但现在它们甚至没有完成它们挂起...

我不知道发生了什么,所以我想知道是否有其他方法来包含Java源代码,或者如果我只是做错了。



任何线索?

解决方案

尝试包括$ {basedir}

< resource>
< directory> $ {basedir} / src / main / java< / directory>
< / resource>


I'm working on a very simple blog engine in Java in order to learn multiple technologies.

Tech: Spring IoC, Hibernate, jUnit, GWT, and Maven.

I created two Maven projects: a core project and a GWT project (which has a reference on the core one)

Code is accessible at https://github.com/LaurentT/BlogEngineCore

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>

My jUnit tests used to pass and finish before that add but now they are not even finishing they are hanging...

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.

Any clue?

解决方案

try including the ${basedir} in front of the directory path.

<resource>
    <directory>${basedir}/src/main/java</directory>
</resource>

这篇关于如何在Maven中正确包含Java源代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆