简体   繁体   English

将多模块Maven项目提交到SVN

[英]Commit multi-module maven project to SVN

I used Maven to create several projects in Eclipse, based on Maven archetypes, and ended up with this project structure (a parent project with multiple modules): 我使用Maven基于Maven原型在Eclipse中创建了几个项目,最后得到了这个项目结构(一个具有多个模块的父项目):

  • Parent project - pom.xml: 父项目-pom.xml:
<name>backoffice-root</name>    
<modules>
    <module>backoffice-web</module>
    <module>backoffice-ejb-core</module>
    <module>backoffice-ws</module>
    <module>backoffice-ear</module>
</modules>

Now I want to commit them to a SVN repository using Subclipse. 现在,我想使用Subclipse将它们提交到SVN存储库。

In my first approach, I added these projects to SVN in a flat hierarchy. 在第一种方法中,我将这些项目以统一的层次结构添加到SVN中。 The first project that I added was root, otherwise I'd get a warning saying that .svn folders in modules would be deleted: 我添加的第一个项目是root,否则我将得到一条警告,指出模块中的.svn文件夹将被删除:

backoffice-root    
backoffice-web
backoffice-ejb-core
backoffice-ws
backoffice-ear

If I try to commit after that I get an error "backoffice-root/backoffice-web is already under version control". 如果在此之后尝试提交,则会出现错误“ backoffice-root / backoffice-web已在版本控制下”。 I believe this happens because when I added the projects to SVN, a .svn folder was created inside each one of them, but I don't know how can I solve this problem without deleting these folders and losing the information contained within them. 我相信会发生这种情况,因为当我将项目添加到SVN时,在每个项目中都创建了一个.svn文件夹,但是我不知道如何在不删除这些文件夹并丢失其中包含的信息的情况下解决此问题。

So I tried a second approach: adding root to SVN and then all the others under root (mapping my Maven project structure to SVN repository), creating this structure in the repository: 因此,我尝试了第二种方法:将root添加到SVN,然后将所有其他添加到root(将我的Maven项目结构映射到SVN存储库),在存储库中创建以下结构:

backoffice-root    
    backoffice-web
    backoffice-ejb-core
    backoffice-ws
    backoffice-ear

But when I try to commit all of them, I get the same error of approach #1. 但是,当我尝试落实所有这些方法时,会遇到方法1的相同错误。

The only way that I get things to work is by just adding root to SVN and committing it (it commits all the modules since they are folders inside root). 使工作正常的唯一方法是将root添加到SVN并提交(由于所有模块都是root文件夹,因此它会提交所有模块)。 But I want to work on each project and commit them individually. 但是我想处理每个项目并分别提交它们。 Do I need to structure my Maven projects in a flat layout like explained in this post? 我需要我的构建Maven项目在平面布局像在解释这个帖子? How does one work this way with my original layout? 如何以这种方式处理我的原始布局?

I'm working with the same your layout and everythings work. 我正在使用相同的布局,一切正常。 My project's skeleton is the following: 我项目的框架如下:

parent
  -model
  -util
  -services
  -web

model,util,services and web are all modules to parent and are placed in parent directory. model,util,services和web都是父级的模块,并放置在父级目录中。 Then I committed the parent project (that contains all modules) and finally I checked out and importing (In eclipse File->Import->Maven->Existing Maven Project) all modules. 然后我提交了父项目(包含所有模块),最后我签出并导入了所有模块(在Eclipse File-> Import-> Maven-> Existing Maven Project中)。

Update1 UPDATE1

Try to describe the procedure along some screenshoot: 尝试通过一些屏幕快照来描述该过程:

Step1 I already committed the parent and all modules 步骤1我已经提交了父级和所有模块

在此处输入图片说明

After checkout you will wind the following situation: 结帐后,您将遇到以下情况:

在此处输入图片说明

where only the parent is linked with the svn. 其中只有父级与svn链接。 Now you have to do (File->Import->Maven->Existing Maven Project and selected all modules. Then automatically you will have all modules linked at the svn 现在,您需要执行(文件->导入-> Maven->现有Maven项目并选择所有模块。然后,您将自动在svn链接所有模块

在此处输入图片说明

Update2 UPDATE2

My parent definition is the following: 我的父母的定义如下:

<modules>
    <module>model</module>
    <module>util</module>
    <module>services</module>
    <module>vaadin-webapp</module>
</modules>

and each module has instead this configuration 每个模块都具有此配置

<parent>
    <groupId>myCompany</groupId>
    <artifactId>myProject</artifactId>
    <version>2.2.1-SNAPSHOT</version>
</parent>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM