Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes: #3550 Add Hello-world JAVA example using mill #3596

Closed

Conversation

himanshumahajan138
Copy link
Contributor

Fixes: #3550

Created Build.sc file with proper format
Created helloworld.apk that runs on android

code runs with command mill app.create

All code Running but the problem is with android.jar file which needs to be present locally or remotely

@lihaoyi I request you to please once check the changes i made in the build.sc file its running well with the local code where android.jar is present but the problem is with the dependency for android.jar

Hope You Understand.

screenshot of running app
WhatsApp Image 2024-09-23 at 20 10 34_4891dfd5

@himanshumahajan138 himanshumahajan138 changed the title Fixes: #3550 Add Hello-world example using mill Fixes: #3550 Add Hello-world JAVA example using mill Sep 23, 2024
@0xnm
Copy link
Contributor

0xnm commented Sep 23, 2024

There are few things you should address here:

  • __build folder shouldn't be committed
  • signing key shouldn't be committed as well: it should either come from the user or generated on the fly for debug builds
  • targetSdkVersion should be updated to the 35 to keep up with the latest Android API
  • you should either run this example in the system image which already have Android SDK installed and all the licenses accepted, or download it and install the necessary components from your build script (former option is better, I believe)
  • .bat files you are trying to run won't be executed in Linux environment

@himanshumahajan138
Copy link
Contributor Author

@lihaoyi @0xnm @lefou

Fixes: #3550

All the Checks Passed and All the files are committed as per requirements

Directory Structure:
Got it! Here’s the directory structure exactly in the format you provided:

example/
│
javallib/
│
hello-world/
│   AndroidManifest.xml
│   build.sc
└───java/
    └───com/
        └───helloworld/
            └───app/
            │   MainActivity.java

This matches your original format. You can use this as is in your README.md.
Create & Compile App using Mill _.compile

Kindly Review the Changes Made and Merge the Pull Request.

Screenshot :
WhatsApp Image 2024-09-24 at 11 15 29_207f2586

@lihaoyi
Copy link
Member

lihaoyi commented Sep 25, 2024

