Skip to content

Commit

Permalink
Merge pull request owlike#122 from owlike/java8
Browse files Browse the repository at this point in the history
Updating Genson to target java 8 and stop support for scala 2.10 and adopt 2.12
  • Loading branch information
EugenCepoi authored May 11, 2018
2 parents 6299d11 + 556b393 commit ed60adc
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 35 deletions.
14 changes: 12 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,19 @@ sudo: false

language: java

cache:
directories:
- ~/.m2

addons:
apt:
packages:
- xsltproc
- xmlstarlet

jdk:
- openjdk7
- oraclejdk8

script:
# for now not testing the cross build because the used lib xmlstarlet is not available for install...
# - ./make-release.sh --command test --dirty-scm true
- mvn test
20 changes: 11 additions & 9 deletions genson-scala/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<description>Genson extension for Scala language</description>

<properties>
<scala.version>2.10</scala.version>
<scala.range.version>2.10.3</scala.range.version>
<scala.version>2.11</scala.version>
<scala.range.version>2.11.11</scala.range.version>
</properties>

<dependencies>
Expand All @@ -42,7 +42,7 @@
<dependency>
<groupId>org.json4s</groupId>
<artifactId>json4s-ast_${scala.version}</artifactId>
<version>3.2.10</version>
<version>3.2.11</version>
<optional>true</optional>
</dependency>

Expand All @@ -56,7 +56,7 @@
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_${scala.version}</artifactId>
<version>2.1.7</version>
<version>3.0.1</version>
<scope>test</scope>
</dependency>

Expand All @@ -71,9 +71,9 @@
<build>
<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.15.2</version>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.3.1</version>
<executions>
<execution>
<id>scala-doc</id>
Expand Down Expand Up @@ -104,8 +104,10 @@
</executions>
<configuration>
<sendJavaToScalac>false</sendJavaToScalac>
<scalaCompatVersion>${scala.version}</scalaCompatVersion>
<scalaVersion>${scala.range.version}</scalaVersion>
<args>
<arg>-target:jvm-1.6</arg>
<arg>-target:jvm-1.8</arg>
<arg>-feature</arg>
<arg>-unchecked</arg>
<arg>-deprecation</arg>
Expand All @@ -132,7 +134,7 @@
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_${scala.version}</artifactId>
<version>2.1.7</version>
<version>3.0.1</version>
</dependency>
</dependencies>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ private[genson] class ScalaBeanPropertyFactory(classloader: ClassLoader) extends
def createAccessor(name: String, field: Field, ofType: Type, genson: Genson): PropertyAccessor = {
fieldType(field, ofType)
.map(new FieldAccessor(name, field, _, field.getDeclaringClass))
.getOrElse(null)
.orNull
}

def createAccessor(name: String, method: Method, ofType: Type, genson: Genson): PropertyAccessor = {
ScalaReflectionApiLock.synchronized {
val sType = expandToJavaType(matchingMethod(method).returnType, ofType)
sType.map(new MethodAccessor(name, method, _, method.getDeclaringClass))
.getOrElse(null)
.orNull
}
}

Expand Down Expand Up @@ -71,13 +71,13 @@ private[genson] class ScalaBeanPropertyFactory(classloader: ClassLoader) extends
}

def createMutator(name: String, field: Field, ofType: Type, genson: Genson): PropertyMutator = {
fieldType(field, ofType).map(new FieldMutator(name, field, _, field.getDeclaringClass)).getOrElse(null)
fieldType(field, ofType).map(new FieldMutator(name, field, _, field.getDeclaringClass)).orNull
}

def createMutator(name: String, method: Method, ofType: Type, genson: Genson): PropertyMutator = {
ScalaReflectionApiLock.synchronized {
val sType = expandToJavaType(matchingMethod(method).paramss.flatten.head, ofType)
sType.map(new MethodMutator(name, method, _, method.getDeclaringClass)).getOrElse(null)
sType.map(new MethodMutator(name, method, _, method.getDeclaringClass)).orNull
}
}

Expand Down
17 changes: 15 additions & 2 deletions genson-scala/src/main/scala/com/owlike/genson/ScalaGenson.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.owlike.genson

import java.lang.reflect.{Type => JType, GenericDeclaration, TypeVariable, GenericArrayType, ParameterizedType}
import java.lang.reflect.{AnnotatedType, GenericArrayType, GenericDeclaration, ParameterizedType, TypeVariable, Type => JType}
import java.io.{Reader => JReader, _}
import java.lang.annotation.Annotation
import java.net.URL

import com.owlike.genson.reflect.TypeUtil._
import com.owlike.genson.stream.{ObjectWriter, ObjectReader}
import com.owlike.genson.stream.{ObjectReader, ObjectWriter}

