We have a fairly large group of Maven2 projects, with a root POM file listing 10+ modules and a lot of properties used by the modules (dependency version numbers, plugin configuration, common dependencies, etc). Some of the modules are, like the root project, parents to other sets of modules.
我们有一个相当大的Maven2项目组,其中一个根POM文件列出了10多个模块和模块使用的许多属性(依赖版本号,插件配置,公共依赖项等)。与根项目一样,某些模块是其他模块的父项。
To clarify, the root project and said parent projects are set to pom packaging (as opposed to e.g. jar).
为了澄清,根项目和所述父项目被设置为pom包装(而不是例如jar)。
Because there are many dependencies between the different projects, I like to use mvn eclipse:eclipse on the root project, which enables me to debug/step into any project at any time.
因为不同项目之间存在许多依赖关系,所以我喜欢在根项目中使用mvn eclipse:eclipse,这使我能够随时调试/步入任何项目。
However, with this approach, the root POM itself, and all other pom-packaged projects, are unavailable in Eclipse. So, if I want to edit them, I have to open them some other way. This is becoming a bit of a hassle.
但是,使用这种方法,根POM本身以及所有其他pom打包项目在Eclipse中都不可用。所以,如果我想编辑它们,我必须以其他方式打开它们。这变得有点麻烦。
So, my question is: is it possible to somehow make pom-packaged projects available in Eclipse? If not, do you have any tips that could make my work with these projects easier?
所以,我的问题是:是否有可能以某种方式在Eclipse中提供pom打包的项目?如果没有,您是否有任何提示可以使我对这些项目的工作更容易?
For the record, I'm currently using MyEclipse 7.0.
为了记录,我目前正在使用MyEclipse 7.0。
6 个解决方案
#1
2
I tried this again, with Galileo and the latest version of m2eclipse. It is now possible to import Maven projects directly (without mvn eclipse:eclipse), and it turns out that the root POM is also imported as a project, which is excactly what I wanted.
我用Galileo和m2eclipse的最新版本再试一次。现在可以直接导入Maven项目(没有mvn eclipse:eclipse),事实证明根POM也作为项目导入,这正是我想要的。
#2
1
Well. Lots of people do this by making the parent POM a sibling project, and having a simple reactor POM in the root. However this can cause problems with website generation and the release plugin, as neither supports this mode as fully as one might like.
好。很多人通过使父POM成为兄弟项目,并在根中拥有一个简单的反应器POM来做到这一点。但是,这可能会导致网站生成和发布插件出现问题,因为它们都不像人们所希望的那样完全支持此模式。
A big problem we often have is that people try to check out the trunk using Subclipse, which adds a .project file in the root, which then prevents importing projects below that level. Instead we have to go outside to check out, then import the projects.
我们经常遇到的一个大问题是人们试图使用Subclipse检查主干,它在根目录中添加了一个.project文件,然后阻止导入低于该级别的项目。相反,我们必须到外面检查,然后导入项目。
I have heard rumor that Subversive might handle nested projects better, which is really the problem here. Other than that, I don't have an absolute solution here.
我听说Subversive可能会更好地处理嵌套项目,这真的是问题所在。除此之外,我在这里没有绝对的解决方案。
#3
0
You could try writing a task to manually create the .project file for each POM project in it's directory. Not sure on the specifics, but you could generate something like:
您可以尝试编写任务以手动为其目录中的每个POM项目创建.project文件。不确定具体细节,但你可以生成类似的东西:
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>${project.name}</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>
in the project's root directory and it should be okay.
在项目的根目录中它应该没问题。
I'm not sure whether doing this would then block you from importing the children projects into eclipse though (as you probably know - you need to import all your non-pom projects first and then create "general" projects for the others, with the path matching the physical path under the mvn structure). Eclipse will stop you from creating a project inside another, so if it recognises anything from higher in the project hierarchy you'll get headed off at the past.
我不确定这样做是否会阻止你将子项目导入eclipse(你可能知道 - 你需要先导入所有非pom项目,然后为其他项目创建“一般”项目,路径匹配mvn结构下的物理路径)。 Eclipse将阻止您在另一个项目中创建项目,因此,如果它在项目层次结构中识别出更高的项目,那么您将会过去。
#4
0
I managed to work with codehaus eclipse plugin with maven projects having parents. The plugin has some flaws, but overall it is maintained and you should be able to get along with it.
我设法使用codehaus eclipse插件与父母的maven项目。该插件有一些缺陷,但总体来说它是维护的,你应该能够与它相处。
#5
0
Actually, if you don't want to depend on m2eclipse, the "right" way to do this is to use a flat project layout (as the problem is that Eclipse doesn't support nested projects).
实际上,如果你不想依赖m2eclipse,那么“正确”的方法是使用平面项目布局(因为问题是Eclipse不支持嵌套项目)。
#6
0
Generally I only really need the parent available in eclipse to add dependencies and to avail of the XML formatting. The cheap and cheerful way is to create resources project and link the parent pom into it. File -> New -> Other -> General -> File -> advanced
通常我只需要在eclipse中可用的父级来添加依赖项并利用XML格式。廉价而愉快的方式是创建资源项目并将父pom链接到其中。文件 - >新建 - >其他 - >常规 - >文件 - >高级
if you use the 2.8+ version of the eclipse plugin you can have it generate the link for you in each of your subprojects e.g.
如果您使用2.8以上版本的eclipse插件,您可以在每个子项目中为您生成链接,例如
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.8-SNAPSHOT</version>
<configuration>
<linkedResources>
<linkedResource>
<name>parent.xml</name>
<type>1</type>
<location>${basedir}/${parent.relativePath}</location>
</linkedResource>
</linkedResources>
</configuration>
</plugin>
Though you will currently need to check it out from subversion and build it yourself as it doesn't seem to resolve from central yet.
虽然你现在需要从subversion中检查它并自己构建它,因为它似乎无法从中心解析。
svn co http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-eclipse-plugin/
cd maven-eclipse-plugin
mvn clean install
#1
2
I tried this again, with Galileo and the latest version of m2eclipse. It is now possible to import Maven projects directly (without mvn eclipse:eclipse), and it turns out that the root POM is also imported as a project, which is excactly what I wanted.
我用Galileo和m2eclipse的最新版本再试一次。现在可以直接导入Maven项目(没有mvn eclipse:eclipse),事实证明根POM也作为项目导入,这正是我想要的。
#2
1
Well. Lots of people do this by making the parent POM a sibling project, and having a simple reactor POM in the root. However this can cause problems with website generation and the release plugin, as neither supports this mode as fully as one might like.
好。很多人通过使父POM成为兄弟项目,并在根中拥有一个简单的反应器POM来做到这一点。但是,这可能会导致网站生成和发布插件出现问题,因为它们都不像人们所希望的那样完全支持此模式。
A big problem we often have is that people try to check out the trunk using Subclipse, which adds a .project file in the root, which then prevents importing projects below that level. Instead we have to go outside to check out, then import the projects.
我们经常遇到的一个大问题是人们试图使用Subclipse检查主干,它在根目录中添加了一个.project文件,然后阻止导入低于该级别的项目。相反,我们必须到外面检查,然后导入项目。
I have heard rumor that Subversive might handle nested projects better, which is really the problem here. Other than that, I don't have an absolute solution here.
我听说Subversive可能会更好地处理嵌套项目,这真的是问题所在。除此之外,我在这里没有绝对的解决方案。
#3
0
You could try writing a task to manually create the .project file for each POM project in it's directory. Not sure on the specifics, but you could generate something like:
您可以尝试编写任务以手动为其目录中的每个POM项目创建.project文件。不确定具体细节,但你可以生成类似的东西:
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>${project.name}</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>
in the project's root directory and it should be okay.
在项目的根目录中它应该没问题。
I'm not sure whether doing this would then block you from importing the children projects into eclipse though (as you probably know - you need to import all your non-pom projects first and then create "general" projects for the others, with the path matching the physical path under the mvn structure). Eclipse will stop you from creating a project inside another, so if it recognises anything from higher in the project hierarchy you'll get headed off at the past.
我不确定这样做是否会阻止你将子项目导入eclipse(你可能知道 - 你需要先导入所有非pom项目,然后为其他项目创建“一般”项目,路径匹配mvn结构下的物理路径)。 Eclipse将阻止您在另一个项目中创建项目,因此,如果它在项目层次结构中识别出更高的项目,那么您将会过去。
#4
0
I managed to work with codehaus eclipse plugin with maven projects having parents. The plugin has some flaws, but overall it is maintained and you should be able to get along with it.
我设法使用codehaus eclipse插件与父母的maven项目。该插件有一些缺陷,但总体来说它是维护的,你应该能够与它相处。
#5
0
Actually, if you don't want to depend on m2eclipse, the "right" way to do this is to use a flat project layout (as the problem is that Eclipse doesn't support nested projects).
实际上,如果你不想依赖m2eclipse,那么“正确”的方法是使用平面项目布局(因为问题是Eclipse不支持嵌套项目)。
#6
0
Generally I only really need the parent available in eclipse to add dependencies and to avail of the XML formatting. The cheap and cheerful way is to create resources project and link the parent pom into it. File -> New -> Other -> General -> File -> advanced
通常我只需要在eclipse中可用的父级来添加依赖项并利用XML格式。廉价而愉快的方式是创建资源项目并将父pom链接到其中。文件 - >新建 - >其他 - >常规 - >文件 - >高级
if you use the 2.8+ version of the eclipse plugin you can have it generate the link for you in each of your subprojects e.g.
如果您使用2.8以上版本的eclipse插件,您可以在每个子项目中为您生成链接,例如
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.8-SNAPSHOT</version>
<configuration>
<linkedResources>
<linkedResource>
<name>parent.xml</name>
<type>1</type>
<location>${basedir}/${parent.relativePath}</location>
</linkedResource>
</linkedResources>
</configuration>
</plugin>
Though you will currently need to check it out from subversion and build it yourself as it doesn't seem to resolve from central yet.
虽然你现在需要从subversion中检查它并自己构建它,因为它似乎无法从中心解析。
svn co http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-eclipse-plugin/
cd maven-eclipse-plugin
mvn clean install