Skip to content

Commit

Permalink
Merge pull request #8 from SumoLogic/chris-scala-2-13
Browse files Browse the repository at this point in the history
Scala 2.13 support
  • Loading branch information
cddude229 authored Jul 3, 2020
2 parents 951f2e2 + 86e389b commit 015ac90
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Thumbs.db
*/build_2.10
*/build_2.11
*/build_2.12
*/build_2.13

# IntelliJ specific files/directories
out
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ trait ChainedProperty[TYPE] extends DynamicProperty[TYPE] {
* and so may not be null.
* @return the value derived from the chain of properties.
*/
override def get: TYPE = box.get
override def get(): TYPE = box.get

/**
* Produce the most-appropriate current value of the chain of properties, as an [[scala.Option]]. Null
Expand All @@ -52,14 +52,14 @@ trait ChainedProperty[TYPE] extends DynamicProperty[TYPE] {
* @param fn the transformation function which produces the new type.
* @return a new ChainedProperty for the target type.
*/
override def map[B](fn: (TYPE) => B)(implicit mapType: Manifest[B]): ChainedProperty[B] = new MapChainBy(box, fn, mapType)
override def map[B](fn: (TYPE) => B)(implicit mapType: Manifest[B]): ChainedProperty[B] = new MapChainBy(box, fn, mapType, this)

protected[this] class MapChainBy[B, TYPE](unmappedBox: ChainBox[TYPE, _], fn: (TYPE) => B, mapType: Manifest[B])
protected[this] class MapChainBy[B, TYPE](unmappedBox: ChainBox[TYPE, _], fn: (TYPE) => B, mapType: Manifest[B], self: ChainedProperty[TYPE])
extends ChainedProperty[B]
{
override protected val box = new ChainBoxConverter[B, TYPE](unmappedBox, fn, mapType)

override def propertyNames: Iterable[String] = propertyNames
override def propertyNames: Iterable[String] = self.propertyNames
}

/**
Expand Down Expand Up @@ -87,9 +87,9 @@ trait ChainedProperty[TYPE] extends DynamicProperty[TYPE] {
* changed.
* @param callback a [[java.lang.Runnable]] to call on changes.
*/
override def addCallback(callback: Runnable) {
override def addCallback(callback: Runnable): Unit = {
box.addCallback(callback)
}

override def toString: String = s"[${propertyName}] = ${get}"
override def toString: String = s"[$propertyName] = ${get()}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ trait DynamicProperty[T] {
* Remove all callbacks to be triggered when the value of the property is
* changed.
*/
def removeAllCallbacks() {
def removeAllCallbacks(): Unit = {
box.removeAllCallbacks()
}

override def toString: String = s"[${propertyName}] = ${get}"
override def toString: String = s"[$propertyName] = ${get()}"

protected val box: PropertyBox[T, _]
}
Expand All @@ -90,7 +90,7 @@ protected[scala] abstract class PropertyBox[T, JT] {
def addCallback(runnable: Runnable): Unit = {
prop.addCallback(runnable)
}
def removeAllCallbacks() {
def removeAllCallbacks(): Unit = {
prop.removeAllCallbacks()
}
protected def convert(jt: JT): T
Expand All @@ -110,7 +110,7 @@ protected[this] class BoxConverter[B, TYPE](propertyBox: PropertyBox[TYPE,AnyRef

override def get: B = fn(propertyBox.get)

override def addCallback(runnable: Runnable) {
override def addCallback(runnable: Runnable): Unit = {
propertyBox.addCallback(runnable)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ extends DynamicProperty[Set[String]]
{
override protected val box = new PropertyBox[Set[String], jSet[jString]] {
override val prop: Property[jSet[jString]]= new jDynamicStringSetProperty(propertyName, defaultValue.asJava, delimiterRegex)
def convert(jt: jSet[String]): Set[String] = jt.asScala.map(x => x)(scala.collection.breakOut)
def convert(jt: jSet[String]): Set[String] = jt.asScala.view.map(x => x).toSet
}
}
26 changes: 21 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ subprojects {
publications {
maven(MavenPublication) {
groupId = 'com.netflix.archaius'
version = '0.7.6.SUMO-5'
version = '0.7.6.SUMO-6'

artifact jar
artifact sourcesJar
Expand Down Expand Up @@ -157,7 +157,7 @@ project(':archaius-scala') {
dependencies {
compile project(':archaius-core')
compile 'org.scala-lang:scala-library:2.10.4'
testCompile 'org.scalatest:scalatest_2.10:3.0.2'
testCompile 'org.scalatest:scalatest_2.10:3.0.8'
testCompile 'junit:junit:4.11'
}
}
Expand All @@ -173,7 +173,7 @@ project(':archaius-scala_2.11') {
dependencies {
compile project(':archaius-core')
compile 'org.scala-lang:scala-library:2.11.11'
testCompile 'org.scalatest:scalatest_2.11:3.0.2'
testCompile 'org.scalatest:scalatest_2.11:3.0.8'
testCompile 'junit:junit:4.11'
}
}
Expand All @@ -188,8 +188,24 @@ project(':archaius-scala_2.12') {

dependencies {
compile project(':archaius-core')
compile 'org.scala-lang:scala-library:2.12.2'
testCompile 'org.scalatest:scalatest_2.12:3.0.2'
compile 'org.scala-lang:scala-library:2.12.11'
testCompile 'org.scalatest:scalatest_2.12:3.0.8'
testCompile 'junit:junit:4.11'
}
}

project(':archaius-scala_2.13') {
apply plugin: 'scala'

sourceCompatibility = 1.8
targetCompatibility = 1.8

buildDir = 'build_2.13'

dependencies {
compile project(':archaius-core')
compile 'org.scala-lang:scala-library:2.13.3'
testCompile 'org.scalatest:scalatest_2.13:3.0.8'
testCompile 'junit:junit:4.11'
}
}
Expand Down
4 changes: 3 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ include 'archaius-aws'
include 'archaius-scala'
include 'archaius-scala_2.11'
include 'archaius-scala_2.12'
include 'archaius-scala_2.13'
include 'archaius-zookeeper'
include 'archaius-etcd'
include 'archaius-typesafe'

project(':archaius-scala_2.11').projectDir=file("archaius-scala")
project(':archaius-scala_2.12').projectDir=file("archaius-scala")
project(':archaius-scala_2.11').projectDir=file("archaius-scala")
project(':archaius-scala_2.13').projectDir=file("archaius-scala")

0 comments on commit 015ac90

Please sign in to comment.