반응형

1. buildscript
그래들(Gradle)에서 buildscript는 보통 별도의 외부 라이브러리를 가져와야 할 때 사용합니다. 즉, 심플한(외부 라이브러리가 필요 없는) 라이브 사용 시에는 별도로 작성할 필요가 없습니다. buildscript는 repository와 dependencies로 구성됩니다.

2. repository
그래들(Gradle)에서 repository란 build.gradle이 들어있는 프로젝트에서 사용하는 라이브러리의 위치를 지정합니다. 가장 흔하게 사용하는 것은 jcenter(), mavenCentral(), google() 등이 있습니다. 모두 인터넷에 있는 공개용 라이브러리 저장소입니다.

3. dependencies
repository에서 jcenter, mavenCentral, google등의 외부 라이브러리 레파지토리를 지정했다면 해당 레파지토리에서 찾을 라이브러리 명을 입력해야 합니다. dependencies에 바로 해당 라이브러리명을 입력합니다.

4. simple example

buildscript {  
    repositories {  
        jcenter()   // 인터넷의 jcenter 레파지토리 사용  (https://bintray.com/bintray/jcenter)
    }  
    dependencies {  
        classpath group:'org.akhikhl.gretty', name:'gretty-plugin', version:'+'   // '그룹 : 이름 : 버전' 순으로 작성
    }  
}  

repositories {  
    jcenter()   // 기본 레파지토리
}  

dependencies {  
    testCompile group:'junit', name:'junit', version:'4.12'  

예를 보면 greety-plugin을 사용하기 위해 인터넷의 jcenter로부터 라이브러리를 찾아 가져오고 있습니다.

반응형

+ Recent posts