eclipse / xtext

Eclipse Xtext™ is a language development framework
http://www.eclipse.org/Xtext
Eclipse Public License 2.0
768 stars 321 forks source link

testOutputDirectory is ignored during Maven build #2264

Open wzurborg opened 4 years ago

wzurborg commented 4 years ago

I am working on a Xtext/Xcore/Xtend/Maven/Tycho project. My problem is that the Xtend test classes are generated into the wrong directory during the Maven build. When the Xtend compiler is triggered by the workspace builder, the test sources are generated into the correct directory. This leads to duplicate test sources.

My Maven setup:

<plugin>
    <groupId>org.eclipse.xtend</groupId>
    <artifactId>xtend-maven-plugin</artifactId>
    <executions>
        <execution>
            <goals>
                <goal>compile</goal>
                <goal>testCompile</goal>
            </goals>
                     <configuration>
                         <writeTraceFiles>false</writeTraceFiles>
                         <outputDirectory>${project.basedir}/src/main/xtend-gen</outputDirectory>
                         <testOutputDirectory>${project.basedir}/src/test/xtend-gen</testOutputDirectory>
                     </configuration>
        </execution>
    </executions>
</plugin>

When run in Maven, the test sources are wrongly generated into src/main/xtend-gen; when run by the Eclipse builder, they are correctly generated into src/test/xtend-gen.

szarnekow commented 4 years ago

Does it work for you?

wzurborg commented 4 years ago

I sent you a mail directly. I am not sure, I will re-open it when I have debugged the problem.

wzurborg commented 4 years ago

Reopened since the problem persists. I have tried many variations for configuring the xtend-maven-plugin, but nothing has helped so far.

cdietrich commented 4 years ago

can you please provide a minimal reproducible example?

wzurborg commented 4 years ago

Difficult, but I will try.

wzurborg commented 4 years ago

Please see https://github.com/wzurborg/xtend-example for a minimal example. I can reproduce the problem with this project, i.e. test sources are generated into src/main/xtend-gen with the Maven build and into src/test/xtend-gen with the Eclipse build.

cdietrich commented 4 years ago

i have no idea if eclipse-plugin supports this usecase at all. usually test code is a separate plugin with <packaging>eclipse-test-plugin</packaging>

wzurborg commented 4 years ago

If this is not supported then a warning should be added to https://www.eclipse.org/Xtext/documentation/350_continuous_integration.html#tycho-build .

I will separate the test code in any case to avoid unwanted test dependencies in the product.

wzurborg commented 4 years ago

I have now separated the tests into an own plug-in with <packaging>eclipse-test-plugin</packaging> but also with a Maven style folder structure, i.e. src/test/java and src/test/xtend-gen.

The fact is that still the testOutputDirectory setting is ignored and the Xtend sources are generated into src/main/xtend-gen, which is the configuration for outputDirectory.

Only when I set outputDirectory to src/test/xtend-gen are the sources generated into there.

So for me this clearly indicates that the configuration of testOutputDirectory is ignored and instead the configuration of outputDirectory is applied during Maven build in all cases.

The strange thing is that the configuration of testOutputDirectory is applied (only) during the Eclipse build.

cdietrich commented 4 years ago

in a normal non plugin usecase this works perfectly fine

https://github.com/itemis/xtext-reference-projects/blob/master/greetings-maven/2.22.0/org.xtext.example.mydsl.parent/pom.xml

for a plugin build setup check

https://github.com/itemis/xtext-reference-projects/blob/master/greetings-tycho/2.22.0/org.xtext.example.mydsl.parent/pom.xml

cdietrich commented 4 years ago

for the rest someone needs to debug this. and i fear there is nobody who has the time to do it

it could e.g. be that the source are considered as src and not test-src

cdietrich commented 4 years ago

p.s.: did you double check you dont have any setting in the .settings/org.eclipse.xtend.core.prefs

cdietrich commented 4 years ago

@wzurborg could you push your latest config to a branch

wzurborg commented 4 years ago

.settings/org.eclipse.xtend.core.Xtend.prefs:

//outlet.DEFAULT_OUTPUT.sourceFolder.src/main/java.directory=src/main/xtend-gen
//outlet.DEFAULT_OUTPUT.sourceFolder.src/test/java.directory=src/test/xtend-gen
BuilderConfiguration.is_project_specific=true
eclipse.preferences.version=1
outlet.DEFAULT_OUTPUT.hideLocalSyntheticVariables=true
outlet.DEFAULT_OUTPUT.installDslAsPrimarySource=false
outlet.DEFAULT_OUTPUT.userOutputPerSourceFolder=true

could you push your latest config to a branch

I would have to do the separation in my minimal example, which I have not done yet.

For me the workaround of setting outputDirectory in the test project is sufficient but I will try to debug further.