How to use Mercurial, Maven and Eclipse together?

I am currently working on a Java project in a team of 5 colleagues for a university. In fact, we will complete the planning phase in the next few days, and then begin the implementation.

For the project, we must use Mercurial (via Bitbucket.org) and Apache Maven. We would like to use Eclipse as an IDE. I know how to use Mercurial, and I read several articles and tutorials about Maven. I do not understand how we should use these tools in collaboration.

What needs to be placed in storage? The whole Eclipse project? Or just the source files and Maven pom.xml? If the latter, what will the working session look like? Pull files, create an Eclipse project with mvn eclipse: eclipse, code a and copy / drag them to the repo?

I am responsible for creating the project structure, so my colleagues - and I too - can begin to develop. But I really don't know how to start now. If using Maven was not mandatory, I would just put the Eclipse project in the repository. But, having the opportunity to use it, I am now completely confused about how it affects everything.

+6
source share
2 answers

I use a similar setting, except that I use Dropbox for my repository (only two developers). Just follow these steps: m2eclipse (update site: http://m2eclipse.sonatype.org/sites/m2e ) and MercurialEclipse (update site: http://cbes.javaforge.com/update ), you can do everything in eclipse.

Create a maven project:

File → Create → Other → Maven Project

In Project explorer, right-click the new maven project

Team → Share Project ... → Mercurial → (leave the folder as is) Finish

Then create the .hgignore file in the project root:

In Project explorer, right-click the new maven project

New -> File -> File Name: .hgignore and Finish

.hgignore:

syntax: regexp target # maven output \.classpath # eclipse \.project # eclipse \.settings # eclipse test-output # eclipse junit/testng plugin output 

Then you can make your first commit, but be careful: hg does not store empty folders in the repository, therefore, to preserve the maven folder structure without source code, you need to put the (empty) file in each empty folder, for a simple maven project without any Or sources it will be in folders:

  • MyProject / SRC / Basic / Java
  • MyProject / SRC / main / resources
  • MyProject / SRC / Test / Java
  • MyProject / SRC / test / resources

For example, I put a file with the name. Empty into it with the contents "this is a placeholder file, delete if there are other files in this folder"

If some of these folders are missing, your colleagues will see errors in eclipse if they import your project.

First commit:

In Project explorer, right-click the new maven project

Command → Commit ... → Select all and enter a commit message → Done

Now you can clone it into a bitbucket (I have no experience with a bitbucket).

Tell your colleagues to install two eclipse plugins and then they can get the repo through

File -> Create -> Other -> Check Maven project from SCM -> enter your repo url -> Done

And then you are good to go.

+7
source

Here are alternatives based on ASF practices (although we don't use Mercurial).

To get started, configure the source tree using the Maven assembly, which you test on Hg. Do not touch the eclipse yet. You will want to find the Eclipse plugin for Hg.

Then consider two alternatives: maven-eclipse-plugin and M2eclipse .

The maven-eclipse plugin is the maven plugin. You start it from the command line and generate .project and .classpath and some of .settings. Currently, it is not processed, but it is quite stable and functional in many common cases. Then you import the "existing Eclipse project" and you are good to go.

M2Eclipse is an Eclipse plugin that integrates Maven assemblies. This is pretty ambitious. However, the current avatar is quite new and may be full of surprises.

+2
source

Source: https://habr.com/ru/post/885975/


All Articles