Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- angularjs
- Ajax
- swift
- jquery
- Eclipse
- JavaFX
- maven
- WebClient
- bootstrap
- SQL
- Apache
- node.js
- SQLite
- build tool
- javadoc
- mybatis
- 일본
- spring boot
- gradle
- webflux
- xml
- Spring
- 개발자 이야기
- Linux
- pdo
- Python
- 외국인 노동자
- Java
- RSocket
- php
- Today
- 123
- Total
- 3,697,220
슬기로운 개발자 생활
[Gradle] Java 프로젝트 생성(퀵가이드) 본문
반응형
개발 환경
- Java : 1.8
- Gradle : 4.1
Gradle 프로젝트를 생성한다.
디렉토리 gradle-hello-world
를 생성하고, Gradle 프로젝트를 초기화한다.
$ mkdir gradle-hello-world
$ cd gradle-hello-world/
$ gradle init
BUILD SUCCESSFUL in 1s
2 actionable tasks: 2 executed
소스 코드를 작성한다.
소스 코드 디렉토리를 생성한다.
$ mkdir -p src/main/java/hello
소스 코드 src/main/java/hello/HelloWorld.java
를 작성한다.
package hello;
public class HelloWorld {
public static void main(String[] args) {
System.out.println("hello world!");
}
}
Gradle로 빌드한다.
빌드를 위해 build.gradle
에 아래 내용을 추가한다.
apply plugin: 'java'
NOTE : 모든 빌드에 대한 내용은 build.gradle
에 기입된다.
빌드 명령어 gradle build
로 빌드을 하면 build 디렉토리를 생성하고, 소스 코드 빌드를 진행하게 된다.
$ gradle build
BUILD SUCCESSFUL in 2s
2 actionable tasks: 2 executed
Gradle 프로젝트를 gradlew으로 실행하기
build.gradle
파일에 아래 내용을 추가하면 어플리케이션을 직접 구동할 수 있다.
apply plugin: 'application'
mainClassName = 'hello.HelloWorld'
구동 명령어 gradlew run
로 어플리케이션을 직접 구동해 본다.
$ ./gradlew run
> Task :run
hello world!
BUILD SUCCESSFUL in 2s
2 actionable tasks: 1 executed, 1 up-to-date
디렉토리 구조
생성된 디렉토리를 확인하기 위해 tree를 입력한다.
$ tree
.
├── build.gradle
├── gradle
│ └── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
└── src
└── main
└── java
└── hello
└── HelloWorld.java
소스 코드
참조
반응형
'IT 개발 > Gradle' 카테고리의 다른 글
[Gradle] DefaultTask 클래스 사용 (0) | 2017.12.23 |
---|---|
[Gradle] 테스크 생성 (2) | 2017.12.23 |
[Gradle] build.gradle 기본 (0) | 2017.12.23 |
[Gradle] Gradle 프로젝트 생성 (0) | 2017.12.23 |
[Gradle] Gradle 준비 (0) | 2017.12.23 |
- Tag
- build tool, gradlew
0 Comments