question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Move module-info.java to /src/main/java

See original GitHub issue

To build gson as a JPMS module, the module-info.java file needs to be in src/main/java, not in src/main/java/com.google.gson.

I checked https://guides.gradle.org/building-java-9-modules/ for confirmation.

With that change, and with these changes in build.gradle, the JAR builds fine as a modular JAR.

sourceCompatibility = 9
targetCompatibility = 9
// sourceSets.main.java.exclude("**/module-info.java")

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

8reactions
krasacommented, Nov 25, 2020

The solution is easy. Do not use Gson, or anything else from Google.

8reactions
2008Chococommented, Sep 7, 2019

This was resolved almost 1 year ago yet there is still no release. Considering we’re on a stable Java 12 release and some running Java 14 pre-builds and modularity should have been completely adopted by Java 11, can we please at least get a release addressing this issue? Even if it’s a minor release, 2.8.5.1. For projects where automatic modules aren’t an option (jlink for instance), it’s an inconvenience.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Move module-info.java to /src/main/java #1315 - google/gson
To build gson as a JPMS module, the module-info.java file needs to be in src/main/java, not in src/main/java/com.google.gson.
Read more >
Where to place module-info.java using Java 9? - Stack Overflow
To answer your specific questions: Place module declaration ( module-info.java ) into the project's source root directory (e.g. src/main/java ).
Read more >
574831 – Computation of module name in Java launch ... - Bugs
The module-info was moved from src/main/jpms to src/main/java => it failed unless I create a new Launch configuration (not a copy). 3.
Read more >
Java Modules - Jenkov.com
A Java module is a packaging mechanism that enables you to package a Java application or Java API as a separate Java module....
Read more >
Chapter 14. The Java Module System - Modern Java in Action
xml files and the Maven directory project structure. The module descriptor ( module-info.java ) needs to be located in the src/main/java directory. Maven...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found