Classes in module not accessible in main module?

已回答

Greetings!

I have simple project:

1. Main module is Java FX application. "HelloApplication" that works.

2. Other module, let's call it mEllClient, contains very simple POJO classes. Ant build, but I've tried the others with same results.

And that result is - from main module no classes in other modules can be seen. So, POJO in module is, say, company.model.InvTx and there's no way for me in main module to write something like:

import company.model;

...

InvTx invTx = new InvTx();

The most similar question is this from 2007:

https://intellij-support.jetbrains.com/hc/en-us/community/posts/206209479-Strange-issue-with-classes-in-one-module?input_string=Classes%20in%20module

I've tried the same project on colleague's computer, and it works there. Does not work when imported back into my computer. Tried with both Ultimate and Community editions, as snap and tar.gz. Always the same.

Where else shoul I look into?

IDEA is 2021.3.3. everything else on my computer works normally (including Android Studio and other Java software). I'm completely baffled by this.

0
Avatar
Permanently deleted user

It does work in 2021.1.3. So, obiously, it is a bug in 2021.3.3. Please, solve it.

0

Hi Slaven,

Would it be possible for you to share your project so that I can check it?

0
Avatar
Permanently deleted user

Of course.

Download link to zipped project is here:

https://www.dropbox.com/sh/u1rsqvrrf910drv/AAAN6PknfTLMTeZTdM0GL8Woa?dl=0

Project is vEll, module is mEllClient.

A line in HelloController should compile, and should be autocompleteable in editor. It isn't. I tested it with both Maven and Gradle JavaFX, and module also as Ant. On IDEA 2021.3.3

There is possibilitiy that's something wrong with Java FX templates so that Maven and/or Gradle are getting something wrong.

Best regards!

0

Thank you, checking.

0
Avatar
Permanently deleted user

Greetings!

Anything new?

If it is a bug, how can I circumvent it?

0
Avatar
Permanently deleted user

BUMP!

;-)

0

How does this project in the same shape work for your colleagues? I se that the JavaFX - is a Java 9 module (having module-info.java) but you want to add a dependency on non-modular project from modular project. I see two issues in the project:

1. To be able to use other Gradle module (mEllClient) as a dependency for project (vEll) - the project must be multi-module Gradle project and include both modules ( vEll and mEllClient in your case). So you should add

include 'mEllClient'

into settings.gradle for the vEll project. And then add

implementation project(':mEllClient')

into build.gradle for the vEll project.

See more about Creating a multi-project build and Project dependencies in Gradle documentation.

2. Now the second problem is that you want to use a dependency in your modular project (vEll) on a Gradle module with is not structured as a Java 9 module. There will be problems since the mEllClient module is not a Java 9 Module. So you should convert it to a Java 9 module (adding the module-info.java descriptor to it) or do not use Java modules for the vEll module.

It should be possible (as Gradle recognizes automatic module dependencies) to just make the module "automatic" - i.e. just add module-info.java and declare the module name, e.g.

module vEll.mEllClient.main {
exports koris.mEllClient;
}

and then add requires for this module in module-info.java of the vEll module:

requires vEll.mEllClient.main;
0
Avatar
Permanently deleted user

It works!

And I also do get separate jar for module mEllClient. It is important because I'll use it in (refactored) Android app, since this module will have only pure Java dependecies (POJOs, JSON parsing, and REST API access) for sharing between Android mobile app and JavaFX desktop app.

Many thanks!

I've just changed module-info.java of mEllClient to simplified (without vell prefix):

module mEllClient.main {
    exports koris.mEllClient;
}

Best regards!

0

请先登录再写评论。