Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic Extensions Gradle plugin fails with java.lang.NoClassDefFoundError: aQute/bnd/osgi/Builder #258

Closed
vierbergenlars opened this issue May 21, 2019 · 2 comments
Labels

Comments

@vierbergenlars
Copy link
Member

vierbergenlars commented May 21, 2019

Using the dynamic extensions gradle plugin fails while running the jar task with a NoClassDefFoundError for aQute.bnd.osgi.Builder.

I'm submitting a ... (check one with "x")

[x] bug report
[ ] feature request
[ ] question

Expected Behavior

Running the jar task creates a dynamic extensions jar.

Current Behavior

Running the jar task fails with an exception

> Task :jar FAILED
Caching disabled for task ':jar' because:
  Build cache is disabled
Task ':jar' is not up-to-date because:
  No history is available.
:jar (Thread[main,5,main]) completed. Took 0.043 secs.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':jar'.
> aQute/bnd/osgi/Builder
* Try:
Run with --debug option to get more log output. Run with --scan to get full insights.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':jar'.
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.accept(ExecuteActionsTaskExecuter.java:151)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.accept(ExecuteActionsTaskExecuter.java:148)
	at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:191)
[...]
Caused by: java.lang.NoClassDefFoundError: aQute/bnd/osgi/Builder
	at aQute.bnd.gradle.BundleTaskConvention$_buildBundle_closure5.doCall(BundleTaskConvention.groovy:199)
	at org.gradle.util.ClosureBackedAction.execute(ClosureBackedAction.java:70)
[...]
Caused by: java.lang.ClassNotFoundException: aQute.bnd.osgi.Builder
	... 172 more
* Get more help at https://help.gradle.org
BUILD FAILED in 2m 25s
3 actionable tasks: 3 executed
The command "./gradlew assemble -i --stacktrace" failed and exited with 1 during .

Steps to Reproduce (for bugs)

  1. Apply the eu.xenit.de gradle plugin (make sure the mavenCentral or jcenter repositories are not used for plugin resolution)
  2. Run ./gradlew assemble

Context

Building the example project fails on travis: https://travis-ci.org/xenit-eu/example-dynamic-extension/builds/535161122

Your Environment

  • Dynamic Extensions Gradle plugin version 2.0.0
@vierbergenlars
Copy link
Member Author

This issue is caused by a bug in the publish process of the bnd plugin that is used under the covers: bndtools/bnd#3174

You can work around it by adding this snippet to settings.gradle

pluginManagement {
    repositories {
        mavenCentral()
        gradlePluginPortal()
    }
}

Or by adding this snippet to your build.gradle

buildscript {
    repositories {
        mavenCentral()
    }
}

@vierbergenlars
Copy link
Member Author

To work around it from the plugin side, we can

  1. Add all the dependencies of the bnd gradle plugin to our compile dependencies. The dependencies will then be resolved and loaded from applying our plugin
  2. Use shadow to shade all dependencies into our plugin jar

kerkhofsd pushed a commit to xenit-eu/example-dynamic-extension that referenced this issue May 21, 2019
kerkhofsd added a commit that referenced this issue May 21, 2019
Add workaround for #258 by manually adding dependencies of bnd
kerkhofsd pushed a commit to xenit-eu/example-dynamic-extension that referenced this issue May 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant