Mosher's Law of Software Engineering
Don't worry if it doesn't work right. If everything did, you'd be out of a job.
build
logging
https://scans.gradle.com/s/g5imwm7fcw44u
automation
task
tool
build-gradle-prerequisite-jdk
build-gradle-customizable at runtime/compile time-
Gradle-wrapper
구조
├── gradle
│ └── wrapper
│ ├── gradle-wrapper.jar // 그레이들 래퍼 jar
│ └── gradle-wrapper.properties // 그레이들 래퍼 버전 및 실행환경 기록
├── gradlew // Unix 계열에서 실행가능한 스크립트
└── gradlew.bat // 윈도우에서 실행가능한 스크립트
gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Ant
Maven
Gradle
이걸 왜 신경써야해 복잡한데 ㅠㅠ ?
--> compile, runtime에 따른 중복 클래스 사용을 피하고, 명확히 명시되어 깔끔하고, 필요한 classPath에만 의존성 lib를 넣어서 더 빠르다.
plugins { // Apply app. plugin to add support for building app. in JAVA
id 'application'
}
// =================================
repositories {
mavenCentral() // use mavenCentral to resolve dependencies
// Declare Multiple repositories
maven {
url "https://repo.spring.io/release"
}
maven {
url "https://repository.jboss.org/maven2"
}
// stored dependencies in shared drive, part of project source code
flatDir {
dirs 'lib1', 'lib2'
}
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.2' // use junit for testing
implementation 'com.google.guava:guava:31.0.1-jre' // dependency used by the applicaiton
}
// =================================
application {
mainClass = 'demo.App' // define main class for app
}
// =================================
// TASKS
tasks.named('test') {
useJUnitPlatform()
}
// gradle installDist
tasks.register('createDocs') {
def docs = layout.buildDirectory.dir('docs')
outputs.dir docs
doLast {
docs.get().asFile.mkdirs()
docs.get().file('readme.txt').asFile.write('Read me!')
}
}
// customizable start script
task createStartScripts(type: CreateStartScripts) {
outputDir = file('build/sample')
mainClass = 'org.gradle.test.Main'
applicationName = 'myApp'
classpath = files('path/to/some.jar')
}
// =================================
distributions {
main {
contents {
from(createDocs) {
into 'docs'
}
}
}
}
https://medium.com/@257ramanrb/ant-vs-maven-vs-gradle-cd8ab4c2735f
https://www.baeldung.com/ant-maven-gradle
https://techblog.woowahan.com/2625/
https://tomgregory.com/gradle-implementation-vs-compile-dependencies/
https://techblog.bozho.net/runtime-classpath-vs-compile-time-classpath/
http://www.natpryce.com/articles/000749.html