class ScalaGenson(val genson: Genson) extends AnyVal {

Expand Down Expand Up @@ -62,6 +63,18 @@ private[genson] class ScalaTypeVariable(name: String, bounds: Array[JType], decl
def getGenericDeclaration: Class[_] = decl

def getName: String = name

override def getAnnotatedBounds: Array[AnnotatedType] = reportUnsupportedOperation

override def getDeclaredAnnotations: Array[Annotation] = reportUnsupportedOperation

override def getAnnotation[T <: Annotation](annotationClass: Class[T]): T = reportUnsupportedOperation

override def getAnnotations: Array[Annotation] = reportUnsupportedOperation

private def reportUnsupportedOperation = {
throw new UnsupportedOperationException("Please report this stacktrace at https://github.com/owlike/genson/issues")
}
}

private[genson] class ScalaGenericArrayType(componentType: JType) extends GenericArrayType {
Expand Down
8 changes: 4 additions & 4 deletions make-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ function checkNoUncommitedChanges {

function createScalaProject {
local SCALA_VERSION=$1
local SCALA_NEXT_VERSION=$2
local SCALA_RANGE_VERSION="$SCALA_VERSION.0"
local SCALA_MINOR_VERSION=$2
local SCALA_RANGE_VERSION="$SCALA_VERSION.$SCALA_MINOR_VERSION"
local SCALA_PROJECT="genson-scala_$SCALA_VERSION"

cp -R genson-scala $SCALA_PROJECT
Expand Down Expand Up @@ -155,8 +155,8 @@ function prepareFromRemote {
function prepareProjects {
sed -i '' "s/<module>genson-scala<\/module>//" pom.xml

createScalaProject 2.10
createScalaProject 2.11
createScalaProject 2.11 11
createScalaProject 2.12 4
}

#######################################################################################################################
Expand Down
18 changes: 8 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,15 @@
<project.build.resourceEncoding>UTF-8</project.build.resourceEncoding>
<maven.compile.encoding>UTF-8</maven.compile.encoding>


<!--
Required to build using JDK 8, unless all JavaDoc is revamped to handle
the stricter DocLint enabled within JDK 8.
-->
<additionalparam>-Xdoclint:none</additionalparam>

<!-- Be clear about the required JDK build version. -->
<jdk.version>1.6</jdk.version>
<jdk.version>1.8</jdk.version>

</properties>

Expand Down Expand Up @@ -169,15 +176,6 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.0</version>

<!--
Required to build using JDK 8, unless all JavaDoc is revamped to handle
the stricter DocLint enabled within JDK 8.
-->
<!-- configuration>
<additionalOptions>-Xdoclint:none</additionalOptions>
</configuration -->

<executions>
<execution>
<id>attach-javadocs</id>
Expand Down
11 changes: 11 additions & 0 deletions website/Documentation/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
title: Changelog
layout: default
---
##Release 1.5 - Upcoming

**Core**

* Starting with release 1.5 Genson requires Java 8+


**Scala**

* Starting with release 1.5, Scala 2.10 is no longer supported. Genson is cross built for Scala 2.11 ans 2.12

##Release 1.4 - 27 March 2016

**Core**
Expand Down
9 changes: 5 additions & 4 deletions website/Documentation/ScalaGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ val actualValue = fromJson[SomeType](json)

###Scala version

Genson has been tested against scala 2.10 and 2.11. In theory you can use it with all releases from 2.10 and up.
We follow the standard cross build conventions for scala projects ex: genson-scala_2.10 and genson-scala_2.11.
Genson has been tested against scala 2.11 and 2.12. In theory you can use it with all releases from 2.11 and up.
We follow the standard cross build conventions for scala projects ex: genson-scala_2.11 and genson-scala_2.12.
If you need support for Scala 2.10, you will need to look at the older releases of Genson pre 1.5.


##Download
Expand Down Expand Up @@ -60,8 +61,8 @@ If you don't use a dependency management tool then you can still use it, but you
the core Genson jars by hand.

* [Genson](http://repo1.maven.org/maven2/com/owlike/genson/{{site.latest_version}}/genson-{{site.latest_version}}.jar)
* [Genson-scala_2.10](http://repo1.maven.org/maven2/com/owlike/genson-scala_2.10/{{site.latest_version}}/genson-scala_2.10-{{site.latest_version}}.jar)
* [Genson-scala_2.11](http://repo1.maven.org/maven2/com/owlike/genson-scala_2.11/{{site.latest_version}}/genson-scala_2.11-{{site.latest_version}}.jar)
* [Genson-scala_2.10](http://repo1.maven.org/maven2/com/owlike/genson-scala_2.11/{{site.latest_version}}/genson-scala_2.11-{{site.latest_version}}.jar)
* [Genson-scala_2.11](http://repo1.maven.org/maven2/com/owlike/genson-scala_2.12/{{site.latest_version}}/genson-scala_2.12-{{site.latest_version}}.jar)


##Collections & Tuples
Expand Down

0 comments on commit ed60adc

Please sign in to comment.