Problems with Git, Intellij, and module-info.java

529 views Asked by At

So I'm working on a group Java 14 project right now and something appears to have gone wrong in my code in terms of building and executing. I switched over from Eclipse a while back due to difficulties with the way it handled Git, and have been enjoying IntelliJ very much despite these issues. The project uses JavaFX, so I downloaded from the website and followed all the instructions here, including adding the lib folder as a Library and adding all of the VM options to the Run Configurations.

VM Run Configuration Options

Added JavaFX Library

I then ensured that all the necessary modules were checked and applied to the project:

Modules active in the project

There were no errors anywhere in the code and my module-info.java looked like as follows:

module activity7
{
    exports activity7;
    requires javafx.controls;
    requires transitive javafx.graphics;
    requires static junit;
}

However, upon building the project to run some JUnit tests, I am greeted with the following build output:

java: module not found: junit
java: module not found: javafx.graphics
java: module not found: javafx.controls

Interestingly, if I delete the module-info.java, the project builds and runs exactly like it's supposed to. My team has indicated they need the file, but with it in my library, I can't actually build/run anything. I attempted to put it in the .gitignore, but even when I change the internals of module-info.java, it still shows up as a change to commit in my default changelist. Same with the .git/info/exclude for local changes. I've attempted closing the project and reimporting it from git, as well as invalidating the caches and restarting, but nothing seems to remove build error. The structure of the project is this:

Project Structure

And finally, the contents of .gitignore:

# Compiled class file
*.class
.classpath

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
.idea/
/303a2t6.iml

out/
bin/
.DS_Store/
*.iws
workspace.xml
tasks.xml
*.iml

and .git/info/exclude:

# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~

I'm truly lost and would love some help or guidance into how to fix this. I can currently still contribute code to the repository, but it requires that I delete the local copy of my module-info.java and ensure I don't accidentally commit its deletion and push it up to the remote repo. Then, of course, whenever I pull, I have to repeat the process all over again.

1

There are 1 answers

0
McBlankenburg On

Send all controller-class to package activity7.controller
(MVC - model, view, controller) read about that

module activity7
{
requires javafx.controls;
requires javafx.graphics;

exports activity7;
exports activity7.controller;

}

I just don't know if it will be working with JUnit
maybe try create new module-info in Test and there

module activity7
{

requires junit;

exports activity7;
exports activity7.controller;
}

for example my project:

Project structure MVC