diff --git a/.github/workflows/jnigen.yaml b/.github/workflows/jnigen.yaml index 2deae7f80..4da96d352 100644 --- a/.github/workflows/jnigen.yaml +++ b/.github/workflows/jnigen.yaml @@ -7,7 +7,7 @@ # code before making a PR. If you add a task here, you might want to add # the equivalent in that script as well. -name: Dart CI +name: jnigen on: # Run on PRs and pushes to the default branch. diff --git a/README.md b/README.md index cab98988f..81c4a8b77 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ building and bundling. | Package | Description | Version | | --- | --- | --- | | [ffigen](pkgs/ffigen/) | Generator for FFI bindings, using LibClang to parse C, Objective-C, and Swift files. | [![pub package](https://img.shields.io/pub/v/ffigen.svg)](https://pub.dev/packages/ffigen) | +| [jni](pkgs/jni/) | A library to access JNI from Dart and Flutter that acts as a support library for `package:jnigen`. | [![pub package](https://img.shields.io/pub/v/jni.svg)](https://pub.dev/packages/jni) | +| [jnigen](pkgs/jnigen/) | A Dart bindings generator for Java and Kotlin that uses JNI under the hood to interop with Java virtual machine. | [![pub package](https://img.shields.io/pub/v/jnigen.svg)](https://pub.dev/packages/jnigen) | | [native_assets_builder](pkgs/native_assets_builder/) | This package is the backend that invokes top-level `build.dart` scripts. | [![pub package](https://img.shields.io/pub/v/native_assets_builder.svg)](https://pub.dev/packages/native_assets_builder) | | [native_assets_cli](pkgs/native_assets_cli/) | A library that contains the argument and file formats for implementing a native assets CLI. | [![pub package](https://img.shields.io/pub/v/native_assets_cli.svg)](https://pub.dev/packages/native_assets_cli) | | [native_toolchain_c](pkgs/native_toolchain_c/) | A library to invoke the native C compiler installed on the host machine. | [![pub package](https://img.shields.io/pub/v/native_toolchain_c.svg)](https://pub.dev/packages/native_toolchain_c) | diff --git a/pkgs/jni/CHANGELOG.md b/pkgs/jni/CHANGELOG.md index 2065bb14b..d9b2a7246 100644 --- a/pkgs/jni/CHANGELOG.md +++ b/pkgs/jni/CHANGELOG.md @@ -1,6 +1,6 @@ ## 0.8.0-wip -- **Breaking Change** ([#394](https://github.com/dart-lang/jnigen/issues/394)): +- **Breaking Change** ([#548](https://github.com/dart-lang/native/issues/548)): Converted various `Exception`s into `Error`s: - `UseAfterReleaseException` -> `UseAfterReleaseError` - `DoubleReleaseException` -> `DoubleReleaseError` @@ -23,11 +23,11 @@ - Fixed a bug where reading non-null terminated strings would overflow. ## 0.7.1 -- Removed macOS Flutter plugin until package:jni supports it ([#41](https://github.com/dart-lang/jnigen/issues/41)). +- Removed macOS Flutter plugin until package:jni supports it ([#780](https://github.com/dart-lang/native/issues/780)). ## 0.7.0 -- **Breaking Change** ([#387](https://github.com/dart-lang/jnigen/issues/387)): +- **Breaking Change** ([#563](https://github.com/dart-lang/native/issues/563)): Added `JBuffer` and `JByteBuffer` classes as default classes for `java.nio.Buffer` and `java.nio.ByteBuffer` respectively. - **Breaking Change**: Made the type classes `final`. @@ -42,14 +42,14 @@ ## 0.6.0 -- **Breaking Change** ([#131](https://github.com/dart-lang/jnigen/issues/131)): +- **Breaking Change** ([#707](https://github.com/dart-lang/native/issues/707)): Renamed `delete*` to `release*`. - Added `PortProxy` and related methods used for interface implementation. - Added the missing binding for `java.lang.Character`. ## 0.5.0 -- **Breaking Change** ([#137](https://github.com/dart-lang/jnigen/issues/137)): +- **Breaking Change** ([#711](https://github.com/dart-lang/native/issues/711)): Java primitive types are now all lowercase like `jint`, `jshort`, ... - The bindings for `java.util.Set`, `java.util.Map`, `java.util.List` and the numeric types like `java.lang.Integer`, `java.lang.Boolean`, ... are now diff --git a/pkgs/jni/README.md b/pkgs/jni/README.md index 37f5b367c..e6e00b74d 100644 --- a/pkgs/jni/README.md +++ b/pkgs/jni/README.md @@ -1,3 +1,8 @@ +[![Build Status](https://github.com/dart-lang/native/actions/workflows/jnigen.yaml/badge.svg)](https://github.com/dart-lang/native/actions/workflows/jnigen.yaml) +[![Coverage Status](https://coveralls.io/repos/github/dart-lang/native/badge.svg?branch=main)](https://coveralls.io/github/dart-lang/native?branch=main) +[![pub package](https://img.shields.io/pub/v/jni.svg)](https://pub.dev/packages/jni) +[![package publisher](https://img.shields.io/pub/publisher/jni.svg)](https://pub.dev/packages/jni/publisher) + # jni This is a support library to access JNI from Dart / Flutter code. This provides the common infrastructure to bindings generated by [jnigen](https://pub.dev/packages/jnigen), as well as some utility methods. diff --git a/pkgs/jni/pubspec.yaml b/pkgs/jni/pubspec.yaml index 6efae3d66..d753fe440 100644 --- a/pkgs/jni/pubspec.yaml +++ b/pkgs/jni/pubspec.yaml @@ -5,7 +5,7 @@ name: jni description: A library to access JNI from Dart and Flutter that acts as a support library for package:jnigen. version: 0.8.0-wip -repository: https://github.com/dart-lang/jnigen/tree/main/jni +repository: https://github.com/dart-lang/native/tree/main/pkgs/jni topics: - interop diff --git a/pkgs/jnigen/CHANGELOG.md b/pkgs/jnigen/CHANGELOG.md index 0056f41dc..e57349385 100644 --- a/pkgs/jnigen/CHANGELOG.md +++ b/pkgs/jnigen/CHANGELOG.md @@ -5,7 +5,7 @@ ## 0.7.0 -- **Breaking Change** ([#387](https://github.com/dart-lang/jnigen/issues/387)): +- **Breaking Change** ([#563](https://github.com/dart-lang/native/issues/563)): Added `JBuffer` and `JByteBuffer` classes as default classes for `java.nio.Buffer` and `java.nio.ByteBuffer` respectively. - **Breaking Change**: Made the type classes `final`. @@ -16,9 +16,9 @@ ## 0.6.0 -- **Breaking Change** ([#131](https://github.com/dart-lang/jnigen/issues/131)): +- **Breaking Change** ([#707](https://github.com/dart-lang/native/issues/707)): Renamed `delete*` to `release*`. -- **Breaking Change** ([#354](https://github.com/dart-lang/jnigen/issues/354)): +- **Breaking Change** ([#585](https://github.com/dart-lang/native/issues/585)): Renamed constructors from `ctor1`, `ctor2`, ... to `new1`, `new2`, ... - **Breaking Change**: Specifying a class always pulls in nested classes by default. If a nested class is specified in config, it will be an error. @@ -39,10 +39,10 @@ ## 0.5.0 -- **Breaking Change** ([#72](https://github.com/dart-lang/jnigen/issues/72)): +- **Breaking Change** ([#746](https://github.com/dart-lang/native/issues/746)): Removed support for `importMap` in favor of the newly added interop mechanism with importing yaml files. -- **Breaking Change** ([#72](https://github.com/dart-lang/jnigen/issues/72)): +- **Breaking Change** ([#746](https://github.com/dart-lang/native/issues/746)): `java.util.Set`, `java.util.Map`, `java.util.List`, `java.util.Iterator` and the boxed types like `java.lang.Integer`, `java.lang.Double`, ... will be generated as their corresponding classes in `package:jni`. @@ -50,7 +50,7 @@ ## 0.4.0 -- **Breaking Change** ([#145](https://github.com/dart-lang/jnigen/issues/145)): +- **Breaking Change** ([#705](https://github.com/dart-lang/native/issues/705)): Type arguments are now named instead of positional. - Type parameters can now be inferred when possible. - Fixed a bug where passing a `long` argument truncated it to `int` in pure dart diff --git a/pkgs/jnigen/README.md b/pkgs/jnigen/README.md index eaffeaa4e..a729900c6 100644 --- a/pkgs/jnigen/README.md +++ b/pkgs/jnigen/README.md @@ -1,5 +1,7 @@ -[![Build Status](https://github.com/dart-lang/jnigen/workflows/Dart%20CI/badge.svg)](https://github.com/dart-lang/jnigen/actions?query=workflow%3A%22Dart+CI%22+branch%3Amain) -[![Coverage Status](https://coveralls.io/repos/github/dart-lang/jnigen/badge.svg?branch=main)](https://coveralls.io/github/dart-lang/jnigen?branch=main) +[![Build Status](https://github.com/dart-lang/native/actions/workflows/jnigen.yaml/badge.svg)](https://github.com/dart-lang/native/actions/workflows/jnigen.yaml) +[![Coverage Status](https://coveralls.io/repos/github/dart-lang/native/badge.svg?branch=main)](https://coveralls.io/github/dart-lang/native?branch=main) +[![pub package](https://img.shields.io/pub/v/jnigen.svg)](https://pub.dev/packages/jnigen) +[![package publisher](https://img.shields.io/pub/publisher/jnigen.svg)](https://pub.dev/packages/jnigen/publisher) ## Introduction Experimental bindings generator for Java bindings through dart:ffi and JNI. @@ -136,7 +138,7 @@ On Android, the flutter application runs embedded in Android JVM. On other platf ## Java features support Currently basic features of the Java language are supported in the bindings. Each Java class is mapped to a Dart class. Bindings are generated for methods, constructors and fields. Exceptions thrown in Java are rethrown in Dart with stack trace from Java. -More advanced features such as callbacks are not supported yet. Support for these features is tracked in the [issue tracker](https://github.com/dart-lang/jnigen/issues). +More advanced features such as callbacks are not supported yet. Support for these features is tracked in the [issue tracker](https://github.com/dart-lang/native/issues?q=is%3Aopen+is%3Aissue+label%3Apackage%3Ajni%2Cpackage%3Ajnigen). ## Note on Dart (standalone) target `package:jni` is an FFI plugin containing native code, and any bindings generated from jnigen contains native code too. diff --git a/pkgs/jnigen/example/README.md b/pkgs/jnigen/example/README.md index dce00fbd5..97d3581b5 100644 --- a/pkgs/jnigen/example/README.md +++ b/pkgs/jnigen/example/README.md @@ -4,10 +4,10 @@ This directory contains examples on how to use jnigen. | Directory | Description | | ------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -| [in_app_java](https://github.com/dart-lang/jnigen/tree/main/jnigen/example/in_app_java/) | Demonstrates how to include custom Java code in Flutter application and call that using jnigen | -| [pdfbox_plugin](https://github.com/dart-lang/jnigen/tree/main/jnigen/example/pdfbox_plugin/) | Example of a flutter plugin which provides bindings to Apache PDFBox library. Currently works on Flutter desktop and Dart standalone on linux. | -| [notification_plugin](https://github.com/dart-lang/jnigen/tree/main/jnigen/example/notification_plugin/) | Example of a reusable Flutter plugin with custom Java code which uses Android libraries. | -| [kotlin_plugin](https://github.com/dart-lang/jnigen/tree/main/jnigen/example/kotlin_plugin) | Example of using jnigen to generate bindings for Kotlin. | +| [in_app_java](https://github.com/dart-lang/native/tree/main/pkgs/jnigen/example/in_app_java/) | Demonstrates how to include custom Java code in Flutter application and call that using jnigen | +| [pdfbox_plugin](https://github.com/dart-lang/native/tree/main/pkgs/jnigen/example/pdfbox_plugin/) | Example of a flutter plugin which provides bindings to Apache PDFBox library. Currently works on Flutter desktop and Dart standalone on linux. | +| [notification_plugin](https://github.com/dart-lang/native/tree/main/pkgs/jnigen/example/notification_plugin/) | Example of a reusable Flutter plugin with custom Java code which uses Android libraries. | +| [kotlin_plugin](https://github.com/dart-lang/native/tree/main/pkgs/jnigen/example/kotlin_plugin) | Example of using jnigen to generate bindings for Kotlin. | We intend to cover few more use cases in future. @@ -16,12 +16,12 @@ We intend to cover few more use cases in future. ### Dart package (Standalone only) - Create dart package, add `jni` as dependency and `jnigen` as dev dependency. -- Write the jnigen config similar to [the one in pdfbox_plugin](https://github.com/dart-lang/jnigen/tree/main/jnigen/example/pdfbox_plugin/jnigen.yaml). +- Write the jnigen config similar to [the one in pdfbox_plugin](https://github.com/dart-lang/native/tree/main/pkgs/jnigen/example/pdfbox_plugin/jnigen.yaml). - Generate JNI bindings by running `dart run jnigen --config jnigen.yaml`. - In the CLI project which uses this package, add this package, and `jni` as a dependency. - Run `dart run jni:setup` to build native libraries for JNI base library and jnigen generated package. -- Import the package. See [pdf_info.dart](https://github.com/dart-lang/jnigen/tree/main/jnigen/example/pdfbox_plugin/dart_example/bin/pdf_info.dart) for an example of using JNI from dart standalone. +- Import the package. See [pdf_info.dart](https://github.com/dart-lang/native/tree/main/pkgs/jnigen/example/pdfbox_plugin/dart_example/bin/pdf_info.dart) for an example of using JNI from dart standalone. ### Flutter FFI plugin @@ -42,7 +42,7 @@ To create an FFI plugin with JNI bindings: - Create an FFI plugin with Android as the only platform. - Build the example/ Android project using command `flutter build apk`. After a release build is done, jnigen can use a gradle stub to collect compile classpaths. - Write your custom Java code in `android/src/main/java` hierarchy of the plugin. -- Generate JNI bindings as described above. See [notification_plugin/jnigen.yaml](https://github.com/dart-lang/jnigen/tree/main/jnigen/example/notification_plugin/jnigen.yaml) for example configuration. +- Generate JNI bindings as described above. See [notification_plugin/jnigen.yaml](https://github.com/dart-lang/native/tree/main/pkgs/jnigen/example/notification_plugin/jnigen.yaml) for example configuration. ### Pure dart bindings diff --git a/pkgs/jnigen/example/notification_plugin/pubspec.yaml b/pkgs/jnigen/example/notification_plugin/pubspec.yaml index 1f6cf4925..06974b396 100644 --- a/pkgs/jnigen/example/notification_plugin/pubspec.yaml +++ b/pkgs/jnigen/example/notification_plugin/pubspec.yaml @@ -2,7 +2,7 @@ name: notification_plugin description: Example for Android plugin with custom Java code using jnigen. version: 0.0.1 publish_to: none -homepage: https://github.com/dart-lang/jnigen +homepage: https://github.com/dart-lang/native environment: sdk: '>=3.1.0 <4.0.0' diff --git a/pkgs/jnigen/example/pdfbox_plugin/jnigen.yaml b/pkgs/jnigen/example/pdfbox_plugin/jnigen.yaml index 584a3bf7e..fa24d8501 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/jnigen.yaml +++ b/pkgs/jnigen/example/pdfbox_plugin/jnigen.yaml @@ -47,7 +47,7 @@ classes: ## directly to dart static fields. In the current implementation some string ## escaping problems may occur. ## -## See issue #31 (https://github.com/dart-lang/jnigen/issues/31) for details. +## See issue #31 (https://github.com/dart-lang/native/issues/792) for details. ## (This field does not appear in bindings unless full package bindings are ## generated using a `-Dclasses` override.) ## diff --git a/pkgs/jnigen/example/pdfbox_plugin/pubspec.yaml b/pkgs/jnigen/example/pdfbox_plugin/pubspec.yaml index a269d5a6f..39b828448 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/pubspec.yaml +++ b/pkgs/jnigen/example/pdfbox_plugin/pubspec.yaml @@ -3,7 +3,7 @@ description: | Example of using jnigen to generate bindings for a non-trivial Java library. version: 0.0.1 publish_to: none -homepage: https://github.com/dart-lang/jnigen +homepage: https://github.com/dart-lang/native environment: sdk: '>=3.1.0 <4.0.0' diff --git a/pkgs/jnigen/lib/src/bindings/dart_generator.dart b/pkgs/jnigen/lib/src/bindings/dart_generator.dart index b202293d3..d01621cc0 100644 --- a/pkgs/jnigen/lib/src/bindings/dart_generator.dart +++ b/pkgs/jnigen/lib/src/bindings/dart_generator.dart @@ -177,7 +177,7 @@ import "package:jni/jni.dart" as jni; log.fatal('Dart format completed with exit code ${formatRes.exitCode} ' 'This usually means there\'s a syntax error in bindings.\n' 'Please look at the generated files and report a bug: \n' - 'https://github.com/dart-lang/jnigen/issues/new\n'); + 'https://github.com/dart-lang/native/issues/new?labels=package%3Ajnigen\n'); } } diff --git a/pkgs/jnigen/pubspec.yaml b/pkgs/jnigen/pubspec.yaml index 35e01bc2e..b706169fa 100644 --- a/pkgs/jnigen/pubspec.yaml +++ b/pkgs/jnigen/pubspec.yaml @@ -5,7 +5,7 @@ name: jnigen description: A Dart bindings generator for Java and Kotlin that uses JNI under the hood to interop with Java virtual machine. version: 0.8.0-wip -repository: https://github.com/dart-lang/jnigen/tree/main/jnigen +repository: https://github.com/dart-lang/native/tree/main/pkgs/jnigen environment: sdk: ">=3.1.0 <4.0.0"