mopemope/meghanada-server

output and test-output path not relative

Closed this issue · 1 comments

When specifying the output and the test-output path in the .meghanada.conf file, if they are relative path like this :

java-home = "/usr/lib/jvm/java-8-openjdk/"
java-version = "1.8"
compile-source = "1.8"
compile-target = "1.8"
sources = ["src/main/java"]
test-sources = ["src/test/java"]
dependencies =
    [
        "lib/antlr-2.7.7.jar",
        "lib/cdi-api-1.1.jar",
        "lib/classmate-1.3.0.jar",
        "lib/dom4j-1.6.1.jar",
        "lib/el-api-2.2.jar",
        "lib/geronimo-jta_1.1_spec-1.1.1.jar",
        "lib/hibernate-commons-annotations-5.0.1.Final.jar",
        "lib/hibernate-core-5.2.3.Final.jar",
        "lib/hibernate-jpa-2.1-api-1.0.0.Final.jar",
        "lib/jandex-2.0.0.Final.jar",
        "lib/javassist-3.20.0-GA.jar",
        "lib/javax.inject-1.jar",
        "lib/jboss-interceptors-api_1.1_spec-1.0.0.Beta1.jar",
        "lib/jboss-logging-3.3.0.Final.jar",
        "lib/jsr250-api-1.0.jar"
    ]
output = "out_meghanada/"
test-output = "out_meghanada/"

they will not be interpreted as relative path from the project, but only from the directory where you launch the server. Here is an example of meghanada-show-project where I open my project in a specific (not root) directory of my project :

sources:
  /home/gary/Documents/gary/ProjetSpringHibernate/src/main/java
resources:
  /home/gary/Documents/gary/ProjetSpringHibernate/src/main/resources
  /home/gary/Documents/gary/ProjetSpringHibernate/src/main/resource
output:
  out_meghanada
testSources:
  /home/gary/Documents/gary/ProjetSpringHibernate/src/test/java
testResources:
  /home/gary/Documents/gary/ProjetSpringHibernate/src/test/resources
  /home/gary/Documents/gary/ProjetSpringHibernate/src/test/resource
testOutput:
  out_meghanada

So the output folder will be created in this specific directory.

I don't know if it's meant to be like this or not but in the official README.md, we can see that these two variables are also relative.

I guess this come from the Project.java file at line 784, where

// output
if (config.hasPath(OUTPUT)) {
    String o = config.getString(OUTPUT);
    this.output = new File(o);
}

this.output is only based on the OUTPUT coming from the config file. (To compare, for all the other variables coming from the config file, the line this.output = new File(o); is like this :

File file = new File(path);
    if (!file.isAbsolute()) {
        file = new File(this.projectRoot, path);
}

I tried to fix it on my side but I had some issue validating all the unit tests : I ran the ./gradlew clean goJF check shadowJar command but had some failed tests (even if I ran it without changing anything on the project).

So yes and thank you devs for this awesome project !

@GaryOma Thank you for your report!. I will fix it soon.