Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #24986: Enable scala 3 cross compilation #5727

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
31 changes: 2 additions & 29 deletions webapp/sources/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,23 +107,6 @@ limitations under the License.
</extension>
</extensions>
<plugins>
<plugin>
<groupId>io.github.evis</groupId>
<artifactId>scalafix-maven-plugin_2.13</artifactId>
<version>0.1.8_0.11.0</version>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-rewrites_2.13</artifactId>
<version>0.1.5</version>
</dependency>
<dependency>
<groupId>ch.epfl.scala</groupId>
<artifactId>scala3-migrate-rules_2.13</artifactId>
<version>0.6.2</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<!-- Specify maven resources plugin version because to avoid this bug from plugin 3.2+ https://issues.apache.org/jira/browse/MRESOURCES-269
especially with maven 3.9 that uses version 3.3.0 of this plugin by default, see https://issues.rudder.io/issues/22403
Expand Down Expand Up @@ -167,13 +150,6 @@ limitations under the License.
<configuration>
<scalaCompatVersion>${scala-binary-version}</scalaCompatVersion>
<recompileMode>all</recompileMode>
<compilerPlugins>
<compilerPlugin>
<groupId>org.scalameta</groupId>
<artifactId>semanticdb-scalac_${scala-version}</artifactId>
<version>4.8.14</version>
</compilerPlugin>
</compilerPlugins>
<args>
<arg>-release:17</arg>
<arg>-dependencyfile</arg>
Expand All @@ -184,7 +160,7 @@ limitations under the License.
-Xlint:_,-nullary-unit,-missing-interpolator -Yno-adapted-args -Ywarn-dead-code -Ywarn-extra-implicit -Ywarn-inaccessible
-Ywarn-infer-any -Ywarn-nullary-override -Ywarn-numeric-widen -Ywarn-unused:imports -Ywarn-unused:locals -Ywarn-unused:privates
-->
<arg>-Xsource:3</arg>
<arg>-Xsource:3-cross</arg>
<arg>-deprecation</arg> <!-- Emit warning and location for usages of deprecated APIs. -->
<arg>-explaintypes</arg> <!-- Explain type errors in more detail. -->
<arg>-feature</arg> <!-- Emit warning and location for usages of features that should be imported explicitly. -->
Expand Down Expand Up @@ -213,9 +189,6 @@ limitations under the License.

<!-- fastparse 3.0.1 emits false unused warning. We must silence them on related files. See: https://github.com/com-lihaoyi/fastparse/issues/285-->
<arg>-Wconf:cat=unused-nowarn&amp;src=com/normation/utils/Version.scala:s,cat=unused-nowarn&amp;src=com/normation/rudder/services/policies/InterpolatedValueCompiler.scala:s</arg>

<!-- this warning is no an actual issue, our smart constructor usage is fine with a scala 3 compiler-->
<arg>-Wconf:msg=constructor modifiers are assumed by synthetic:s</arg>
</args>
<jvmArgs>
<jvmArg>-Xmx${jvmArg-Xmx}</jvmArg>
Expand Down Expand Up @@ -422,7 +395,7 @@ limitations under the License.
<rudder-major-version>8.2</rudder-major-version>
<rudder-version>8.2.0~alpha1-SNAPSHOT</rudder-version>

<scala-version>2.13.12</scala-version>
<scala-version>2.13.14</scala-version>
<scala-binary-version>2.13</scala-binary-version>
<!-- lift force us to remain with 1.3.0 because of
java.lang.NoSuchMethodError: 'scala.collection.mutable.Stack scala.xml.parsing.NoBindingFactoryAdapter.scopeStack()'net.liftweb.util.Html5Parser.$anonfun$parse$1(HtmlParser.scala:373)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1600,7 +1600,7 @@ object JMachineInfo {
case JMachineType.PhysicalMachineType => Result.Value(PhysicalMachineType)
case JMachineType.VirtualMachineType =>
Result.fromEitherString(
jm.provider.traverse(VmType.parse).map(_.getOrElse(VmType.UnknownVmType)).map(VirtualMachineType)
jm.provider.traverse(VmType.parse).map(_.getOrElse(VmType.UnknownVmType)).map(VirtualMachineType.apply)
)
}
}
Expand Down Expand Up @@ -2019,16 +2019,6 @@ object NodeFactSerialisation {
.orElse(decoder)
)
}
//=======
// implicit val codecMachineUuid: JsonCodec[MachineUuid] = JsonCodec.string.transform[MachineUuid](MachineUuid(_), _.value)

