-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
JAVA-5452 #1378
base: scala3
Are you sure you want to change the base?
JAVA-5452 #1378
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
vbabanin marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright 2008-present MongoDB, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import config.Extensions.scalaVersion | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some |
||
import config.Extensions.setAll | ||
|
||
plugins { id("conventions.scala") } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Main scala configuration is done by using |
||
|
||
base.archivesName.set("mongo-scala-bson") | ||
|
||
val scalaVersion: String = project.scalaVersion() | ||
|
||
extra.setAll( | ||
mapOf( | ||
"mavenName" to "Mongo Scala Bson Library", | ||
"mavenDescription" to "A Scala wrapper / extension to the bson library", | ||
"automaticModuleName" to "org.mongodb.bson.scala", | ||
"importPackage" to "!scala.*, *", | ||
jyemin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"scalaVersion" to scalaVersion, | ||
"mavenArtifactId" to "${base.archivesName.get()}_${scalaVersion}")) | ||
|
||
dependencies { implementation(project(path = ":bson", configuration = "default")) } | ||
|
||
// ============================================ | ||
// Scala version specific configuration | ||
// ============================================ | ||
when (scalaVersion) { | ||
"2.13" -> { | ||
dependencies { | ||
implementation(libs.bundles.scala.v2.v13) | ||
|
||
testImplementation(libs.bundles.scala.test.v2.v13) | ||
} | ||
sourceSets { main { scala { setSrcDirs(listOf("src/main/scala", "src/main/scala-2.13")) } } } | ||
} | ||
"2.12" -> { | ||
dependencies { | ||
implementation(libs.bundles.scala.v2.v12) | ||
|
||
testImplementation(libs.bundles.scala.test.v2.v12) | ||
} | ||
sourceSets { main { scala { setSrcDirs(listOf("src/main/scala", "src/main/scala-2.12")) } } } | ||
} | ||
"2.11" -> { | ||
dependencies { | ||
implementation(libs.bundles.scala.v2.v11) | ||
|
||
testImplementation(libs.bundles.scala.test.v2.v11) | ||
} | ||
sourceSets { main { scala { setSrcDirs(listOf("src/main/scala", "src/main/scala-2.12")) } } } | ||
jyemin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,10 +15,7 @@ | |
*/ | ||
package org.mongodb.scala.bson | ||
|
||
import org.junit.runner.RunWith | ||
import org.scalatest.flatspec.AnyFlatSpec | ||
import org.scalatest.matchers.should.Matchers | ||
import org.scalatestplus.junit.JUnitRunner | ||
|
||
@RunWith(classOf[JUnitRunner]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No longer needed thanks to the scala test configurations done in the scala convention. |
||
abstract class BaseSpec extends AnyFlatSpec with Matchers {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -530,6 +530,7 @@ class MacrosSpec extends BaseSpec { | |
} | ||
|
||
it should "support tagged types in case classes" in { | ||
assume(!scala.util.Properties.versionNumberString.startsWith("2.11")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is failing to compile with Scala 2.11 - not sure how it worked with the previous plugin as its a scala error. Its possible that we are using a newer scala 2.11 version patch which highlights this error. As Scala 2.11 has been EOL for a long time so I'm not sure its worth investigating further. |
||
val a = 1.asInstanceOf[Int with Tag] | ||
val b = "b".asInstanceOf[String with Tag] | ||
val c = Map("c" -> 0).asInstanceOf[Map[String with Tag, Int with Tag] with Tag] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,7 +87,15 @@ public static Map<Path, BsonDocument> testDocs(final Path dir) { | |
|
||
public static List<File> getTestFiles(final String resourcePath) throws URISyntaxException { | ||
List<File> files = new ArrayList<>(); | ||
addFilesFromDirectory(new File(JsonPoweredTestHelper.class.getResource(resourcePath).toURI()), files); | ||
|
||
URL resource = JsonPoweredTestHelper.class.getResource(resourcePath); | ||
File directory; | ||
try { | ||
directory = new File(resource.toURI()); | ||
} catch (IllegalArgumentException e) { | ||
directory = new File(resource.toExternalForm()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resources may now come from test jars so use the external form in that case.
jyemin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
addFilesFromDirectory(directory, files); | ||
return files; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,68 +106,6 @@ configure(javaProjects) { | |
|
||
} | ||
|
||
configure(scalaProjects) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The root build.gradle no longer handles the configuration of scala projects. |
||
apply plugin: 'scala' | ||
apply plugin: 'idea' | ||
apply plugin: "com.adtran.scala-multiversion-plugin" | ||
apply plugin: "com.diffplug.spotless" | ||
|
||
group = 'org.mongodb.scala' | ||
|
||
dependencies { | ||
implementation ('org.scala-lang:scala-library:%scala-version%') | ||
implementation ('org.scala-lang:scala-reflect:%scala-version%') | ||
|
||
testImplementation(platform("org.junit:junit-bom:$junitBomVersion")) | ||
testImplementation("org.junit.vintage:junit-vintage-engine") | ||
|
||
testImplementation('org.scalatest:scalatest-flatspec_%%:3.2.9') | ||
testImplementation('org.scalatest:scalatest-shouldmatchers_%%:3.2.9') | ||
testImplementation('org.scalatestplus:junit-4-13_%%:3.2.9.0') | ||
testImplementation('org.scalatestplus:mockito-3-12_%%:3.2.10.0') | ||
testImplementation('ch.qos.logback:logback-classic:1.1.3') | ||
testImplementation('org.reflections:reflections:0.9.10') | ||
} | ||
|
||
test{ | ||
useJUnitPlatform { | ||
includeEngines('junit-jupiter', 'junit-vintage') | ||
} | ||
} | ||
|
||
spotless { | ||
scala { | ||
scalafmt().configFile("$configDir/scala/scalafmt.conf") | ||
} | ||
} | ||
compileScala.dependsOn('spotlessApply') | ||
compileTestScala.dependsOn('spotlessApply') | ||
|
||
tasks.withType(ScalaCompile) { | ||
scalaCompileOptions.deprecation = false | ||
if(scalaVersion.startsWith("2.11")) { | ||
scalaCompileOptions.additionalParameters = [ | ||
// support static methods in interfaces | ||
"-target:jvm-1.8" | ||
] | ||
} | ||
if(scalaVersion.startsWith("2.13")) { | ||
scalaCompileOptions.additionalParameters = [ | ||
"-feature", | ||
"-unchecked", | ||
"-language:reflectiveCalls", | ||
"-Wconf:cat=deprecation:ws,any:e", | ||
"-Xlint:strict-unsealed-patmat" | ||
] | ||
} | ||
|
||
} | ||
|
||
tasks.withType(GenerateModuleMetadata) { | ||
enabled = false | ||
} | ||
} | ||
|
||
configure(javaMainProjects) { | ||
apply plugin: 'nebula.optional-base' | ||
apply plugin: 'java-library' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright 2008-present MongoDB, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed | ||
plugins { | ||
`kotlin-dsl` | ||
// When updating, update in libs.versions.toml | ||
id("com.diffplug.spotless") version "6.25.0" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The buildSrc project also uses spotless for formatting. Unfortunately, at the plugin stage we can't access the version from |
||
} | ||
|
||
repositories { | ||
gradlePluginPortal() | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation(libs.spotless.plugin) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Conventions now configure the spotless and logger plugins for the projects that use them. |
||
implementation(libs.test.logger.plugin) | ||
|
||
// https://github.com/gradle/gradle/issues/15383 | ||
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location)) | ||
} | ||
|
||
spotless { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The spotless configuration for |
||
kotlinGradle { | ||
ktfmt("0.39").dropboxStyle().configure { it.setMaxWidth(120) } | ||
trimTrailingWhitespace() | ||
indentWithSpaces() | ||
endWithNewline() | ||
target("./**/*.gradle.kts", "./**/*.kt") | ||
licenseHeaderFile("../config/mongodb.license", "package ") | ||
} | ||
} | ||
|
||
tasks.withType<GradleBuild> { dependsOn("spotlessApply") } |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,22 +13,13 @@ | |
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
@Suppress("UnstableApiUsage") | ||
dependencyResolutionManagement { versionCatalogs { create("libs") { from(files("../gradle/libs.versions.toml")) } } } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Allows access from within the convention to the |
||
|
||
include ':bson' | ||
include ':bson-record-codec' | ||
include ':driver-benchmarks' | ||
include ':driver-workload-executor' | ||
include ':driver-lambda' | ||
include ':driver-core' | ||
include ':driver-legacy' | ||
include ':driver-sync' | ||
include ':driver-reactive-streams' | ||
include ':bson-kotlin' | ||
include ':bson-kotlinx' | ||
include ':driver-kotlin-sync' | ||
include ':driver-kotlin-coroutine' | ||
include ':bson-scala' | ||
include ':driver-scala' | ||
include 'util:spock' | ||
include 'util:taglets' | ||
include ':graalvm-native-image-app' | ||
pluginManagement { | ||
repositories { | ||
gradlePluginPortal() | ||
google() | ||
mavenCentral() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
libs.versions.toml
now handles the scala library versioning. So this is now just for which scala release to test against.