Changed serialization gradle plugin build to gradle
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
This commit is contained in:
+4
-15
@@ -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:
|
||||
|
||||
@@ -73,7 +60,7 @@ 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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,3 +68,5 @@ apply plugin: 'kotlin'
|
||||
apply plugin: 'kotlin-serialization'
|
||||
|
||||
```
|
||||
|
||||
You can also obtain it from bintray: https://bintray.com/kotlin/kotlinx/kotlinx.serialization
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,158 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<properties>
|
||||
<maven.version>3.0.4</maven.version>
|
||||
<serialization.src>${basedir}/../../../plugins/kotlin-serialization/kotlin-serialization-compiler/src</serialization.src>
|
||||
<serialization.gradle.plugin.src>${basedir}/src/main/kotlin</serialization.gradle.plugin.src>
|
||||
<serialization.gradle.plugin.resources>${basedir}/src/main/resources</serialization.gradle.plugin.resources>
|
||||
<serialization.target-src>${basedir}/target/src/main/kotlin</serialization.target-src>
|
||||
<serialization.target-resources>${basedir}/target/resource</serialization.target-resources>
|
||||
</properties>
|
||||
|
||||
<parent>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-project</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>org.jetbrains.kotlinx</groupId>
|
||||
<artifactId>kotlinx-serialization</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<description>Serialization plugin for Gradle</description>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jetbrains-utils</id>
|
||||
<url>http://repository.jetbrains.com/utils</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-compiler-embeddable</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-gradle-plugin-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>gradle-api</artifactId>
|
||||
<version>2.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>${serialization.target-src}</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${serialization.target-resources}</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-sources</id>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${serialization.target-src}</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${serialization.src}</directory>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>${serialization.gradle.plugin.src}</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>copy-resources</id>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${serialization.target-resources}/META-INF</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${serialization.src}/META-INF</directory>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>${serialization.gradle.plugin.resources}/META-INF</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.google.code.maven-replacer-plugin</groupId>
|
||||
<artifactId>replacer</artifactId>
|
||||
<version>1.5.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>replace</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<includes>
|
||||
<include>${serialization.target-src}/**</include>
|
||||
</includes>
|
||||
<replacements>
|
||||
<replacement>
|
||||
<token>(?<!\.)com\.intellij</token>
|
||||
<value>org.jetbrains.kotlin.com.intellij</value>
|
||||
</replacement>
|
||||
</replacements>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<version>${project.version}</version>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sourceDirs>
|
||||
<sourceDir>${serialization.target-src}</sourceDir>
|
||||
</sourceDirs>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
+1
-1
@@ -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)
|
||||
|
||||
@@ -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"
|
||||
@@ -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
|
||||
}
|
||||
+2
-1
@@ -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
|
||||
@@ -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()
|
||||
|
||||
+2
-3
@@ -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
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user