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

Multi-module Maven project does not work #1248

Open
ccarv opened this issue Jan 18, 2020 · 18 comments
Open

Multi-module Maven project does not work #1248

ccarv opened this issue Jan 18, 2020 · 18 comments
Labels

Comments

@ccarv
Copy link

ccarv commented Jan 18, 2020

I created a multi-module Maven project and tried to open the root folder in Visual Studio Code. When I try to work with any of the sub-modules, I do not get any linting, formatting, refactoring, etc... I tried Add Folder to Java Source Path but that does not work either. I have no issues working with this project in other IDE's, including Eclipse.

Environment
  • Operating System: Windows 10
  • JDK version: 1.8.0.201
  • Visual Studio Code version: 1.14.1
  • Java extension version: 0.55.1
Steps To Reproduce
  1. Clone example project:
git clone https://github.com/hashdelta/stix-pattern-evaluator-examples.git
cd stix-pattern-evaluator-examples
git checkout develop
  1. Open project in VSCode
Current Result

The plugin does not recognize the children modules, thus does not provide any kind of Java semantics support - no linting, formatting, refactoring, etc...

Expected Result

You should be able to get semantics support for any Java class when you open the parent. It should be one cohesive project.

Additional Informations

The only way to work with the sub modules is by opening the module in its own VSCode instance. This does not work for me, as one of my projects consists of over 20+ modules.

I have verified in Eclipse, NetBeans, and IntelliJ that the GitHub project has no issues.

@snjeza
Copy link
Contributor

snjeza commented Jan 18, 2020

@ccarv
Copy link
Author

ccarv commented Jan 18, 2020

Attached the server log.
vscode-server.log

@ccarv
Copy link
Author

ccarv commented Jan 18, 2020

@snjeza It looks like clearing the workspaceStorage fixed my issue. Does this deserve a close?

@ccarv ccarv closed this as completed Jan 18, 2020
@ccarv ccarv reopened this Jan 18, 2020
@snjeza
Copy link
Contributor

snjeza commented Jan 18, 2020

It looks like clearing the workspaceStorage fixed my issue. Does this deserve a close?

@hashdelta yes, you can close the issue.

@ccarv
Copy link
Author

ccarv commented Jan 26, 2020

@snjeza Revisiting this. What is the proper way to initialize a new maven sub module in VSCode? I am manually creating the POM and folder hierarchy, and VSCode does not recognize it unless I clear the workspaceStorage directory, which is a non-solution.

@snjeza
Copy link
Contributor

snjeza commented Jan 26, 2020

Revisiting this. What is the proper way to initialize a new maven sub module in VSCode? I am manually creating the POM and folder hierarchy, and VSCode does not recognize it unless I clear the workspaceStorage directory, which is a non-solution.

Related to eclipse-jdtls/eclipse.jdt.ls#901
@ccarv could you try https://github.com/snjeza/vscode-test/blob/master/java-0.56.1.vsix?raw=true

@ousiax
Copy link

ousiax commented May 7, 2021

I have the same problem. What can I do to solve it is to reopen the root folder again after create a new sub module.

Btw, I think the vscode should refresh the project automatically.

@holmofy
Copy link

holmofy commented Jul 16, 2021

Me too. Open multi-module project will have a lot of error

@brunoborges
Copy link

Facing issue too with the microsoft/gctoolkit project (multi-module, and each has its own module-info.java).

@go-fish-wxy
Copy link

It looks like clearing the workspaceStorage fixed my issue. Does this deserve a close?

@hashdelta yes, you can close the issue.

Hi, I am just facing same issue, kindof no idea how to make vs code recognize the project folder and all sub folders and files as a multi-module maven project,
e.g. pom file in sub module report error "could not find dependency"
What steps shall I take to make project workable in vs code until I can debug the source file

@tonyvperez
Copy link

It appears this issue hasn't received prioritization needed for resolution. I'm working on a project that requires the building of such a repo with nested modules and there isn't a viable solution to develop with intellisense intact. Is there any plans to work in this issue in the near future?

@rossinineto
Copy link

rossinineto commented Aug 17, 2023

For me, source folders from submodules doesn´t appear after added a java project multi modules.
For workaround, I downgraded the extension "Project Manager for Java" (https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-dependency) to version 0.21.2

Captura de tela 2023-08-17 095642

@rossinineto
Copy link

Updated "Project Manager for Java" to v0.23.1 and occurs the problem bellow:

Captura de tela 2023-09-03 095215

@crowmagnumb
Copy link

