Skip to content
This repository has been archived by the owner on Aug 19, 2020. It is now read-only.

Sample for building multi platform projects #800

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Sample for building multi platform projects #800

wants to merge 3 commits into from

Conversation

neonailol
Copy link

Context

This is a full sample of building the multiplatform kotlin project (common, js, jvm. native)

  • common module with shared logic, and expected declarations, and shared test cases
  • js module, with actual implementation, and set up testing environment via node and quint
  • jvm module, with actual implementation, and set up testing environment via testng
  • native module, with actual implementation, and set up testing environment via application build

Contributor Checklist

  • Base the PR against the develop branch
  • Make sure that all commits are signed off to indicate that you agree to the terms of Developer Certificate of Origin.
  • Provide integration tests to verify changes from a user perspective
  • Provide unit tests to verify logic
  • Ensure that tests pass locally: ./gradlew check --parallel


dependencies {
classpath(kotlin("gradle-plugin", "1.2.31"))
classpath(kotlin("native-gradle-plugin", "0.6.2"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the plugins{} block for these dependencies

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea how to move these into plugins block, it just breaks the build for me

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
base
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why using base? 🤔

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without it "archives" task do not work

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
}

allprojects {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is all that "boilerplate" really needed?
I think it would be good to define everything in their build.gradle files. Instead of the project build.gradle file..

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better apply it once for all project


repositories {
mavenCentral()
jcenter()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't mirror jcenter mavencentral?
So jcenter() is enough, right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is


tasks.withType<Wrapper> {
distributionType = Wrapper.DistributionType.ALL
gradleVersion = "4.6"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the latest version: 4.7
(and update the wrapper, of course)


dependencies {
"expectedBy"(project(":platform-common"))
"implementation"(kotlin("stdlib-js"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why using "xx" instead of dirctly the method implementation(kotlin(...)?

Copy link
Author

@neonailol neonailol May 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intellij breaks time to time when it's defined without quotes
also for some reaseon in native project it does not understand expectedBy without quotes

}

dependencies {
"expectedBy"(project(":platform-common"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@@ -0,0 +1,18 @@
import org.gradle.internal.impldep.bsh.commands.dir
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is that needed?

@@ -0,0 +1,31 @@
import org.jetbrains.kotlin.gradle.plugin.KonanArtifactContainer

apply {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to use one code style. With the plugins {} block

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea how to move this intro plugins block

pluginManagement {
repositories {
gradlePluginPortal()
google()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need google()?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just leftover from tying to add android as a platform

@neonailol
Copy link
Author

@StefMa updated pr, please look at it when you have time

@eskatos eskatos changed the base branch from develop to master April 25, 2019 14:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants