Tuesday, June 16, 2020

Build a fat jar for Spring boot to include classes under 'test' in gradle

       

plugins {
     id 'org.springframework.boot' version '2.2.2.RELEASE'
     id 'io.spring.dependency-management' version '1.0.8.RELEASE'
     id 'java'
     id "com.palantir.docker" version "0.22.1"
     id "com.gorylenko.gradle-git-properties" version "1.5.1"   // auto generate git.properties and visible at /actuator/info
     id 'com.github.johnrengelman.shadow' version '6.0.0'
}


shadowJar {
    mergeServiceFiles()

    manifest {
        attributes 'Main-Class': 'com.company.product.cloud.packageName.TestClassName'
    }
    from sourceSets.test.output.classesDirs
}



Build:

./gradlew :project-name:shadowJar



Run:

java -cp ./project-name/build/libs/* com.company.product.cloud.packageName.TestClassName

No comments:

Post a Comment