Difference between revisions of "Maven Project 생성"
Jump to navigation
Jump to search
(7 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
=== Karel을 위한 프로젝트 생성 === | |||
아래 그림과 같이 새로운 프로젝트를 생성한다. | |||
<gallery> | |||
file:maven-01.png | 1. 새로운 프로젝트를 생성한다. 탐색기 MAVEN에서 +를 누른 후 maven-archetype-quickstart 선택 | |||
file:maven-02.png | 2. 1.4 선택 | |||
file:maven-03.png | 3. 생성할 예제의 package 명을 입력한다. 그림에서는 <code>hufs.ice.cp</code>를 입력 | |||
file:maven-04.png | 4. artifact id 입력. 예제에서는 <code>example</code>을 입력 | |||
file:maven-05.png | 5. 프로젝트 폴더를 선택함. 기존에 연습중이던 프로젝트의 폴더를 선택하거나 새로운 폴더를 선택함 | |||
file:maven-06.png | 6. 터미널 창에서 생성하는 프로젝트의 버전을 지정하는데, <code>1.0</code>을 입력하고 다음 질문에는 <code>Y</code>를 선택한다. | |||
file:maven-07.png | 7. 프로젝트를 기존 Workspace에 추가할 지 묻는다. <code>Add to Workspace</code>를 선택하여 기존 Workspace에 추가한다. | |||
file:maven-08.png | 8. 추가한 모습. 정상적으로 보이지 않으면 vscode를 다시 실행한다. | |||
file:maven-09.png | 9. pom.xml 파일에서 Jave 버전은 <code>1.6</code>으로 변경한다. 그렇게 해야 Karel이 동작한다. | |||
</gallery> | |||
=== pom.xml에 Karel 라이브러리 추가 === | |||
Maven에서 프로젝트에 대한 명세가 pom.xml에 기술되어 있다. 여기에서 필요한 항목을 추가하도록 한다. | |||
* 먼저 Java 1.6으로 컴파일, 실행을 해야 한다. 이것은 아래 명세에서 다음을 변경한다. | |||
<syntaxhighlight lang="xml"> | |||
<maven.compiler.source>1.6</maven.compiler.source> | |||
<maven.compiler.target>1.6</maven.compiler.target> | |||
</syntaxhighlight> | |||
* 두 번째로 Karel.jar와 Hufs-karel.jar를 다운로드 받는다. 그리고 방금 만든 프로젝트 폴더에 <code>lib</code> 폴더를 생성한 후, 이 폴더에 다운로드 받은 두 개의 jar 파일을 이 폴더에 저장한다. | |||
* 세 번째로 Stanford Karel 라이브러리를 프로젝트에서 사용할 수 있도록 추가한다. dependencies 엘리먼트에 다음을 추가한다. 여기서 groupId와 artifactId는 적당한 이름으로 저장하도록 한다. version도 1.0으로 적절하게 지정한다. systemPath에서 project.basedir은 프로젝트가 있는 최상위 폴더를 뜻한다. | |||
<syntaxhighlight lang="xml"> | |||
<dependency> | |||
<groupId>karel</groupId> | |||
<artifactId>stanford</artifactId> | |||
<version>1.0</version> | |||
<scope>system</scope> | |||
<systemPath>${basedir}/lib/Karel.jar</systemPath> | |||
</dependency> | |||
</syntaxhighlight> | |||
* 마지막으로 Hufs Karel 라이브러리를 다음과 같이 추가한다. | |||
<syntaxhighlight lang="xml"> | |||
<dependency> | |||
<groupId>karel</groupId> | |||
<artifactId>hufs</artifactId> | |||
<version>1.0</version> | |||
<scope>system</scope> | |||
<systemPath>${basedir}/lib/Hufs-karel.jar</systemPath> | |||
</dependency> | |||
</syntaxhighlight> | |||
=== pom.xml에서 수정하는 부분 === | |||
<syntaxhighlight lang="xml"> | <syntaxhighlight lang="xml"> | ||
... | ... | ||
Line 27: | Line 65: | ||
</dependency> | </dependency> | ||
<dependency> | <dependency> | ||
<groupId> | <groupId>karel</groupId> | ||
<artifactId> | <artifactId>stanford</artifactId> | ||
<version>1.0</version> | <version>1.0</version> | ||
<scope>system</scope> | <scope>system</scope> | ||
<systemPath>${ | <systemPath>${basedir}/lib/Karel.jar</systemPath> | ||
</dependency> | </dependency> | ||
<dependency> | |||
<groupId> | <groupId>karel</groupId> | ||
<artifactId> | <artifactId>hufs</artifactId> | ||
<version>1.0</version> | <version>1.0</version> | ||
<scope>system</scope> | <scope>system</scope> | ||
<systemPath>${ | <systemPath>${basedir}/lib/Hufs-karel.jar</systemPath> | ||
</dependency> | </dependency> | ||
</dependencies> | </dependencies> |
Latest revision as of 03:21, 4 November 2022
Karel을 위한 프로젝트 생성
아래 그림과 같이 새로운 프로젝트를 생성한다.
pom.xml에 Karel 라이브러리 추가
Maven에서 프로젝트에 대한 명세가 pom.xml에 기술되어 있다. 여기에서 필요한 항목을 추가하도록 한다.
- 먼저 Java 1.6으로 컴파일, 실행을 해야 한다. 이것은 아래 명세에서 다음을 변경한다.
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
- 두 번째로 Karel.jar와 Hufs-karel.jar를 다운로드 받는다. 그리고 방금 만든 프로젝트 폴더에
lib
폴더를 생성한 후, 이 폴더에 다운로드 받은 두 개의 jar 파일을 이 폴더에 저장한다.
- 세 번째로 Stanford Karel 라이브러리를 프로젝트에서 사용할 수 있도록 추가한다. dependencies 엘리먼트에 다음을 추가한다. 여기서 groupId와 artifactId는 적당한 이름으로 저장하도록 한다. version도 1.0으로 적절하게 지정한다. systemPath에서 project.basedir은 프로젝트가 있는 최상위 폴더를 뜻한다.
<dependency>
<groupId>karel</groupId>
<artifactId>stanford</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/lib/Karel.jar</systemPath>
</dependency>
- 마지막으로 Hufs Karel 라이브러리를 다음과 같이 추가한다.
<dependency>
<groupId>karel</groupId>
<artifactId>hufs</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/lib/Hufs-karel.jar</systemPath>
</dependency>
pom.xml에서 수정하는 부분
...
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>karel</groupId>
<artifactId>stanford</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/lib/Karel.jar</systemPath>
</dependency>
<dependency>
<groupId>karel</groupId>
<artifactId>hufs</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/lib/Hufs-karel.jar</systemPath>
</dependency>
</dependencies>
...