diff --git a/xtext-gradle-plugin/src/main/java/org/xtext/gradle/tasks/XtextEclipseSettings.xtend b/xtext-gradle-plugin/src/main/java/org/xtext/gradle/tasks/XtextEclipseSettings.xtend index 47ac2dcd..035902dd 100644 --- a/xtext-gradle-plugin/src/main/java/org/xtext/gradle/tasks/XtextEclipseSettings.xtend +++ b/xtext-gradle-plugin/src/main/java/org/xtext/gradle/tasks/XtextEclipseSettings.xtend @@ -1,5 +1,7 @@ package org.xtext.gradle.tasks; +import com.google.common.base.CharMatcher +import java.io.File import org.gradle.api.DefaultTask import org.gradle.api.tasks.TaskAction @@ -18,11 +20,19 @@ class XtextEclipseSettings extends DefaultTask { prefs.load prefs.putBoolean("is_project_specific", true) language.outputs.forEach [ output | - prefs.put(output.getKey("directory"), project.file(output.dir).absolutePath) + prefs.put(output.getKey("directory"), project.file(output.dir).projectRelativePath) ] prefs.save ] } def String getKey(OutputConfiguration output, String preferenceName) '''outlet.«output.name».«preferenceName»''' + + private def projectRelativePath(File file) { + project.projectDir.toURI.relativize(file.toURI).path.trimTrailingSeparator + } + + private def trimTrailingSeparator(String path) { + CharMatcher.anyOf("/\\").trimTrailingFrom(path) + } }