Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version = 3.8.1
runner.dialect = scala3

rewrite.scala3.convertToNewSyntax = true
rewrite.scala3.removeOptionalBraces = no

rewrite.rules = []
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed
- Redesigned the `ExtractorSpec.scala`, to clear test files between different tests. [#299](https://github.com/ie3-institute/simBench2psdm/issues/299)
- Updated to `scala3` [#313](https://github.com/ie3-institute/simBench2psdm/issues/313)

## [1.0.0] - 2021-08-03
### Added
Expand Down
18 changes: 7 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ ext {
//version (changing these should be considered thoroughly!)
javaVersion = JavaVersion.VERSION_17

scalaVersion = '2.13'
scalaBinaryVersion = '2.13.16'
scalaVersion = '3'
scalaBinaryVersion = '3.7.0'
tscfgVersion = '1.2.4'
slf4jVersion = '2.0.17'

Expand Down Expand Up @@ -46,15 +46,15 @@ repositories {

dependencies {
/* PowerSystemDataModel */
implementation('com.github.ie3-institute:PowerSystemDataModel:6.0.0') {
implementation('com.github.ie3-institute:PowerSystemDataModel:7.0.0') {
exclude group: 'org.apache.logging.log4j'
exclude group: 'org.slf4j'
/* Exclude our own nested dependencies */
exclude group: 'com.github.ie3-institute'
}

/* util functions */
implementation('com.github.ie3-institute:PowerSystemUtils:2.2.1') {
implementation('com.github.ie3-institute:PowerSystemUtils:3.1.0') {
exclude group: 'org.apache.logging.log4j'
exclude group: 'org.slf4j'
/* Exclude our own nested dependencies */
Expand All @@ -77,8 +77,8 @@ dependencies {

// NEW scala libs //
// CORE Scala //
implementation "org.scala-lang:scala-library:$scalaBinaryVersion"
implementation 'org.scala-lang.modules:scala-parallel-collections_2.13:1.2.0'
implementation "org.scala-lang:scala3-library_3:$scalaBinaryVersion"
implementation "org.scala-lang.modules:scala-parallel-collections_$scalaVersion:1.2.0"

// TEST Scala //
testImplementation "org.scalatest:scalatest_${scalaVersion}:3.2.19"
Expand All @@ -88,7 +88,7 @@ dependencies {

// config //
implementation 'com.typesafe:config:+'
implementation "com.github.carueda:tscfg_2.13:${tscfgVersion}"
implementation "com.github.carueda:tscfg_$scalaVersion:${tscfgVersion}"

// cmd args parser //
implementation "com.github.scopt:scopt_${scalaVersion}:+"
Expand All @@ -97,10 +97,6 @@ dependencies {
implementation "org.apache.commons:commons-compress:+"
}

wrapper {
gradleVersion = '7.6'
}

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
1 change: 0 additions & 1 deletion gradle/scripts/scoverage.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/
scoverage {
scoverageVersion = "2.3.0"
scoverageScalaVersion = scalaBinaryVersion
coverageOutputHTML = false
coverageOutputXML = true
coverageOutputCobertura = false
Expand Down
4 changes: 2 additions & 2 deletions gradle/scripts/spotless.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ spotless {

//sets a license header, removes unused imports and formats conforming to the scala fmt formatter
scala {
scalafmt()
scalafmt().configFile('.scalafmt.conf')
}

/* cf. https://github.com/diffplug/spotless/tree/master/plugin-gradle */
Expand All @@ -36,7 +36,7 @@ spotless {
format 'misc', {
target '**/*.md', '**/.gitignore', 'configs/**'
trimTrailingWhitespace()
indentWithTabs()
leadingSpacesToTabs()
endWithNewline()
}
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
10 changes: 5 additions & 5 deletions src/main/scala/edu/ie3/simbench/config/ArgsParser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package edu.ie3.simbench.config
import java.io.File
import java.nio.file.Paths

import com.typesafe.config.{ConfigFactory, Config => TypesafeConfig}
import scopt.{OptionParser => scoptOptionParser}
import com.typesafe.config.{ConfigFactory, Config as TypesafeConfig}
import scopt.OptionParser as scoptOptionParser

object ArgsParser {
// case class for allowed arguments
Expand All @@ -24,11 +24,11 @@ object ArgsParser {
)
})
.validate(value =>
if (value.trim.isEmpty) failure("config location cannot be empty")
if value.trim.isEmpty then failure("config location cannot be empty")
else success
)
.validate(value =>
if (value.contains("\\"))
if value.contains("\\") then
failure("wrong config path, expected: /, found: \\")
else success
)
Expand All @@ -48,7 +48,7 @@ object ArgsParser {

private def parseTypesafeConfig(fileName: String): TypesafeConfig = {
val file = Paths.get(fileName).toFile
if (!file.exists())
if !file.exists() then
throw new Exception(s"Missing config file on path $fileName")
parseTypesafeConfig(file)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ case object ConfigValidator {
*/
@throws[CodeValidationException]
private def checkSimbenchCodes(codes: List[java.lang.String]): Unit = {
for (code <- codes) {
for code <- codes do {
SimbenchCode.isValid(code) match {
case Success(_) =>
case Failure(exception) => throw exception
Expand Down
34 changes: 17 additions & 17 deletions src/main/scala/edu/ie3/simbench/config/SimbenchConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ object SimbenchConfig {
"directoryHierarchy"
),
fileEncoding =
if (c.hasPathOrNull("fileEncoding")) c.getString("fileEncoding")
if c.hasPathOrNull("fileEncoding") then c.getString("fileEncoding")
else "UTF-8",
fileEnding =
if (c.hasPathOrNull("fileEnding")) c.getString("fileEnding")
if c.hasPathOrNull("fileEnding") then c.getString("fileEnding")
else ".csv",
separator =
if (c.hasPathOrNull("separator")) c.getString("separator") else ";"
if c.hasPathOrNull("separator") then c.getString("separator") else ";"
)
}
}
Expand Down Expand Up @@ -78,14 +78,14 @@ object SimbenchConfig {
): SimbenchConfig.Io.Input.Download = {
SimbenchConfig.Io.Input.Download(
baseUrl =
if (c.hasPathOrNull("baseUrl")) c.getString("baseUrl")
if c.hasPathOrNull("baseUrl") then c.getString("baseUrl")
else "https://daks.uni-kassel.de/bitstreams",
failOnExistingFiles =
c.hasPathOrNull("failOnExistingFiles") && c.getBoolean(
"failOnExistingFiles"
),
directory =
if (c.hasPathOrNull("folder")) c.getString("folder")
if c.hasPathOrNull("folder") then c.getString("folder")
else "inputData/download/"
)
}
Expand All @@ -98,13 +98,13 @@ object SimbenchConfig {
): SimbenchConfig.Io.Input = {
SimbenchConfig.Io.Input(
csv = SimbenchConfig.CsvConfig(
if (c.hasPathOrNull("csv")) c.getConfig("csv")
if c.hasPathOrNull("csv") then c.getConfig("csv")
else com.typesafe.config.ConfigFactory.parseString("csv{}"),
parentPath + "csv.",
$tsCfgValidator
),
download = SimbenchConfig.Io.Input.Download(
if (c.hasPathOrNull("download")) c.getConfig("download")
if c.hasPathOrNull("download") then c.getConfig("download")
else com.typesafe.config.ConfigFactory.parseString("download{}"),
parentPath + "download.",
$tsCfgValidator
Expand All @@ -127,13 +127,13 @@ object SimbenchConfig {
SimbenchConfig.Io.Output(
compress = !c.hasPathOrNull("compress") || c.getBoolean("compress"),
csv = SimbenchConfig.CsvConfig(
if (c.hasPathOrNull("csv")) c.getConfig("csv")
if c.hasPathOrNull("csv") then c.getConfig("csv")
else com.typesafe.config.ConfigFactory.parseString("csv{}"),
parentPath + "csv.",
$tsCfgValidator
),
targetDir =
if (c.hasPathOrNull("targetFolder")) c.getString("targetFolder")
if c.hasPathOrNull("targetFolder") then c.getString("targetFolder")
else "convertedData"
)
}
Expand All @@ -146,13 +146,13 @@ object SimbenchConfig {
): SimbenchConfig.Io = {
SimbenchConfig.Io(
input = SimbenchConfig.Io.Input(
if (c.hasPathOrNull("input")) c.getConfig("input")
if c.hasPathOrNull("input") then c.getConfig("input")
else com.typesafe.config.ConfigFactory.parseString("input{}"),
parentPath + "input.",
$tsCfgValidator
),
output = SimbenchConfig.Io.Output(
if (c.hasPathOrNull("output")) c.getConfig("output")
if c.hasPathOrNull("output") then c.getConfig("output")
else com.typesafe.config.ConfigFactory.parseString("output{}"),
parentPath + "output.",
$tsCfgValidator
Expand All @@ -168,13 +168,13 @@ object SimbenchConfig {
val parentPath: java.lang.String = ""
val $result = SimbenchConfig(
conversion = SimbenchConfig.Conversion(
if (c.hasPathOrNull("conversion")) c.getConfig("conversion")
if c.hasPathOrNull("conversion") then c.getConfig("conversion")
else com.typesafe.config.ConfigFactory.parseString("conversion{}"),
parentPath + "conversion.",
$tsCfgValidator
),
io = SimbenchConfig.Io(
if (c.hasPathOrNull("io")) c.getConfig("io")
if c.hasPathOrNull("io") then c.getConfig("io")
else com.typesafe.config.ConfigFactory.parseString("io{}"),
parentPath + "io.",
$tsCfgValidator
Expand All @@ -189,7 +189,7 @@ object SimbenchConfig {
parentPath: java.lang.String,
$tsCfgValidator: $TsCfgValidator
): scala.List[java.lang.String] = {
import scala.jdk.CollectionConverters._
import scala.jdk.CollectionConverters.*
cl.asScala.map(cv => $_str(cv)).toList
}
private def $_expE(
Expand All @@ -200,15 +200,15 @@ object SimbenchConfig {
new java.lang.RuntimeException(
s"${cv.origin.lineNumber}: " +
"expecting: " + exp + " got: " +
(if (u.isInstanceOf[java.lang.String]) "\"" + u + "\"" else u)
(if u.isInstanceOf[java.lang.String] then "\"" + u + "\"" else u)
)
}

private def $_str(cv: com.typesafe.config.ConfigValue): java.lang.String = {
java.lang.String.valueOf(cv.unwrapped())
}

private final class $TsCfgValidator {
final class $TsCfgValidator {
private val badPaths =
scala.collection.mutable.ArrayBuffer[java.lang.String]()

Expand All @@ -228,7 +228,7 @@ object SimbenchConfig {
}

def validate(): Unit = {
if (badPaths.nonEmpty) {
if badPaths.nonEmpty then {
throw new com.typesafe.config.ConfigException(
badPaths.mkString("Invalid configuration:\n ", "\n ", "")
) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package edu.ie3.simbench.convert
import edu.ie3.datamodel.models.input.NodeInput
import edu.ie3.simbench.model.datamodel.Coordinate
import edu.ie3.util.geo.GeoUtils
import org.locationtech.jts.geom.{Point, Coordinate => JTSCoordinate}
import org.locationtech.jts.geom.{Point, Coordinate as JTSCoordinate}

/** Converts a SimBench coordinate to the needed geometry position of
* PowerSystemDataModel
Expand Down
Loading