How to add ressource folder with json with the shadowjar plugin in gradle

85 Views Asked by At

Here is my problem, my build gradle with shadowjar works well execept that the src/main/ressources is not added to the jar.

When i try to add include('src/main/ressources') it gives me a main class not found when launching the shadowjar task.

buildscript {
    repositories {
        mavenCentral()
        gradlePluginPortal()
    }
    dependencies {
        classpath "gradle.plugin.com.github.johnrengelman:shadow:7.1.2"
    }
}



apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'application'
apply plugin: 'com.github.johnrengelman.shadow'

// gradle 5.0+ compatibility
configurations.implementation.setCanBeResolved(true)
// gradle 9.0+ compatibility
// for replacing configurations.implementation.setCanBeResolved(true)
// resolve all dependencies at configuration time



// tag::repositories[]
repositories { 
    mavenCentral() 
}



application {
    // Define the main class for the application.
    mainClass = 'd20.App'
}

// end::repositories[]

// tag::dependencies[]
sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
    implementation "joda-time:joda-time:+"
    testImplementation "junit:junit:+"
    implementation 'com.google.code.gson:gson:+'

}



// tag::jar[]
jar {
    archiveBaseName = 'd20'
    archiveVersion =  '0.1.0'
    manifest {
    attributes(
      'Class-Path': configurations.implementation.collect { it.getName() }.join(' '),
      'Main-Class': 'd20.HelloWorld'
    )
  }
}


shadowJar {

   archiveBaseName.set('oldschooljava')



   archiveClassifier.set('')
   archiveVersion.set('')
      
}

// end::jar[]

// tag::dependencies[]
//sourceCompatibility = 1.8
//targetCompatibility = 1.8

//dependencies {
    //implementation "joda-time:joda-time:2.2"
    //testImplementation "junit:junit:4.12"
//}

How can i include the ressources folder in my jar with shadowjar ?

regards

0

There are 0 best solutions below