@himanshumahajan138 I think this looks good as a first pass, but there's a bunch of work to be done to bring it in line with the rest of Mill's codebase. Some immediate action items that come to mind:

  1. The example needs to be running in CI using the standard example/ folder format.
    • This can go in a new example/javalib/android/, register it in example/package.mill
    • It needs a /** Usage */ block with CLI instructions on how this is to be used, that will be executed as part of the example
  2. The example should be self-contained and download all necessary files (as much as possible) as part of the build.
  3. Let's move the bulk of the non-app-specific logic into an trait AndroidModule in scalalib/src/mill/javalib/android, so that only app-specific logic would live in the build.sc file
    • Scaladoc should be done using /** */ to properly get picked up by the documentation system
  4. The relationship between AndroidModule and JavaModule should be made clear. Does AndroidModule just provide the post-compilation step from classfiles->dex? Does it also provide custom source layouts and source->classfile compilation, or can it piggy-pack on the stuff that JavaModule already provides? I suspect a lot of the stuff calling javac ourselves is redundant
  5. You should not need a build_path to put things in, the T.dest of each task should be sufficient, which you can wrap in PathRef(T.dest) and return from each task so downstream tasks can access the files using `upstreamTask().path / "blahblahblah"
  6. The build.sc file should be build.mill as following the new file extension
  7. Should use the new os.call((...)) syntax instead of os.proc().call(), and path / "platforms/android-35/android.jar" instead of path / "platforms" / "android-35" / "android.jar"
  8. The various .bloop stuff probably shouldn't be committed

@himanshumahajan138
Copy link
Contributor Author

himanshumahajan138 commented Sep 25, 2024

3. Let's move the bulk of the non-app-specific logic into an trait AndroidModule in scalalib/src/mill/javalib/android, so that only app-specific logic would live in the build.sc file

@lihaoyi

I am facing problem, please help
i created AndroidModule.scala file in mill/scalalib/src/mill/javalib/android/ and build.sc in mill/example/javalib/android/hello-world/

But now when i am importing mill.javalib.android.AndroidModule in the build.sc then its giving error that AndroidModule doesnt exist i tried my whole day solving this reading the docs and all but still unable to figureout why this is happening

@lefou @0xnm @lihaoyi please help me if possible...

@lefou
Copy link
Member

lefou commented Sep 26, 2024

i created AndroidModule.scala file in mill/scalalib/src/mill/javalib/android/

I can't see this file is this PR.

@himanshumahajan138
Copy link
Contributor Author

i created AndroidModule.scala file in mill/scalalib/src/mill/javalib/android/

I can't see this file is this PR.

Actually I didn't pushed coz if i try to push it will fail in checks

@lefou
Copy link
Member

lefou commented Sep 26, 2024

@lefou @0xnm @lihaoyi please help me if possible...

I fear it's not possible to help when we can't see anything. If you see some error, you need to show it! You should push your changes, so CI can catch it, too. That makes it reproducible and easy to look at.

@himanshumahajan138
Copy link
Contributor Author

Fixes : #3550

@lihaoyi @lefou @0xnm

I Changed Whole Code According to the Requirements and Code is running Fully in Local but i dont know what is happening when i pushed the code for live checking

Key Changes :

  • Create mill/example/javalib/android/1-hello-world/build.mill file which extends the AndroidModule.scala Trait and creates android app and then proper /** Usage */ for CLI
  • Created mill/scalalib/src/mill/javalib/android/AndroidModule.scala file which contains code for creating android application and then provided proper documentation in scaladoc format
  • Updated mill/example/package.mill for android folder

Please help me out i have not slept from last 2 days constantly to create proper code for #3550 issue and now when everything was working fine in my local its again got some issue with the live testing

Please Help me out !!!
@lihaoyi @lefou @0xnm

@lihaoyi
Copy link
Member

lihaoyi commented Sep 27, 2024

@himanshumahajan138 if you have not slept for the last two days, I will tell you straight that you should stop working on this and go sleep. Maybe you are able to complete the ticket and maybe you can't, but regardless we're not interested in you working yourself to the bone.

@himanshumahajan138
Copy link
Contributor Author

@lihaoyi Heartly Appreciated your words, please once review my pr and tell me what's wrong in this i again pushed some changes and this time i have followed each and every step as per requirements

@himanshumahajan138
Copy link
Contributor Author

Fixes : #3550

@lihaoyi @lefou @0xnm Please Review !!!

All test Passed and Code Worked as per the Requirements please Review and Merge #3596 to main branch

Finally after a Week of hustle 💯

@lihaoyi
Copy link
Member

lihaoyi commented Sep 28, 2024

I've updated the original ticket with some more details. I think you've made good progress, but still a ways to go

  • A folder in example/javalib/android/1-hello-world that contains a build that contains Java code for building a trivial hello-world android app APK, that can then be loaded into a physical phone or android emulator.
    • This isn't ready yet, the build is not yet of acceptable quality to be merged as an official example
  • Just the simplest plain-old-Java android app is fine: no need fancier features or C++ code or whatever.
  • Manual testing of the final APK is fine, but the process to build it should be exercised in the example.
    • I assume you've tested it, and the example passes
  • The app should have two modules containing Java code, one depending on another, to demonstrate how splitting of a app codebase into modules works
    • Not done yet. Currently it's only one module
  • Android-specific config should be extracted into a trait AndroidJavaModule in mill.javalib, and only app-specific config should be in the example/javalib/android/1-hello-world example
    • This is not yet of acceptable quality to be merged
  • Both the library code and the example code should be rigorously documented w.r.t. how it is used and how it fits into the larger Android ecosystem
    • This is not there yet. Doc-comments are a start, but that does not achieve rigorously documented w.r.t. how it is used and how it fits into the larger Android ecosystem

In general, the code now works, but for it to be an official Mill-android example we need to aim for higher than "works". Please go through all the other examples in example/, especially example/javalib/ example/scalalib/ and example/kotlinlib/, along with their associated scalalib/ and kotlinlib/ traits to see what a Mill example and module trait should look like. The example code doesn't need to be perfect, and I'm not expecting you to write a books worth of documentation. But it needs to fit into the prevailing Mill style and coding conventions, and have both enough docs for someone to get started as well as enough links to further resources for readers to dig deeper as necessary

@himanshumahajan138
Copy link
Contributor Author

The app should have two modules containing Java code, one depending on another, to demonstrate how splitting of a app codebase into modules works

  • Not done yet. Currently it's only one module

You Means we have to create two functions inside build.mill
or
Create two Separate Traits one for Downloading Android Setup and other for creating Android app and then extend them inside build.mill

@lihaoyi
Copy link
Member

lihaoyi commented Sep 28, 2024

You Means we have to create two functions inside build.mill
or
Create two Separate Traits one for Downloading Android Setup and other for creating Android app and then extend them inside build.mill

Two traits sounds reasonable. Assuming we provide good defaults, each trait we extend inside build.mill will be somewhere around 1-3 lines of code, not a huge burden to someone configuring the build. We could also set it up such that for someone who only has one android app, they can extend both traits in the same module

@lihaoyi
Copy link
Member

lihaoyi commented Sep 28, 2024

Notably, two modules doesn't mean two android apps. It means two java modules that end up being included in the one same android app

@himanshumahajan138
Copy link
Contributor Author

himanshumahajan138 commented Sep 28, 2024

You Means we have to create two functions inside build.mill
or
Create two Separate Traits one for Downloading Android Setup and other for creating Android app and then extend them inside build.mill

Two traits sounds reasonable. Assuming we provide good defaults, each trait we extend inside build.mill will be somewhere around 1-3 lines of code, not a huge burden to someone configuring the build. We could also set it up such that for someone who only has one android app, they can extend both traits in the same module

OK so I will add One named as AndroidModule.scala and other AppModule.scala

and finally extend both of them inside the build.mill

@lihaoyi
Copy link
Member

lihaoyi commented Sep 28, 2024

Let's name them AndroidSdkModule.scala and AndroidAppModule.scala, a bit more verbose but makes their roles clearer

@himanshumahajan138
Copy link
Contributor Author

Fixes: #3550
@lihaoyi
Sir can you please review my AndroidAppModule.scala
I have formatted it fully and it passed local linting check
But i dont know why it failed maybe some thing left on my part which i am unable to figureout,
So i request you to please review the code ✅

@himanshumahajan138
Copy link
Contributor Author

Fixes #3550
@lihaoyi

Final All test Passed and All Requirements also completed
Please Review the code and then i will start documentation.....

@lihaoyi @0xnm @lefou

@lihaoyi
Copy link
Member

lihaoyi commented Sep 29, 2024

@himanshumahajan138 I'm going to make the call and say that this collaboration isn't going to work out. I don't think you have the expertise necessary to push this over the finish line, there's a limit in how much I can hold your hand, and I don't see this PR converging to a merge-able state with a reasonable amount of time and effort.

Thank you for the time you put in, I know you've tried hard and done your best, but I'm going to call it quits on this one and close this PR to open up the space for others to attack the problem

@lihaoyi lihaoyi closed this Sep 29, 2024
@himanshumahajan138
Copy link
Contributor Author

@lihaoyi
I think this is not fare !
All the things are almost covered
Keypoints:

  1. Created build.mill which inherits AndroidAppModule and AndroidSdkModule
  2. AndroidSdkModule trait provides the implementation for Sdk download
  3. AndroidAppModule trait provides the implementation for App Creation
  4. App configuration related stuff will be updated in build.mill file making it unique from default app creation
  5. Proper scaladoc and usage followed to implement the code
  6. App testing done in local, results passed
  7. Code fully reusable for unique application
  8. Passed all automated testcases

Just asking for review because i want to create documentation based on finetuned code but when i was near finish line you just kicked me out
i heartly request you to please tell me what is left and i will provide you with the professional code and documentation
i have worked a lot for this please understand....
please give me a chance !

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.

Add hello-world Android Java & Kotlin examples using Mill (2000USD bounty)
4 participants