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

Add to -classpath via dedicated configuration #40

Open
f4lco opened this issue Apr 30, 2021 · 3 comments
Open

Add to -classpath via dedicated configuration #40

f4lco opened this issue Apr 30, 2021 · 3 comments

Comments

@f4lco
Copy link

f4lco commented Apr 30, 2021

First of all, thank you for this plugin, it is well documented and very useful 🎉

I have a minor feature to add: is it possible to add to the -classpath argument via a dedicated configuration?

Let me expand: I tried to use a JAXB plugin and ran into the following problem, where the service loader complains that the requested plugin is not actually an instance of com.sun.tools.xjc.Plugin. The root cause are different classloaders for Plugin and the class that is supposed to be a subtype. The solution is that all plugin JARs must be on the list of -classpath (an argument XJC), and not on the regular classpath from java -cp. See also https://stackoverflow.com/a/28197814.

With the current plugin, one can only add to -classpath by adding dependencies to the compile classpath:

"jaxb"(argMap) {
"classpath" {
"pathelement"( "path" to classpathfiles.asPath)
}

resp.

@get:InputFiles
val classpathfiles : FileCollection by lazy {
val returnFiles = project.files()
// find files of original JASPER and Eclipse compiler
returnFiles.from(project.configurations.findByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME))
returnFiles
}

However, I would prefer not to add JAXB plugins to my implementation configuration (or to generally have the JAXB plugin and its dependencies on the compile classpath).

  • I would suggest to add a dedicated configuration for plugins, like jaxbPlugins, and use that in addition to compileClasspath.
  • Would you accept a PR for that?
@m-raab
Copy link
Contributor

m-raab commented Apr 30, 2021

It is not really visible in the documentation: "It is possible to overwrite the project dependency configuration 'jaxb', if you want use an other version of JAXB. The classpath of the xjc can be extended with a project configuration 'jaxb' and dependencies."
So it is possible to replace all necessary dependencies in the jaxb configuration. That is necessary for the tooling. The class path is necessary for the code generation self and is the xjc parameter -classpath.
Do you want a separate class path configuration for these files?

@m-raab
Copy link
Contributor

m-raab commented Apr 30, 2021

I think I understand your problem. I will check that in the next release.

@f4lco
Copy link
Author

f4lco commented May 4, 2021

Thank you very much @m-raab, looking forward to it. Actually, I saw the relevant documentation, but it does not address the problem, because the existing dependency configurations do not add to -classpath (maybe that is a bit clearer).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants