Build automation involves scripting or automating the process of compiling computer source code into binary code.
- Build Automation이란
자동으로 source code를 binary code로 만드는 행위
이다.- build automation을 위해서 script 언어를 사용할 수 있다.
Ant, Maven, Gradle
주된 목적은 artifact를 생성하는 것
💡 `artifact란?`특정 시점에 만들어낸 개발 산출물
ex) jar 또는 war 파일
Ant
Maven
과 같은 이전 세대 빌드 도구의 단점을 보완하고 장점을 취합하여 만든 오픈소스로 공개된 빌드 도구pom.xml
에 필요한 라이브러리를 선언하면 자동으로 해당 프로젝트로 불러와 편리하다.Ant
와 Maven
이 가진 장점을 모아 만들었다. 의존성 관리를 위한 다양한 방법을 제공하고 빌드 스크립트를 XML 언어가 아닌 JVM에서 동작하는 스크립트 언어 ‘그루비’ 기반의 DSL(Domain Specific Language)를 사용한다.Gradle Wrapper
를 이용하면 Gradle이 설치되지 않은 시스템에서도 프로젝트를 빌드할 수 있다.pom.xml
을 Gradle 용으로 변환할 수도 있으며 Maven의 중앙 저장소도 지원하기 때문에 라이브러리를 모두 그대로 가져다 사용할 수 있다.The Wrapper is a script that invokes a declared version of Gradle, downloading it beforehand if necessary. As a result, developers can get up and running with a Gradle project quickly without having to follow manual installation processes saving your company time and money.
- 한 마디로 gradle이 깔리지 않은 상태에서 주어진 gradle 프로젝트를 실행해주는 script 파일이다.
A Project Object Model or POM is the fundamental unit of work in Maven. It is an XML file that contains information about the project and configuration details used by Maven to build the project. It contains default values for most projects.
- code를 이용하여 project의 설정을 포함한 메타 정보를 담아둔 파일이다. 그리하여 build 시에 해당 파일이 사용된다.
task 태스크이름 {
... 작업들
}
task sayHello {
println 'Hello Taeng'
}
plugins {
id 'com.android.apllication'
id 'org.jetbrains.kotilin.android'
}
$ gradle tasks --all // 모든 Task 출력
Build tasks
-----------
app:assemble - Assemble main outputs for all the variants.
app:assembleAndroidTest - Assembles all the Test applications.
app:build - Assembles and tests this project.
app:buildDependents - Assembles and tests this project and all projects that depend on it.
app:buildNeeded - Assembles and tests this project and all projects it depends on.
app:bundle - Assemble bundles for all the variants.
app:clean - Deletes the build directory.
...
Other tasks
-----------
app:analyzeDebugAndroidTestDependencies
app:analyzeDebugDependencies
app:analyzeDebugUnitTestDependencies
app:analyzeReleaseDependencies
app:analyzeReleaseUnitTestDependencies
app:assembleDebug - Assembles main output for variant debug
app:assembleDebugAndroidTest - Assembles main output for variant debugAndroidTest
app:assembleDebugUnitTest - Assembles main output for variant debugUnitTest
app:assembleRelease - Assembles main output for variant release
app:assembleReleaseUnitTest - Assembles main output for variant releaseUnitTest
..