I have all my code in a mono-repo. All my Java code is in modules in a sub-directory called java. Despite the mono-repo I've been using Eclipse for all my Java dev and VSCode for everything else. BUT I want to consolidate it all under VSCode but I just can't get the Java code to work right. There is a single parent pom.xml that lists all of the sub-modules which hierarchically depend on one another. If I open in VSCode the folder containing just the lowest sub-module in the stack, so that it is alone in the workspace and only depends on 3rd-party code listed in it's pom.xml, the Java and maven plugins all work right out of the box and I can edit and debug just fine.

BUT I can't figure out how to get VSCode to recognize the java and maven code if I open the full repo. Does this just not work?

@snjeza
Copy link
Contributor

snjeza commented Nov 16, 2023

There is a single parent pom.xml

@crowmagnumb Could you show this pom.xml?

@crowmagnumb
Copy link

@snjeza Here is my parent pom.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.animalus</groupId>
  <artifactId>auroot-parent</artifactId>
  <version>2.0.0</version>
  <packaging>pom</packaging>
  
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <!-- Skipping javadoc by default. If you want to run the javadoc run...
			mvn -Dmaven.javadoc.skip=false javadoc:javadoc -->
    <maven.javadoc.skip>true</maven.javadoc.skip>
    <flyway.version>9.21.1</flyway.version>
    <jackson.version>2.15.2</jackson.version>
    <!-- <shiro.version>1.12.0</shiro.version> -->
    <shiro.version>2.0.0-alpha-3</shiro.version>
    <junit.version>5.10.0</junit.version>
    <!-- upgrade these together depending on which version of springframework
		     is used by the version of springboot or else you may get duplicate
			 libraries in the final packaged jar. Annoyingly springsession is
		     on a different schedule, so just bump to its latest I guess -->
    <!-- <springcore.version>5.3.21</springcore.version> -->
    <springboot.version>3.1.2</springboot.version>
    <springsession.version>3.1.1</springsession.version>
  </properties>
  
  <modules>
    <module>auroot-core</module>
    <module>auroot-http</module>
    <module>autravel</module>
    <module>autravel-http</module>
    <module>critterspot-core</module>
    <module>critterspot-admin</module>
    <module>critterspot-http</module>
    <module>critterspot-server</module>
    <module>crowdb</module>
    <module>crowjson</module>
    <module>crowlang</module>
    <module>auhttp</module>
    <module>auzooniverse</module>
  </modules>
  
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.5.0</version>

        <configuration>          <reportOutputDirectory>${project.basedir}/target/${project.artifactId}-${project.version}</reportOutputDirectory>
          <destDir>javadoc</destDir>
          <show>private</show>
        </configuration>

        <executions>
          <execution>
            <phase>install</phase>
            <goals>
              <goal>javadoc</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.11.0</version>
        <configuration>
          <release>17</release>
        </configuration>
      </plugin>
      
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        <version>3.1.2</version>
        <configuration>
          <argLine>--illegal-access=permit</argLine>
        </configuration>
        
        <executions>
          <execution>
            <goals>
              <goal>integration-test</goal>
              <goal>verify</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      
      <plugin>
        <groupId>org.flywaydb</groupId>
        <artifactId>flyway-maven-plugin</artifactId>
        <version>${flyway.version}</version>
      </plugin>
      
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.1.2</version>
        <configuration>
          <argLine>--illegal-access=permit</argLine>
        </configuration>
      </plugin>
      
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <version>3.3.0</version>
        <executions>
          <execution>
            <id>attach-sources</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>versions-maven-plugin</artifactId>
        <version>2.16.0</version>
        <configuration>
          <generateBackupPoms>false</generateBackupPoms>
        </configuration>
      </plugin>
      
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>3.3.0</version>
        <executions>
          <execution>
            <id>enforce-versions</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <requireMavenVersion>
                  <version>3.2.5</version>
                </requireMavenVersion>
              </rules>
            </configuration>
          </execution>
        </executions>
      </plugin>
      
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <version>3.3.1</version>
        <configuration>
          <encoding>UTF-8</encoding>
          <nonFilteredFileExtensions>
            <nonFilteredFileExtension>ttf</nonFilteredFileExtension>
          </nonFilteredFileExtensions>
        </configuration>
      </plugin>
    
    </plugins>
  
  </build>

</project>

Note: The Java/Maven plugins recognize this as a java project (it shows up in the java projects list) BUT the sub-projects (modules) and their poms are not recognized.

@snjeza
Copy link
Contributor

snjeza commented Nov 16, 2023

BUT the sub-projects (modules)

Could you show your workspace and user settings.json and your logs - Enable Logging?

@crowmagnumb
Copy link

@snjeza Thank you! I didn't know how to set the logs to debug nor read them. Through the logs I found out that all of my .project files from Eclipse all had <!DOCTYPE xml> on the 2nd line and that was causing it grief. No idea how they got there (well probably auto-added by Eclipse) but I removed those lines, reloaded the Java extension and voila it works!!! Thank you!

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

No branches or pull requests

10 participants