Common library for JVM and JS
diff --git a/build.gradle b/build.gradle
index a3350b4..fa58e7a 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,5 +1,6 @@
 buildscript {
     ext.snapshot_version = '1.1-SNAPSHOT'
+    ext.kotlinVersion = ext.snapshot_version
 
     repositories {
         mavenLocal()
@@ -13,73 +14,53 @@
     }
 }
 
-group 'org.jetbrains.kotlinx'
-version "$snapshot_version"
+ext {
+    libraries = [
+            kotlin_stdlib: "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion",
+            kotlin_stdlib_common: "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlinVersion",
+            kotlin_stdlib_js: "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlinVersion",
+            kotlin_test: "org.jetbrains.kotlin:kotlin-test:$kotlinVersion",
+            kotlin_test_common: "org.jetbrains.kotlin:kotlin-test-common:$kotlinVersion",
+            kotlin_test_js: "org.jetbrains.kotlin:kotlin-test-js:$kotlinVersion",
+            kotlin_reflect: "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion",
+    ]
+}
+
+allprojects {
+    group 'org.jetbrains.kotlinx'
+    version "$snapshot_version"
+}
 
 apply plugin: 'kotlin'
-apply plugin: 'kotlin-serialization'
 
-repositories {
-    mavenLocal()
-    mavenCentral()
-}
+configure([project(':jvm'), project(':js')]) {
+    apply plugin: 'kotlin-serialization'
 
-apply plugin: 'maven-publish'
+    apply plugin: 'maven-publish'
 
-task sourceJar(type: Jar, dependsOn: classes) {
-    classifier 'sources'
-    from sourceSets.main.allSource
-}
+    def varintName = "${rootProject.name}-${project.name}"
 
-publishing {
-    publications {
-        mavenJava(MavenPublication) {
-            from components.java
+    task sourceJar(type: Jar, dependsOn: classes) {
+        classifier 'sources'
+        from sourceSets.main.allSource
+    }
 
+    tasks.withType(Jar) {
+        archivesBaseName = varintName
+    }
 
-            artifact sourceJar {
-                classifier "sources"
+    publishing {
+        publications {
+            mavenJava(MavenPublication) {
+                from components.java
+                groupId project.group
+                artifactId varintName
+                version project.version
+
+                artifact sourceJar {
+                    classifier "sources"
+                }
             }
         }
     }
-}
-
-apply plugin: 'com.google.protobuf'
-
-protobuf {
-    protoc {
-        // Download from repositories
-        artifact = 'com.google.protobuf:protoc:3.0.0'
-    }
-}
-
-test {
-    dependsOn 'generateTestProto'
-}
-
-clean {
-    delete protobuf.generatedFilesBaseDir
-}
-
-sourceSets {
-    test {
-        java {
-            srcDirs += file("${protobuf.generatedFilesBaseDir}/test/java")
-        }
-    }
-}
-
-
-dependencies {
-    compile "org.jetbrains.kotlin:kotlin-stdlib:${snapshot_version}"
-    compile "org.jetbrains.kotlin:kotlin-reflect:${snapshot_version}"
-
-    testCompile group: 'junit', name: 'junit', version: '4.4'
-    testCompile 'io.kotlintest:kotlintest:2.0.4'
-
-    testCompile 'com.google.protobuf:protobuf-java:3.0.0'
-    testCompile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.8.9'
-    testCompile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.9'
-    testCompile group: 'com.fasterxml.jackson.module', name: 'jackson-module-kotlin', version: '2.8.9'
-    testCompile group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-cbor', version: '2.8.9'
 }
\ No newline at end of file