-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #407 from spangaer/oss/jdt-settings
Implement JDT compiler settings writing
- Loading branch information
Showing
17 changed files
with
344 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
!.settings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 | ||
org.eclipse.jdt.core.compiler.source=1.8 | ||
org.eclipse.jdt.core.compiler.compliance=1.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
|
||
val check = TaskKey[Unit]("check") := { | ||
import java.util.Properties | ||
import java.io.FileInputStream | ||
import scala.collection.JavaConverters._ | ||
|
||
val s: TaskStreams = streams.value | ||
val expectedFile = baseDirectory.value / "expected" | ||
val resultFile = baseDirectory.value / ".settings" / "org.eclipse.jdt.core.prefs" | ||
|
||
if (expectedFile.exists()) { | ||
val expectedIn = new FileInputStream(expectedFile) | ||
val expected = | ||
try { | ||
val prop = new Properties() | ||
prop.load(expectedIn) | ||
prop.asScala.toMap | ||
} finally { | ||
expectedIn.close() | ||
} | ||
|
||
val resultIn = new FileInputStream(resultFile) | ||
val result = | ||
try { | ||
val prop = new Properties() | ||
prop.load(resultIn) | ||
prop.asScala.toMap | ||
} finally { | ||
resultIn.close() | ||
} | ||
|
||
if (expected == result) | ||
s.log.info(s"correct data: ${resultFile}") | ||
else | ||
sys.error("Expected settings to be '%s', but was '%s'!".format(expected, result)) | ||
} | ||
} | ||
|
||
// ensure org.eclipse.core.resources.prefs will always be generated | ||
ThisBuild / scalacOptions ++= Seq("-encoding", "utf-8") | ||
|
||
// check that no JDT file is generated (default ignore, no runtime defined) | ||
lazy val projectA = (project in file("a")) | ||
.settings( | ||
check | ||
) | ||
|
||
// check that a new and correct JDT file is generated | ||
lazy val projectB = (project in file("b")) | ||
.settings( | ||
EclipseKeys.executionEnvironment := Some(EclipseExecutionEnvironment.JavaSE18), | ||
EclipseKeys.jdtMode := EclipseJDTMode.Update, | ||
check | ||
) | ||
|
||
// check that a correct JDT file is is not updated | ||
lazy val projectC = (project in file("c")) | ||
.settings( | ||
EclipseKeys.executionEnvironment := Some(EclipseExecutionEnvironment.JavaSE11), | ||
EclipseKeys.jdtMode := EclipseJDTMode.Update, | ||
check | ||
) | ||
|
||
// check that an outdated JDT file is selectively updated | ||
lazy val projectD = (project in file("d")) | ||
.settings( | ||
EclipseKeys.executionEnvironment := Some(EclipseExecutionEnvironment.JavaSE_17), | ||
EclipseKeys.jdtMode := EclipseJDTMode.Update, | ||
check | ||
) | ||
|
||
// check that a JDT file is overwritten | ||
lazy val projectE = (project in file("e")) | ||
.settings( | ||
EclipseKeys.executionEnvironment := Some(EclipseExecutionEnvironment.JavaSE11), | ||
EclipseKeys.jdtMode := EclipseJDTMode.Overwrite, | ||
check | ||
) | ||
|
||
// check that an JDT file is removed | ||
lazy val projectF = (project in file("f")) | ||
.settings( | ||
EclipseKeys.jdtMode := EclipseJDTMode.Remove, | ||
check | ||
) | ||
|
||
// check that an JDT file is default ignored, but written on command | ||
lazy val projectG = (project in file("g")) | ||
.settings( | ||
EclipseKeys.executionEnvironment := Some(EclipseExecutionEnvironment.JavaSE18), | ||
check | ||
) |
4 changes: 4 additions & 0 deletions
4
src/sbt-test/sbteclipse/08-jdt-settings/c/.settings/org.eclipse.jdt.core.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 | ||
org.eclipse.jdt.core.compiler.source=11 | ||
org.eclipse.jdt.core.compiler.compliance=11 | ||
dummy.key=abc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 | ||
org.eclipse.jdt.core.compiler.source=11 | ||
org.eclipse.jdt.core.compiler.compliance=11 | ||
dummy.key=abc |
4 changes: 4 additions & 0 deletions
4
src/sbt-test/sbteclipse/08-jdt-settings/d/.settings/org.eclipse.jdt.core.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 | ||
org.eclipse.jdt.core.compiler.source=11 | ||
org.eclipse.jdt.core.compiler.compliance=11 | ||
dummy.key=abc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 | ||
org.eclipse.jdt.core.compiler.source=17 | ||
org.eclipse.jdt.core.compiler.compliance=17 | ||
dummy.key=abc |
4 changes: 4 additions & 0 deletions
4
src/sbt-test/sbteclipse/08-jdt-settings/e/.settings/org.eclipse.jdt.core.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 | ||
org.eclipse.jdt.core.compiler.source=11 | ||
org.eclipse.jdt.core.compiler.compliance=11 | ||
dummy.key=abc |
Oops, something went wrong.