FreeBuilder icon indicating copy to clipboard operation
FreeBuilder copied to clipboard

JPMS

Open xenoterracide opened this issue 2 years ago • 10 comments

please add a module-info or automatic module name so this can be used with java modules

/home/xeno/IdeaProjects/ai-wh40k/module/game/src/main/java/module-info.java:3: error: module not found: freebuilder
  requires freebuilder;

xenoterracide avatar Sep 11 '23 18:09 xenoterracide

PRs welcome

alicederyn avatar Sep 11 '23 20:09 alicederyn

Are you trying to maintain support for pre java 9?

xenoterracide avatar Sep 11 '23 20:09 xenoterracide

I'm not sure of the Java landscape these days. What does Android compatibility entail?

alicederyn avatar Sep 11 '23 21:09 alicederyn

I don't know what android's up to. Automatic module naming is backwards compatible for sure though.

xenoterracide avatar Sep 12 '23 16:09 xenoterracide

I believe recent-er versions of gradle can generate the automatic module manifest (I need to do some research) are you amenable to upgrading if that's the path of least resistance?

xenoterracide avatar Sep 12 '23 17:09 xenoterracide

Absolutely.

alicederyn avatar Sep 12 '23 21:09 alicederyn

Honestly, I went to do this, this morning, but I can't get the project to build. I'm not sure why you've done some things... so I don't want to mess around with a project that doesn't build

 Where:
Script '/home/xeno/IdeaProjects/FreeBuilder/gradle/java-compatibility.gradle' line: 34

* What went wrong:
A problem occurred evaluating root project 'FreeBuilder'.
> Could not get unknown property 'HOME' for root project 'FreeBuilder' of type org.gradle.api.Project.

to fix this you might want to upgrade to gradle 8 (it was introduced in 7, but I'm not sure which version), and use the Java Toolchain feature. I'm only guessing at what you're trying to do though.

to fix the actual issue I brought up here it should be as simple as

jar {
    manifest {
        attributes 'Automatic-Module-Name': 'org.inferred.freebuilder'
    }
}

https://stackoverflow.com/a/53912585/206466

https://blog.joda.org/2017/05/java-se-9-jpms-automatic-modules.html

xenoterracide avatar Sep 27 '23 14:09 xenoterracide

hacky workaround (mostly using it to decide if freebuilder works for me, if not... then I have to decide what I want to do about that)

plugins {
  id("org.gradlex.extra-java-module-info").version("1.+")
}

extraJavaModuleInfo {
  automaticModule("org.inferred:freebuilder", "org.inferred.freebuilder")
  failOnMissingModuleInfo.set(false)
}

not sure if if this adds the manifest to the jar, simply gives it a name on the cli or what https://github.com/gradlex-org/extra-java-module-info

xenoterracide avatar Sep 27 '23 15:09 xenoterracide

I can't get the project to build

That error's coming from these lines here: https://github.com/inferred/FreeBuilder/blob/3a38f58e1e5e69f4b71bd8ac4c5dcfc4c37fa587/gradle/java-compatibility.gradle#L34-L35

It's supposed to write out an error message, but apparently the $HOME needs escaping in the string before it can do that. (It was supposed to be a literal dollar sign in the output.)

alicederyn avatar Sep 27 '23 16:09 alicederyn

Yeah, I'm just thinking there might be a better way to do whatever you're trying to do than there was in 6. You should just be able to copy and paste those jar lines somewhere though and have add the manifest.MF when you build the jar. I haven't tested it though because... Oh because I didn't want to spend a ton of time making your build work. Especially with My IDE.

xenoterracide avatar Sep 27 '23 23:09 xenoterracide