반응형

(gradle로 hello world 띄우기)

 

Gradle 설치

1. 설치는 공홈에서.

https://gradle.org/install/

홈페이지에서 들어간 후, release 페이지 진입

 

여기서 알맞은 버전의 complete 을 클릭하며 다운로드

2. 환경변수 설정

In File Explorer right-click on the This PC (or Computer) icon, then click Properties -> Advanced System Settings -> Environmental Variables.

 

PATH에 아래의 경로 추가.

C:\Gradle\gradle-7.2-all\gradle-7.2\bin

 

2. hello world

https://araikuma.tistory.com/461

 

3. 문법

3-1. gradle task 만들어서 실행하기

https://kotlinworld.com/313

 

(만약 groovy로 만들었다면, 아래와 같이 작성한다.)

task firstTask {

    println "first task"

}

실행

$ gradle firstTask

 

 

3-2. 변수문법/테스크 간 의존성 설정.

https://coding-start.tistory.com/305

 

Extra properties

https://docs.gradle.org/current/userguide/writing_build_scripts.html

 

 

https://threeidiotscoding.tistory.com/40

딜레이 주는 방법.

로그 (콘솔 로그) 출력

https://docs.gradle.org/current/userguide/logging.html

task my_task(type: JacocoReport, dependsOn: ['testDebugUnitTest']) {
    logger.info('An info log message.')
}

 

예시 코드

File: build.gradle

ext {
    my_global = "1.2.0"
    my_time = "00:30"
}

// 세미콜론 안찍어도됨.
task firstTask {
    var num = 1
    ext.a = 2
    println num
    println "THE NUMBER: " + num + " #### "
    println a
    println "-------------------"
    println "MY GLOBAL: " + my_global
    println "MY TIME: " + my_time
}

출력화면:

> gradle firstTask

> Configure project :
1
THE NUMBER: 1 ####
2
-------------------
MY GLOBAL: 1.2.0
MY TIME: 00:30


BUILD SUCCESSFUL in 2s

 

 

 

반응형