eclipse-jdtls / eclipse.jdt.ls

Java language server
1.76k stars 393 forks source link

Doesn't support Maven project with source folder at the root #1032

Open yyoncho opened 5 years ago

yyoncho commented 5 years ago

Project: https://github.com/vspinu/IBjts

My guess is that it the issue is caused by the fact that the project overrides the source location to ..

    <build>
        <sourceDirectory>.</sourceDirectory>
        <directory>build</directory>

Oddly the project is imported fine when I first import another project and then add IBjts via workspace/didChangeWorkspaceFolders . But after I restart the workspace it does work again.

(issue originally logged in https://github.com/emacs-lsp/lsp-java/issues/132)

(cc @vspinu)

fbricon commented 5 years ago

Indeed this project is bending the Maven conventions to a point which is not supported by m2e, and it's unlikely it will ever be. You'll definitely get better luck moving the code to src/main/java and then simplifying your pom.xml to read:

<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" 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.interactivebrokers</groupId>
    <artifactId>tws-api</artifactId>
    <version>9.73.01-SNAPSHOT</version>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.7.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>3.0.1</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifestEntries>
                            <Automatic-Module-Name>com.interactivebrokers.twsapi</Automatic-Module-Name>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>