Skip to content

Add gradle support for java bindings - #4512

Merged
not-jenni merged 2 commits into
iree-org:mainfrom
not-jenni:java-bindings-gradle
Jan 20, 2021
Merged

not-jenni merged 2 commits into
iree-org:mainfrom
not-jenni:java-bindings-gradle

Conversation

@not-jenni

Copy link
Copy Markdown
Contributor

Checks in a build.gradle file for compiling an android library file, and updates the readme with instructions for how to generate the AAR on linux. Progress on #4464

gradlew, gradlew.bat, gradle/wrapper/gradle-wrapper.jar, and gradle/wrapper/gradle-wrapper.properties are all files generated by Android Studio. I am including them to keep with the convention most other apps seem to use (example https://github.com/tensorflow/examples/tree/master/lite/examples/image_classification/android)

@google-cla google-cla Bot added the cla: yes label Jan 14, 2021
@not-jenni
not-jenni requested a review from ScottTodd January 14, 2021 00:00

@ScottTodd ScottTodd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comment thread bindings/java/build.gradle Resolved
main {
java.srcDirs = ['com/google/iree']
jni.srcDirs = ['com/google/iree/native']
manifest.srcFile '../javatests/com/google/iree/TestManifest.xml'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No change needed now, but we'll want to differentiate between test manifest files, sample app manifest files, and bindings manifest files later on.

Comment on lines +53 to +57
externalNativeBuild {
cmake {
path "../../CMakeLists.txt"
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can this path be included in the prior externalNativeBuild? Or are two externalNativeBuild definitions needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I believe this needs to be separate because the previous externalNativeBuild was in a defaultConfig block, and the CMake path needs to be specified outside of that

Comment thread bindings/java/gradlew
#!/usr/bin/env sh

#
# Copyright 2015 the original author or authors.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@GMNGeoffrey will this license header trigger any errors in our infrastructure? Maybe the files should live under a third_party/ directory?

For a bit of context on why these files are useful to check in, see https://stackoverflow.com/a/40981755

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

They won't because I got annoyed and turned off these checks (the snr was terrible). That said, we should check third party code in only under a third_party/ directory

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also I can't comment on the binary file because GitHub, but is checking in a jar necessary? I know git doesn't like binary files (although that one is pretty small)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Checking in the jar or the other gradle files isn't necessary, I just included them because that seems to be the standard that many other projects follow (more info in the stackoverflow link Scott included). I can remove them if you would prefer, then anyone who wants to use the java api will just need to generate the files themselves

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This stuff should still go under third_party/. It's third party code we didn't write and has a different copyright

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just sent out #4580 to remove these files

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks :-) I think we should probably also put the jar there? Unless the jar is actually are code? I can't tell since it's, well, a binary 😁

@GMNGeoffrey

Copy link
Copy Markdown
Member

For the failing Lint / tabs check, lets add .jar to

https://github.com/google/iree/blob/176b5803d616f09002e6cea619363cf61688e406/scripts/check_tabs.sh#L24-L30

I think even better, make that grep skip binary files using --binary-files=without-match (AKA -I, but I like using long-form in scripts for readability)

@not-jenni
not-jenni requested a review from ScottTodd January 19, 2021 20:52
@not-jenni
not-jenni merged commit b8d6ea8 into iree-org:main Jan 20, 2021
@hanhanW hanhanW mentioned this pull request Jan 22, 2021
@not-jenni not-jenni linked an issue Jan 22, 2021 that may be closed by this pull request
@not-jenni
not-jenni deleted the java-bindings-gradle branch September 7, 2021 19:02
@not-jenni
not-jenni restored the java-bindings-gradle branch September 7, 2021 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support building java bindings with Gradle/CMake

3 participants