// implicit val codecManufacturer: JsonCodec[Manufacturer] = JsonCodec.string.transform[Manufacturer](Manufacturer(_), _.name)
// implicit val codecMachine: JsonCodec[MachineInfo] = DeriveJsonCodec.gen
// implicit val codecMemorySize: JsonCodec[MemorySize] = JsonCodec.long.transform[MemorySize](MemorySize(_), _.size)
// implicit val codecSVersion: JsonCodec[SVersion] = JsonCodec.string.transform[SVersion](new SVersion(_), _.value)
// implicit val codecSoftwareEditor: JsonCodec[SoftwareEditor] =
// JsonCodec.string.transform[SoftwareEditor](SoftwareEditor(_), _.name)
//>>>>>>> branches/rudder/8.1
}

import SimpleCodec.*
Expand Down Expand Up @@ -2056,21 +2046,21 @@ object NodeFactSerialisation {
}
}

implicit val decoderJValue: JsonDecoder[JValue] = JsonDecoder[Option[Json]].map {
implicit lazy val decoderJValue: JsonDecoder[JValue] = JsonDecoder[Option[Json]].map {
case None => JNothing
case Some(v) => recJsonToJValue(v)
}
implicit val encoderJValue: JsonEncoder[JValue] = JsonEncoder[Option[Json]].contramap(recJValueToJson(_))
implicit val codecCustomProperty: JsonCodec[CustomProperty] = DeriveJsonCodec.gen
implicit lazy val encoderJValue: JsonEncoder[JValue] = JsonEncoder[Option[Json]].contramap(recJValueToJson(_))
implicit lazy val codecCustomProperty: JsonCodec[CustomProperty] = DeriveJsonCodec.gen

implicit val codecInputDevice: JsonCodec[InputDevice] = DeriveJsonCodec.gen
implicit val codecLocalGroup: JsonCodec[LocalGroup] = DeriveJsonCodec.gen
implicit val codecLocalUser: JsonCodec[LocalUser] = DeriveJsonCodec.gen
implicit val codecLogicalVolume: JsonCodec[LogicalVolume] = DeriveJsonCodec.gen
implicit val codecPhysicalVolume: JsonCodec[PhysicalVolume] = DeriveJsonCodec.gen
implicit lazy val codecInputDevice: JsonCodec[InputDevice] = DeriveJsonCodec.gen
implicit lazy val codecLocalGroup: JsonCodec[LocalGroup] = DeriveJsonCodec.gen
implicit lazy val codecLocalUser: JsonCodec[LocalUser] = DeriveJsonCodec.gen
implicit lazy val codecLogicalVolume: JsonCodec[LogicalVolume] = DeriveJsonCodec.gen
implicit lazy val codecPhysicalVolume: JsonCodec[PhysicalVolume] = DeriveJsonCodec.gen

implicit val codecSoftwareFact: JsonCodec[SoftwareFact] = DeriveJsonCodec.gen
implicit lazy val codecSoftwareFact: JsonCodec[SoftwareFact] = DeriveJsonCodec.gen

implicit val codecNodeFact: JsonCodec[NodeFact] = DeriveJsonCodec.gen
implicit lazy val codecNodeFact: JsonCodec[NodeFact] = DeriveJsonCodec.gen

}
Original file line number Diff line number Diff line change
Expand Up @@ -270,28 +270,26 @@ class NodeGroupUnserialisationImpl(
isSystem <- (group \ "isSystem").headOption.flatMap(s =>
tryo(s.text.toBoolean)
) ?~! ("Missing attribute 'isSystem' in entry type nodeGroup : " + entry)
properties <- traverse((group \ "properties" \ "property").toList) {
// format: off
case <property>{p @ _*}</property> =>
// format: on
val name = (p \\ "name").text.trim
if (name.trim.isEmpty) {
Failure(s"Found unexpected xml under <properties> tag (name is blank): ${p}")
} else {
GroupProperty
.parse(
(p \\ "name").text.trim,
ParseRev((p \\ "revision").text.trim),
StringEscapeUtils.unescapeXml((p \\ "value").text.trim): @nowarn(
"msg=class StringEscapeUtils in package lang3 is deprecated"
),
(p \\ "inheritMode").headOption.flatMap(p => InheritMode.parseString(p.text.trim).toOption),
(p \\ "provider").headOption.map(p => PropertyProvider(p.text.trim))
)
.toBox
}
case xml => Failure(s"Found unexpected xml under <properties> tag: ${xml}")
}
properties: Seq[GroupProperty] <- traverse(group \ "properties" \ "property") { p =>
val name = (p \ "name").text.trim
if (name.isEmpty) {
Failure(s"Found unexpected xml under <properties> tag (name is blank): ${p}")
} else {
GroupProperty
.parse(
name,
ParseRev((p \ "revision").text.trim),
StringEscapeUtils.unescapeXml((p \ "value").text.trim): @nowarn(
"msg=class StringEscapeUtils in package lang3 is deprecated"
),
(p \ "inheritMode").headOption.flatMap(p =>
InheritMode.parseString(p.text.trim).toOption
),
(p \ "provider").headOption.map(p => PropertyProvider(p.text.trim))
)
.toBox
}
}
} yield {
NodeGroup(
id = id,
Expand Down Expand Up @@ -855,10 +853,7 @@ class ApiAccountUnserialisationImpl extends ApiAccountUnserialisation {
Full(ApiAuthorization.RO)
case Some(Text(text)) if text == ApiAuthorizationKind.RW.name =>
Full(ApiAuthorization.RW)
// format: off
case Some(<acl>{xml @ _*}</acl>) if (xml.nonEmpty) =>
// format: on
unserAcl(xml.head)
case Some(xml @ <acl>{_*}</acl>) if xml.child.nonEmpty => unserAcl(xml.child.head)
// all other case: serialization pb => None
case _ => Full(ApiAuthorization.None)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ import org.joda.time.DateTime
import org.joda.time.Duration
import org.junit.runner.RunWith
import org.specs2.runner.JUnitRunner
import scala.annotation.nowarn
import scala.collection.SortedMap
import scala.concurrent.duration.FiniteDuration
import zio.*
Expand Down Expand Up @@ -178,7 +177,6 @@ class ReportingServiceTest extends DBCommon with BoxSpecMatcher {
def getGlobalUserCompliance()(implicit qc: QueryContext): Box[Option[(ComplianceLevel, Long)]] = null
def findUncomputedNodeStatusReports(): Box[Map[NodeId, NodeStatusReport]] = null

@nowarn("msg=parameter.*is never used")
def getUserNodeStatusReports()(implicit qc: QueryContext): Box[Map[NodeId, NodeStatusReport]] = Full(Map())
def getSystemAndUserCompliance(
optNodeIds: Option[Set[NodeId]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import com.normation.rudder.rest.lift.LiftApiProcessingLogger
import com.normation.zio.*
import net.liftweb.http.InMemoryResponse
import net.liftweb.http.LiftResponse
import scala.annotation.nowarn
import scala.collection.immutable
import zio.json.*
import zio.json.DeriveJsonEncoder
Expand Down Expand Up @@ -140,10 +139,9 @@ object RudderJsonResponse {

// rudder response. The "A" parameter is the business object (or list of it) in the response.
// Success
@nowarn("msg=parameter encoder .* is never used") // used by magnolia macro
def successOne[A](schema: ResponseSchema, obj: A, id: Option[String])(implicit
prettify: Boolean,
encoder: JsonEncoder[A]
encoder: JsonEncoder[A]
): LiftJsonResponse[? <: JsonRudderApiResponse[?]] = {
schema.dataContainer match {
case Some(key) =>
Expand All @@ -154,10 +152,9 @@ object RudderJsonResponse {
generic.success(JsonRudderApiResponse.success(schema, id, obj))
}
}
@nowarn("msg=parameter encoder .* is never used") // used by magnolia macro
def successList[A](schema: ResponseSchema, objs: List[A])(implicit
prettify: Boolean,
encoder: JsonEncoder[A]
encoder: JsonEncoder[A]
): LiftJsonResponse[
? <: JsonRudderApiResponse[? <: immutable.Iterable[Any] with PartialFunction[Int with String, Any] with Equals]
] = {
Expand Down Expand Up @@ -189,10 +186,9 @@ object RudderJsonResponse {
generic.internalError(JsonRudderApiResponse.error(id, schema, errorMsg))
}
// Internal error with a specific schema
@nowarn("msg=parameter encoder .* is never used") // used by magnolia macro
def internalError[A](id: Option[String], schema: ResponseSchema, obj: A, errorMsg: Option[String])(implicit
prettify: Boolean,
encoder: JsonEncoder[A]
encoder: JsonEncoder[A]
): LiftJsonResponse[? <: JsonRudderApiResponse[?]] = {
schema.dataContainer match {
case Some(key) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -867,10 +867,6 @@ class GroupApiService2(
change.copy(newGroup = change.newGroup.copy(_isEnabled = enableCheck))
}

case _ =>
Failure(
s"Could not create group '${name}' (id:${groupId.serialize}) based on an already existing group, cause is: too many values for source parameter."
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,6 @@ class Section2FieldService(val fieldFactory: DirectiveFieldFactory, val translat
priority match {
case LowDisplayPriority => false
case HighDisplayPriority => true
case _ => true
}
}
}
Loading