Skip to content

Instantly share code, notes, and snippets.

@mishin
Forked from Maxlero/build.gradle
Created July 24, 2020 05:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mishin/d35c8b2d3c228b0b4a8db154c7e01e31 to your computer and use it in GitHub Desktop.
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)
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