I am trying to load some external jars in gradle undertow project using spring-boot-loader version 2.3.4.RELEASE by passing
-Dloader.path=/path/jar1.jar,path2/jar2.jar...etc

In my build.gradle file,

compile group: 'org.springframework.boot', name: 'spring-boot-loader', version: '2.3.4.RELEASE' and plugin - apply plugin: 'org.springframework.boot'

It used to work with version 1.3.8.RELEASE, after upgrading to 1.4.0.RELEASE(even tried with latest 2.3.4.RELEASE) it started failing, throwing java.lang.NoClassDefFoundError for the classes available in /path/jar1.jar.


jar {
  manifest {
    attributes "Start-Class": "com.main.Application"
    attributes "Main-Class": "org.springframework.boot.loader.PropertiesLauncher"
  }
  from {
    configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
  }
}

Please suggest, What I am missing ?

Comment From: wilkinsona

It looks like you are customising the wrong task. I suspect you want to customise the bootJar task rather than the jar task.

If you have any further questions, please follow up on Stack Overflow or Gitter. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements.

If you believe that you have found a bug, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue. We can then re-open this issue and take another look.

Comment From: shrimank

It looks like you are customising the wrong task. I suspect you want to customise the bootJar task rather than the jar task.

If you have any further questions, please follow up on Stack Overflow or Gitter. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements.

If you believe that you have found a bug, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue. We can then re-open this issue and take another look.

Thank you, It worked 👍