Discussion:
[ceylon-dev] Ceylon on Android news
Stephane Epardaud
2016-03-02 17:30:48 UTC
Permalink
Hi,

I have been working on getting Ceylon applications to run on Android, and
while it's very early and rough, it's at a point where I can start
accepting testers and contributions. I have been able to create a working
APK written entirely in Ceylon, with Maven interop, using Gradle for
building it.

How can you test this?
===

Checkout the `android` branch of the Ceylon distribution (
https://github.com/ceylon/ceylon) and build your distribution with `ant
clean dist`. It's a bit behind `master`, but not by much. Warning: this
branch will be forcibly rewritten as its commit history is crap and
temporary. It's also only been tested for Android and it will likely just
break if you try to use it outside of Android building. Naturally all that
will be fixed in due time. This is bleeding edge, remember?

Get the Ceylon/Android Gradle plugin at
https://github.com/ceylon/ceylon-gradle-android and try it out.

You will need to edit the
`com.redhat.ceylon.gradle.android.MyCeylonCompileTask` class to change `
/home/stephane/src/java-eclipse/ceylon/dist/dist/bin/ceylon`to point to
your distribution (of course it will be configurable later).

Because it has a `sample-app` that depends on the Gradle plugin being
built, you will need to comment out the `include 'sample-app'`line in
`settings.gradle` until you've built the plugin first with:

`$ ANDROID_HOME=.../Android/Sdk/ ./gradlew :android:build`

Now you can uncomment that line back in `settings.gradle` and build your
sample app with:

`$ ANDROID_HOME=.../Android/Sdk/ ./gradlew assembleDebug`

And stuff it onto your emulator with:

`$ .../Android/Sdk/tools/android avd &`
`$ .../Android/Sdk/platform-tools/adb install -r
sample-app/build/outputs/apk/sample-app-debug.apk`

What I did so far
===
- added a `--jdk-provider` flag to the compiler which takes a module that
contains the Jdk, and treats it as the source for the Jdk you target. You
point it to your android module and it will figure out which Jdk modules it
contains from there, allowing you to resolve `java.base/7` from it instead
of from the running Jdk.
- started fixing `import-jar` to deal with transitive dependencies, so we
can import the android jar and whatever dependencies are declared in the
Gradle build (which come from the Android Sdk Maven repo)
- hacked `jigsaw create-mlib` to generate a `ceylon.metamodel` file which
describes the metamodel statically, so that at run-time the metamodel gets
initialised with this. This will move to a more appropriate command
- got the Gradle plugin to:
a/ import the Maven (aar file types mostly, which the Android Gradle
plugin unpacks for us) modules into a Ceylon repo
b/ compile our Ceylon module with that repo configured, and the generated
source paths (containing `R.java`) configured too
c/ generate a list of jars required by our Ceylon modules (as in, the
Ceylon runtime) and static metamodel file
d/ pass on that list (minus those already found by Gradle) to the Android
Gradle build so it can dex them and include them in the Apk

What remains to be done
===

- clean up and polish
- support variants and flavours in the Gradle plugin
- properly set up input/output and incremental build in the Gradle plugin
- make the Gradle plugin configurable
- very likely make the Gradle plugin use the Gradle Ceylon plugin Renato
wrote, not sure how
- deal with `java.lang::CharSequence` because Android seems to use this a
lot
- add `--exclude` to `jigsaw create-mlib`
- trim module dependencies in dist to reduce runtime footprint

What feedback/help you can give
===

If you know Gradle, please help improve my plugin, it's currently working
but not well written at all, and not complete or configurable.

If you know Android: try out the same app, try adding more Android typical
features to it, see where we need to improve support for both Ceylon and
the Gradle plugin.
--
Stéphane Épardaud
--
You received this message because you are subscribed to the Google Groups "ceylon-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceylon-dev+***@googlegroups.com.
To post to this group, send email to ceylon-***@googlegroups.com.
Visit this group at https://groups.google.com/group/ceylon-dev.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceylon-dev/CAKU9E9uBVyh8QsiL76G-SjXsANg%3DyPb4D_xmGB9L-LQKzRmv8g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Gavin King
2016-03-02 23:24:24 UTC
Permalink
Progress! :-)

On Wed, Mar 2, 2016 at 6:30 PM, Stephane Epardaud
Post by Stephane Epardaud
Hi,
I have been working on getting Ceylon applications to run on Android, and
while it's very early and rough, it's at a point where I can start accepting
testers and contributions. I have been able to create a working APK written
entirely in Ceylon, with Maven interop, using Gradle for building it.
How can you test this?
===
Checkout the `android` branch of the Ceylon distribution
(https://github.com/ceylon/ceylon) and build your distribution with `ant
clean dist`. It's a bit behind `master`, but not by much. Warning: this
branch will be forcibly rewritten as its commit history is crap and
temporary. It's also only been tested for Android and it will likely just
break if you try to use it outside of Android building. Naturally all that
will be fixed in due time. This is bleeding edge, remember?
Get the Ceylon/Android Gradle plugin at
https://github.com/ceylon/ceylon-gradle-android and try it out.
You will need to edit the
`com.redhat.ceylon.gradle.android.MyCeylonCompileTask` class to change
`/home/stephane/src/java-eclipse/ceylon/dist/dist/bin/ceylon`to point to
your distribution (of course it will be configurable later).
Because it has a `sample-app` that depends on the Gradle plugin being built,
you will need to comment out the `include 'sample-app'`line in
`$ ANDROID_HOME=.../Android/Sdk/ ./gradlew :android:build`
Now you can uncomment that line back in `settings.gradle` and build your
`$ ANDROID_HOME=.../Android/Sdk/ ./gradlew assembleDebug`
`$ .../Android/Sdk/tools/android avd &`
`$ .../Android/Sdk/platform-tools/adb install -r
sample-app/build/outputs/apk/sample-app-debug.apk`
What I did so far
===
- added a `--jdk-provider` flag to the compiler which takes a module that
contains the Jdk, and treats it as the source for the Jdk you target. You
point it to your android module and it will figure out which Jdk modules it
contains from there, allowing you to resolve `java.base/7` from it instead
of from the running Jdk.
- started fixing `import-jar` to deal with transitive dependencies, so we
can import the android jar and whatever dependencies are declared in the
Gradle build (which come from the Android Sdk Maven repo)
- hacked `jigsaw create-mlib` to generate a `ceylon.metamodel` file which
describes the metamodel statically, so that at run-time the metamodel gets
initialised with this. This will move to a more appropriate command
a/ import the Maven (aar file types mostly, which the Android Gradle plugin
unpacks for us) modules into a Ceylon repo
b/ compile our Ceylon module with that repo configured, and the generated
source paths (containing `R.java`) configured too
c/ generate a list of jars required by our Ceylon modules (as in, the
Ceylon runtime) and static metamodel file
d/ pass on that list (minus those already found by Gradle) to the Android
Gradle build so it can dex them and include them in the Apk
What remains to be done
===
- clean up and polish
- support variants and flavours in the Gradle plugin
- properly set up input/output and incremental build in the Gradle plugin
- make the Gradle plugin configurable
- very likely make the Gradle plugin use the Gradle Ceylon plugin Renato
wrote, not sure how
- deal with `java.lang::CharSequence` because Android seems to use this a
lot
- add `--exclude` to `jigsaw create-mlib`
- trim module dependencies in dist to reduce runtime footprint
What feedback/help you can give
===
If you know Gradle, please help improve my plugin, it's currently working
but not well written at all, and not complete or configurable.
If you know Android: try out the same app, try adding more Android typical
features to it, see where we need to improve support for both Ceylon and the
Gradle plugin.
--
Stéphane Épardaud
--
You received this message because you are subscribed to the Google Groups
"ceylon-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/ceylon-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ceylon-users/CAKU9E9uBVyh8QsiL76G-SjXsANg%3DyPb4D_xmGB9L-LQKzRmv8g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
Gavin King
***@ceylon-lang.org
http://profiles.google.com/gavin.king
http://ceylon-lang.org
http://hibernate.org
http://seamframework.org
--
You received this message because you are subscribed to the Google Groups "ceylon-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceylon-dev+***@googlegroups.com.
To post to this group, send email to ceylon-***@googlegroups.com.
Visit this group at https://groups.google.com/group/ceylon-dev.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceylon-dev/CAP7PoCf08d%3DTQW-5cvSgGRoNwSy-Cm_jQHCLkP01-oVPBhjRkw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Stephane Epardaud
2016-03-03 17:08:47 UTC
Permalink
For info, I've just cleaned up my commits considerably in the android
branch. You need to refetch it though, as a result. I may even be able to
merge this soon.
Post by Gavin King
Progress! :-)
On Wed, Mar 2, 2016 at 6:30 PM, Stephane Epardaud
Post by Stephane Epardaud
Hi,
I have been working on getting Ceylon applications to run on Android, and
while it's very early and rough, it's at a point where I can start
accepting
Post by Stephane Epardaud
testers and contributions. I have been able to create a working APK
written
Post by Stephane Epardaud
entirely in Ceylon, with Maven interop, using Gradle for building it.
How can you test this?
===
Checkout the `android` branch of the Ceylon distribution
(https://github.com/ceylon/ceylon) and build your distribution with `ant
clean dist`. It's a bit behind `master`, but not by much. Warning: this
branch will be forcibly rewritten as its commit history is crap and
temporary. It's also only been tested for Android and it will likely just
break if you try to use it outside of Android building. Naturally all
that
Post by Stephane Epardaud
will be fixed in due time. This is bleeding edge, remember?
Get the Ceylon/Android Gradle plugin at
https://github.com/ceylon/ceylon-gradle-android and try it out.
You will need to edit the
`com.redhat.ceylon.gradle.android.MyCeylonCompileTask` class to change
`/home/stephane/src/java-eclipse/ceylon/dist/dist/bin/ceylon`to point to
your distribution (of course it will be configurable later).
Because it has a `sample-app` that depends on the Gradle plugin being
built,
Post by Stephane Epardaud
you will need to comment out the `include 'sample-app'`line in
`$ ANDROID_HOME=.../Android/Sdk/ ./gradlew :android:build`
Now you can uncomment that line back in `settings.gradle` and build your
`$ ANDROID_HOME=.../Android/Sdk/ ./gradlew assembleDebug`
`$ .../Android/Sdk/tools/android avd &`
`$ .../Android/Sdk/platform-tools/adb install -r
sample-app/build/outputs/apk/sample-app-debug.apk`
What I did so far
===
- added a `--jdk-provider` flag to the compiler which takes a module that
contains the Jdk, and treats it as the source for the Jdk you target. You
point it to your android module and it will figure out which Jdk modules
it
Post by Stephane Epardaud
contains from there, allowing you to resolve `java.base/7` from it
instead
Post by Stephane Epardaud
of from the running Jdk.
- started fixing `import-jar` to deal with transitive dependencies, so we
can import the android jar and whatever dependencies are declared in the
Gradle build (which come from the Android Sdk Maven repo)
- hacked `jigsaw create-mlib` to generate a `ceylon.metamodel` file which
describes the metamodel statically, so that at run-time the metamodel
gets
Post by Stephane Epardaud
initialised with this. This will move to a more appropriate command
a/ import the Maven (aar file types mostly, which the Android Gradle
plugin
Post by Stephane Epardaud
unpacks for us) modules into a Ceylon repo
b/ compile our Ceylon module with that repo configured, and the
generated
Post by Stephane Epardaud
source paths (containing `R.java`) configured too
c/ generate a list of jars required by our Ceylon modules (as in, the
Ceylon runtime) and static metamodel file
d/ pass on that list (minus those already found by Gradle) to the
Android
Post by Stephane Epardaud
Gradle build so it can dex them and include them in the Apk
What remains to be done
===
- clean up and polish
- support variants and flavours in the Gradle plugin
- properly set up input/output and incremental build in the Gradle plugin
- make the Gradle plugin configurable
- very likely make the Gradle plugin use the Gradle Ceylon plugin Renato
wrote, not sure how
- deal with `java.lang::CharSequence` because Android seems to use this a
lot
- add `--exclude` to `jigsaw create-mlib`
- trim module dependencies in dist to reduce runtime footprint
What feedback/help you can give
===
If you know Gradle, please help improve my plugin, it's currently working
but not well written at all, and not complete or configurable.
If you know Android: try out the same app, try adding more Android
typical
Post by Stephane Epardaud
features to it, see where we need to improve support for both Ceylon and
the
Post by Stephane Epardaud
Gradle plugin.
--
Stéphane Épardaud
--
You received this message because you are subscribed to the Google Groups
"ceylon-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/ceylon-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ceylon-users/CAKU9E9uBVyh8QsiL76G-SjXsANg%3DyPb4D_xmGB9L-LQKzRmv8g%40mail.gmail.com
.
Post by Stephane Epardaud
For more options, visit https://groups.google.com/d/optout.
--
Gavin King
http://profiles.google.com/gavin.king
http://ceylon-lang.org
http://hibernate.org
http://seamframework.org
--
You received this message because you are subscribed to the Google Groups
"ceylon-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/ceylon-dev.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ceylon-dev/CAP7PoCf08d%3DTQW-5cvSgGRoNwSy-Cm_jQHCLkP01-oVPBhjRkw%40mail.gmail.com
.
For more options, visit https://groups.google.com/d/optout.
--
Stéphane Épardaud
--
You received this message because you are subscribed to the Google Groups "ceylon-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceylon-dev+***@googlegroups.com.
To post to this group, send email to ceylon-***@googlegroups.com.
Visit this group at https://groups.google.com/group/ceylon-dev.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceylon-dev/CAKU9E9vuhc%3DjT8Mr9gAUJ4_g6xXqAESHigaVnuHQJH8vP2zGGA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Stephane Epardaud
2016-03-16 14:30:51 UTC
Permalink
Just merged this to `master` for `ceylon`, `ceylon-ide-common` and
`ceylon-ide-eclipse`. Perhaps `ceylon-ide-intellij` needs a fix too? If yes
it's pretty simple, just replace the package from which you import
`TypeKind` to our model/mirror package.

It's still WIP, but it works so far. I'll work on reducing the module graph
now.

Cheers.
Great!
Alas, I still haven't learned to code for Android (yet), but if I need to
write an app someday, I would prefer to do it in Ceylon rather than in
Java... :-)
And that's one domain where Kotlin has some advance, so it is nice to see
Ceylon to catch up there.
--
You received this message because you are subscribed to the Google Groups
"ceylon-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/ceylon-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ceylon-users/eb8432c3-ce43-46fa-a81a-8fd711bd4d7f%40googlegroups.com
<https://groups.google.com/d/msgid/ceylon-users/eb8432c3-ce43-46fa-a81a-8fd711bd4d7f%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
Stéphane Épardaud
--
You received this message because you are subscribed to the Google Groups "ceylon-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceylon-dev+***@googlegroups.com.
To post to this group, send email to ceylon-***@googlegroups.com.
Visit this group at https://groups.google.com/group/ceylon-dev.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceylon-dev/CAKU9E9sGZ_ZdN6mm4E_YFzhB0KFNZ9uOiSkqChU7OCoBFaTPiw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...