1

I'm struggling to create a repository for my Maven project in Eclipse. Whatever I try it turns out like so:

\ProjectA
----\.git
----\ProjectA
--------\src
--------\pom.xml

While I'd like it to be like so:

\ProjectA
----\.git
----\src
----\pom.xml

Is there any way for it to not create a separate folder under the working tree?

Rüdiger Herrmann
  • 20,512
  • 11
  • 62
  • 79
K. Kowalczyk
  • 967
  • 13
  • 34

2 Answers2

1

I'm not sure if it is the only or the best way, but creating empty repo from git directly then moving files and reimporting in Eclipse did the trick.

In case anyone needs this later:

In folder you want your repo in:

git init

Copy your sources and pom.xml and other needed files there (I also recommend creating .gitignore file at this point), then:

git add --all
git commit --m "Initial commit msg"

Then open Eclipse, delete your project and reimport it as existing Maven project directly from your repo. In my case it already recognized repo as well.

K. Kowalczyk
  • 967
  • 13
  • 34
0

From my understanding, you are trying to create a Git repository with a single Eclipse project, located at the root of the work directory.

  1. open the EGit Repositories view and select the Create a new Repository action
  2. enter the name of the directory in which the repository should be created and select Finish
  3. make sure that auto-sharing projects is enabled (enabled by default, in doubt, see Preferences > Team > Git > Projects)
  4. open the New Java Project and enter a project name
  5. uncheck Use default workspace location and enter the exact same path as the repository work directory (see 2.)
  6. go to the Package Explorer, select the new project, open the context menu and select Configure > Convert to Maven Project

The detour of creating a Java project first and then converting it into a Maven project seems necessary because the New Maven Project wizard apparently always adds the Group Id to the location path.

Community
  • 1
  • 1
Rüdiger Herrmann
  • 20,512
  • 11
  • 62
  • 79