2016년 8월 4일 목요일

Including resources to jar

You can include resource files to jar or war file like as below.

- Structure










- build.gradle

apply plugin: 'java'
apply plugin: 'spring-boot'

repositories {
    maven { url "http://repo1.maven.org/maven2" }
}

dependencies {
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator'
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-web'
}

buildscript {
    repositories {
        maven { url "http://repo1.maven.org/maven2" }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.0.RELEASE")
    }
}

// Including resources
sourceSets.main.resources.srcDirs = ["src/main/resources"]
sourceSets.main.resources.includes = ["**/*.txt", "application.properties", "application-${env}.properties"]


- Execution result

gradle build -Penv=local


댓글 없음 :

댓글 쓰기