Changing Eclipse Source folder output location generates duplicate classpathentries

(Thierry Guérin) #1

I want to change the output location to separate the test classes from my other classes.
I used the code provided in the Buildship 1.0.18 release notes ( ):

apply plugin: 'java'
apply plugin: 'eclipse'

eclipse {
    classpath {
        file {
            whenMerged {
                def src = entries.find { it.path == 'src/main/java' }
                src.output = "/$"

Note: I don’t use Buildship; I only use the eclipse task to generate my eclipse project.

All works as expected, but when I run the eclipse task a second time, a duplicate (and invalid) classpathEntry is created:

<?xml version="1.0" encoding="UTF-8"?>
    <classpathentry path="bin" kind="output"/>
    <classpathentry output="/gradleSrcFolderOutput/classes/main-java" kind="src" path="src/main/java"/>
    <classpathentry kind="src" path="src/main/java"/>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>

Am I doing something wrong?

(Stefan Oehme) #2

I think this is an issue on our side, because paths in the Eclipse classpath are unique, so we should overwrite the old entry instead of adding a second one.

As a workaround, if you don’t care about merging the previous state (i.e. user-edited values), you could clean the classpath before merging it

beforeMerge {

(Thierry Guérin) #3

Thanks for the workaround Stefan, I don’t mind losing user-edited values so this fits perfectly.

Should I open a bug?

(Stefan Oehme) #4

Please go ahead, yes :slight_smile:

(Thierry Guérin) #5

Done: Issue 922.