-
-
Save mishin/d35c8b2d3c228b0b4a8db154c7e01e31 to your computer and use it in GitHub Desktop.
Build Gradle script that generates jar file with manifest classpath pointing to dependencies in subfolder /lib. (gradle, groovy, kotlin, spring)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plugins { | |
id 'org.hidetake.ssh' version '2.9.0' | |
id 'org.jetbrains.kotlin.jvm' version '1.3.11' | |
id 'org.springframework.boot' version '2.1.2.RELEASE' | |
id 'io.spring.dependency-management' version "1.0.6.RELEASE" | |
} | |
group 'App Group' | |
version '1.0.0' | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
compile 'org.jetbrains.kotlin:kotlin-stdlib-jdk8' | |
compile "org.jetbrains.kotlin:kotlin-reflect:1.3.11" | |
compile 'org.springframework.boot:spring-boot-starter-web' | |
} | |
// Copy dependencies to 'lib' directory | |
task copyRuntimeLibs(type: Copy) { | |
into "$buildDir/libs/lib/" | |
from configurations.compile | |
} | |
// attach to assemble task | |
assemble.dependsOn copyRuntimeLibs | |
jar { | |
manifest { | |
attributes( | |
'Main-Class': 'ApplicationKt', | |
'Class-Path': configurations.compile.collect { 'lib/' + it.getName() }.join(' ') | |
) | |
} | |
} | |
compileKotlin { | |
kotlinOptions.jvmTarget = '1.8' | |
} | |
compileTestKotlin { | |
kotlinOptions.jvmTarget = '1.8' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment