본문 바로가기

Development/Maven

IDE에서 Maven 프로젝트 생성.

프로젝트의 일관성을 가지기 위해서 Maven을 도입했다.
그런데 문제는 프로젝트 생성.

Maven은 Eclipse, IDEA, Net Beans를 공식적으로 지원한다.
하지만 프로젝트를 생성해도 java 디렉토리는 자동으로 생성해주지 않는다. 수동으로 생성해야 하는데 문제는 IDE에서 프로젝트가 열려있는 상태에서 java 디렉토리를 생성하면 IDE가 그게 소스디렉토리인지 인식하지 못한다. 그래서 class 생성메뉴같은것이 열리지 않고 일반 파일종류만 생성할 수 있다.
프로젝트를 삭제하고 다시 import 하면 소스디렉토리로 정상적으로 인식한다.
IntelliJ IDEA에서는 일반디렉토리는 노란색, 소스디렉토리는 파란색으로 구별할 수 있다.

원래 정상적인 방법은 command 창에서 수동으로 생성해주는 방법이다.
예를 들면 웹프로젝트 같은 경우는,

#mvn archetype:create -DgroupId=com.prompt -DartifactId=test02 -DarchetypeArtifactId=maven-archetype-webapp


위의 명령어로 프로젝트를 생성한다. 생성하고 난뒤 java 소스디렉토리를 다시 수동으로 생성해준다.

mvn archetype:generate 명령어로 프로젝트를 생성하면서 18번을 실행한다.
무슨말인고 하니, command 창에서 mvn archetype:generate 명령어를 실행해보면

E:\IdeaProjects>mvn archetype:generate
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO]    task-segment: [archetype:generate] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] Preparing archetype:generate
[INFO] No goals needed for project - skipping
[INFO] Setting property: classpath.resource.loader.class => 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'.
[INFO] Setting property: velocimacro.messages.on => 'false'.
[INFO] Setting property: resource.loader => 'classpath'.
[INFO] Setting property: resource.manager.logwhenfound => 'false'.
[INFO] [archetype:generate]
[INFO] Generating project in Interactive mode
[INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0)
Choose archetype:
1: internal -> appfuse-basic-jsf (AppFuse archetype for creating a web application with Hibernate, Spring and JSF)
2: internal -> appfuse-basic-spring (AppFuse archetype for creating a web application with Hibernate, Spring and Spring MVC)
3: internal -> appfuse-basic-struts (AppFuse archetype for creating a web application with Hibernate, Spring and Struts 2)
4: internal -> appfuse-basic-tapestry (AppFuse archetype for creating a web application with Hibernate, Spring and Tapestry 4)
5: internal -> appfuse-core (AppFuse archetype for creating a jar application with Hibernate and Spring and XFire)
6: internal -> appfuse-modular-jsf (AppFuse archetype for creating a modular application with Hibernate, Spring and JSF)
7: internal -> appfuse-modular-spring (AppFuse archetype for creating a modular application with Hibernate, Spring and Spring MVC)
8: internal -> appfuse-modular-struts (AppFuse archetype for creating a modular application with Hibernate, Spring and Struts 2)
9: internal -> appfuse-modular-tapestry (AppFuse archetype for creating a modular application with Hibernate, Spring and Tapestry 4)
10: internal -> maven-archetype-j2ee-simple (A simple J2EE Java application)
11: internal -> maven-archetype-marmalade-mojo (A Maven plugin development project using marmalade)
12: internal -> maven-archetype-mojo (A Maven Java plugin development project)
13: internal -> maven-archetype-portlet (A simple portlet application)
14: internal -> maven-archetype-profiles ()
15: internal -> maven-archetype-quickstart ()
16: internal -> maven-archetype-site-simple (A simple site generation project)
17: internal -> maven-archetype-site (A more complex site project)
18: internal -> maven-archetype-webapp (A simple Java web application)
19: internal -> jini-service-archetype (Archetype for Jini service project creation)
20: internal -> softeu-archetype-seam (JSF+Facelets+Seam Archetype)
21: internal -> softeu-archetype-seam-simple (JSF+Facelets+Seam (no persistence) Archetype)
22: internal -> softeu-archetype-jsf (JSF+Facelets Archetype)
23: internal -> jpa-maven-archetype (JPA application)
24: internal -> spring-osgi-bundle-archetype (Spring-OSGi archetype)
25: internal -> confluence-plugin-archetype (Atlassian Confluence plugin archetype)
26: internal -> jira-plugin-archetype (Atlassian JIRA plugin archetype)
27: internal -> maven-archetype-har (Hibernate Archive)
28: internal -> maven-archetype-sar (JBoss Service Archive)
29: internal -> wicket-archetype-quickstart (A simple Apache Wicket project)
30: internal -> scala-archetype-simple (A simple scala project)
31: internal -> lift-archetype-blank (A blank/empty liftweb project)
32: internal -> lift-archetype-basic (The basic (liftweb) project)
33: internal -> cocoon-22-archetype-block-plain ([http://cocoon.apache.org/2.2/maven-plugins/])
34: internal -> cocoon-22-archetype-block ([http://cocoon.apache.org/2.2/maven-plugins/])
35: internal -> cocoon-22-archetype-webapp ([http://cocoon.apache.org/2.2/maven-plugins/])
36: internal -> myfaces-archetype-helloworld (A simple archetype using MyFaces)
37: internal -> myfaces-archetype-helloworld-facelets (A simple archetype using MyFaces and facelets)
38: internal -> myfaces-archetype-trinidad (A simple archetype using Myfaces and Trinidad)
39: internal -> myfaces-archetype-jsfcomponents (A simple archetype for create custom JSF components using MyFaces)
40: internal -> gmaven-archetype-basic (Groovy basic archetype)
41: internal -> gmaven-archetype-mojo (Groovy mojo archetype)
Choose a number:  (1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/16/17/18/19/20/21/22/23/24/25/26/27/28/29/30/31/32/33/34/35/36/37/38/39/40/41) 15: :


위와 같이 메뉴들이 나오면서 그중에서 선택하는데 웹프로젝트 같은 경우는 18번 메뉴이다.
플러그인이 이 명령어를 실행하면서 약간 문제를 일으킨다.

최고 좋은 방법은 command 창에서 수동으로 정석대로 생성하기.
그보다 더 편한 방법은 이미 있는 Maven 프로젝트를 가져와서 pom.xml 파일만 수정해서 사용하기.

아..삽질 많이 했다. IDE에서 소스파일로 인식시켜줄라고....



'Development > Maven' 카테고리의 다른 글

맥에 maven 설치하기.  (0) 2013.11.06
로컬 레파지토리 설정하기.  (0) 2011.09.20
Eclipse 에 Maven Plugin 설치하기.  (0) 2010.02.25
Eclipse에 Maven 설정하기  (0) 2009.01.02