본문 바로가기

Study/Java

eclipse workspace 위치에 git directory를 바로 clone하여 사용하지 말 것

반응형

eclipse를 계속 사용하다 보면 버전이 바뀌면서 workspace의 변경 처리를 하여 이전 버전의 eclipse와 호환이 되지 않는 경우도 있고 동일한 git 소스를 브런치 별로 따로 개발을 하기 위해 여러 벌 받아 사용하는 경우가 있게 된다.

이런 경우 편하게 사용하기 위해 workspace 별로 해당 directory 내에 git 소스를 받아 그대로 import 하여 사용하였다.

웬만한 경우 문제가 되지 않지만 spring-boot와 같이 프로젝트 이름과 동일한 이름의 artifactId가 존재하는 경우 문제가 발생한다.

Project at 'C:\Users\bluesky\Documents\workspace-opensource\spring-boot' can't be named 'spring-boot-build' because it's located directly under the workspace root. If such a project is renamed, Eclipse would move the container directory. 
To resolve this problem, move the project out of the workspace root or configure it to have the name 'spring-boot'.

예를 들어 해당 workspace내에 spring-boot directory로 git을 clone 받은 경우 spring-boot라는 이름의 폴더가 만들어지고 최상위 pom의 artifactId는 spring-boot-build이다.

https://github.com/spring-projects/spring-boot

하지만 eclipse에서 workspace 내 directory를 바로 import를 하면 spring-boot의 프로젝트 이름은 directory이름 그대로 사용하여 spring-boot가 되고 해당 이름이 '.project' 파일에 설정된다.

그리고 해당 이름으로 최상위 pom이 import 된다. (원래 설정된 artifactId로 만들어지지 않는다.)

즉 최상위인 spring-boot-build pom은 spring-boot라는 이름으로 import가 된다.

(git 소스 directory의 최상위 위치에 pom.xml 이 존재하는 경우 해당 문제가 발생한다.)

그렇기 때문에 하위 모듈로 존재하는 spring-boot 모듈과 이름이 충돌 나게 된다.

따라서 git의 소스와 workspace의 directory를 혼용해서 사용하는 경우 이런 문제가 발생할 수 있기 때문에 되도록 이런 식으로는 사용하지 말아야 한다.

반응형