Skip to content

Commit

Permalink
Changed serialization gradle plugin build to gradle
Browse files Browse the repository at this point in the history
Env variable for idea SDK on TeamCity
Fix kotlin_root dir relative path

Updated broken API after rebase to 1.1.50

Bintray upload setup
  • Loading branch information
sandwwraith committed Sep 7, 2018
1 parent ef11fb5 commit 8cacaec
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 182 deletions.
19 changes: 4 additions & 15 deletions libraries/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,7 @@ If your maven build is failing with Out-Of-Memory errors, set JVM options for ma

## Kotlin serialization Gradle Plugin

To build it, first **build all the above** and then, `cd` to `tools/kotlin-serialization`
and run `mvn install`

So, all build sequence will look like:

```bash
# Assuming you are in the kotlin/libraries folder
./gradlew build install
mvn install
cd tools/gradle-tools
./gradlew clean install
cd ../kotlin-serialization
mvn install
```
First, build all the above. Then run `./gradlew :kotlin-serialization:install` to install it to your local maven repository.

When it is installed in local maven repository, you can add it as a dependency in buildscript classpath and apply it:

Expand All @@ -73,11 +60,13 @@ buildscript {
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.1-SNAPSHOT"
classpath "org.jetbrains.kotlinx:kotlinx-serialization:1.1-SNAPSHOT"
classpath "org.jetbrains.kotlinx:kotlin-serialization:0.1"
}
}
apply plugin: 'kotlin'
apply plugin: 'kotlin-serialization'
```

You can also obtain it from bintray: https://bintray.com/kotlin/kotlinx/kotlinx.serialization
68 changes: 68 additions & 0 deletions libraries/tools/kotlin-serialization/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
plugins {
id "com.jfrog.bintray" version "1.7.3"
}

group = 'org.jetbrains.kotlinx'
version = '0.1'

apply plugin: 'kotlin'

configureJvmProject(project)

compileJava {
sourceCompatibility = 1.8
targetCompatibility = 1.8
options.fork = false
}

repositories {
mavenLocal()
jcenter()
maven { url 'http://repository.jetbrains.com/utils' }
}

dependencies {
compileOnly project(':kotlin-gradle-plugin-api')

compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlin_version"

compileOnly 'org.jetbrains.kotlin:gradle-api:1.6'
}

def originalSrc = "$kotlin_root/plugins/kotlin-serialization/kotlin-serialization-compiler/src"
def targetSrc = file("$buildDir/kotlin-serialization-target-src")

task preprocessSources(type: Copy) {
from originalSrc
into targetSrc
filter { it.replaceAll('(?<!\\.)com\\.intellij', 'org.jetbrains.kotlin.com.intellij') }
}

sourceSets.main.java.srcDirs += targetSrc

compileKotlin.dependsOn preprocessSources

jar {
from(targetSrc) { include("META-INF/**") }
}

bintray {
user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
configurations = ['archives']
pkg {
repo = 'kotlinx'
name = 'kotlinx.serialization'
userOrg = 'kotlin'
licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/JetBrains/kotlin/tree/rr/kotlinx.serialization/libraries'
websiteUrl = 'https://github.com/Kotlin/kotlinx.serialization'
issueTrackerUrl = 'https://github.com/Kotlin/kotlinx.serialization/issues'

githubRepo = 'JetBrains/kotlin'
version {
name = project.version
}
}
}
158 changes: 0 additions & 158 deletions libraries/tools/kotlin-serialization/pom.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class SerializationGradleSubplugin : Plugin<Project> {
class SerializationKotlinGradleSubplugin : KotlinGradleSubplugin<AbstractCompile> {
companion object {
val SERIALIZATION_GROUP_NAME = "org.jetbrains.kotlinx"
val SERIALIZATION_ARTIFACT_NAME = "kotlinx-serialization"
val SERIALIZATION_ARTIFACT_NAME = "kotlin-serialization"
}

override fun isApplicable(project: Project, task: AbstractCompile) = SerializationGradleSubplugin.isEnabled(project)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
buildscript {
ext {
kotlin_root = "$rootDir/../../../"
kotlin_root = file("$rootDir/../../..")
distDir = file("$kotlin_root/dist")
bootstrapCompilerFile = file("$distDir/kotlin-compiler-for-maven.jar")
kotlin_version = "1.1.3"
Expand Down Expand Up @@ -57,7 +57,9 @@ jar {
apply plugin: 'org.jetbrains.intellij'

intellij {
localPath "$kotlin_root/ideaSDK"
if (findProperty("noIdeaSDK") == null) {
localPath "$kotlin_root/ideaSDK"
}
pluginName 'Kotlin-serialization'
downloadSources false
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import org.jetbrains.kotlin.js.translate.general.Translation
import org.jetbrains.kotlin.js.translate.utils.JsAstUtils
import org.jetbrains.kotlin.js.translate.utils.TranslationUtils
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.KtProperty
import org.jetbrains.kotlin.psi.KtPureClassOrObject
import org.jetbrains.kotlinx.serialization.compiler.backend.common.SerializableCodegen
import org.jetbrains.kotlinx.serialization.compiler.backend.common.anonymousInitializers
Expand Down Expand Up @@ -83,7 +84,7 @@ class SerializableJsTranslator(val declaration: KtPureClassOrObject,

//transient initializers and init blocks
val serialDescs = properties.serializableProperties.map { it.descriptor }
(initMap - serialDescs).forEach { desc, expr ->
(initMap - serialDescs).forEach { (desc, expr) ->
val e = requireNotNull(expr) {"transient without an initializer"}
val initExpr = Translation.translateAsExpression(e, context)
+TranslationUtils.assignmentToBackingField(context, desc, initExpr).makeStmt()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import org.jetbrains.kotlin.js.translate.declaration.DefaultPropertyTranslator
import org.jetbrains.kotlin.js.translate.general.Translation
import org.jetbrains.kotlin.js.translate.utils.JsAstUtils
import org.jetbrains.kotlin.js.translate.utils.TranslationUtils
import org.jetbrains.kotlin.js.translate.utils.TranslationUtils.shouldBoxReturnValue
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.KtPureClassOrObject
import org.jetbrains.kotlin.resolve.descriptorUtil.classId
Expand Down Expand Up @@ -260,10 +259,10 @@ class SerializerJsTranslator(declaration: KtPureClassOrObject,
).makeStmt()
}
// char unboxing crutch
if (KotlinBuiltIns.isCharOrNullableChar(property.type) && !shouldBoxReturnValue(property.descriptor.getter)) {
if (KotlinBuiltIns.isCharOrNullableChar(property.type)) {
+JsAstUtils.assignment(
localProps[i],
Translation.unboxIfNeeded(context, localProps[i], true)
TranslationUtils.coerce(context, localProps[i], TranslationUtils.getReturnTypeForCoercion(property.descriptor.getter!!))
).makeStmt()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ class SerializableCodegenImpl(
val serializedProps = properties.serializableProperties.map { it.descriptor }

(descToProps - serializedProps)
.forEach { _, prop -> classCodegen.initializeProperty(exprCodegen, prop) }
.forEach { (_, prop) -> classCodegen.initializeProperty(exprCodegen, prop) }
(paramsToProps - serializedProps)
.forEach { t, u -> exprCodegen.genInitParam(t, u) }
.forEach { (t, u) -> exprCodegen.genInitParam(t, u) }

// init blocks
// todo: proper order with other initializers
Expand Down

0 comments on commit 8cacaec

Please sign in to comment.