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

feat(android): be able to add plugins to build.gradle #14019

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

Conversation

AbdullahFaqeir
Copy link

feat(android): added classpathes to manifest
feat(android): add plugins to manifest
feat(android): custom root.build.gradle for modules

  • classpathes will be added to the root project build.gradle to allow plugins to be identified.
  • plugins will be added to the module build.gradle file.

feat(android): plugins classpathes to manifest
feat(android): custom root.build.gradle for modules
Copy link
Collaborator

@hansemannn hansemannn left a comment

Choose a reason for hiding this comment

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

Just a minor code style issue, thanks!

android/templates/build/root.build.gradle Outdated Show resolved Hide resolved
Co-authored-by: Hans Knöchel <hansemannn@users.noreply.github.com>
@AbdullahFaqeir
Copy link
Author

Just a minor code style issue, thanks!

Of course! Thanks 🙏

Copy link
Collaborator

@hansemannn hansemannn left a comment

Choose a reason for hiding this comment

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

CR looks good from my end. @m1ga Any objections?

@AbdullahFaqeir
Copy link
Author

CR looks good from my end. @m1ga Any objections?

I guess I need to add a couple of more things to make this PR feature solid.

@m1ga
Copy link
Contributor

m1ga commented Apr 15, 2024

i've not tested it as I don't have any test case or knowledge how to use plugins in a gradle file. But if it works for you and doens't break the usual stuff (module build, app build, hyperloop app, kitchensink app) then go for it 😄
if it is something "non standard" gradle stuff there should be some documentation how to use it

@AbdullahFaqeir
Copy link
Author

@hansemannn @m1ga This was the last commit needed to this PR, I've tested it from my side and it's all good now and ready to be merged, as for the documentation of how to use this, we need to add the update here, if you can tag me on where this is editable so I can work on the documentation of this new feature.

@m1ga
Copy link
Contributor

m1ga commented Apr 16, 2024

Nice, that will be in this repo: https://github.com/tidev/titanium-docs/tree/main/docs/guide/Titanium_SDK/Titanium_SDK_How-tos/Extending_Titanium_Mobile

@AbdullahFaqeir
Copy link
Author

Cool

@m1ga
Copy link
Contributor

m1ga commented Apr 16, 2024

Hyperloop apps won't build.

[ERROR] [GRADLE] 
[ERROR] [GRADLE] FAILURE: Build failed with an exception.
[ERROR] [GRADLE] 
[ERROR] [GRADLE] * Where:
[ERROR] [GRADLE] Build file '/home/miga/tools/hyperloop-examples/build/hyperloop/android/build.gradle' line: 2
[ERROR] [GRADLE] 
[ERROR] [GRADLE] * What went wrong:
[ERROR] [GRADLE] Could not compile build file '/home/miga/tools/hyperloop-examples/build/hyperloop/android/build.gradle'.
[ERROR] [GRADLE] > startup failed:
[ERROR] [GRADLE]   build file '/home/miga/tools/hyperloop-examples/build/hyperloop/android/build.gradle': 2: Unexpected input: '{' @ line 2, column 13.

The generated build.gradle file looks like this:

	dependencies {
		classpath 'com.android.tools.build:gradle:7.0.4'
		classpath 'com.google.gms:google-services:4.3.10'
		classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
		<% for (let i = 0; i < classpathes.length; i++) {%>
		classpath '<%= classpathes[i] %>'
		<% } %>
	}

so it didn't replace the loop.

@m1ga
Copy link
Contributor

m1ga commented Apr 16, 2024

Module also won't build:

[ERROR] TypeError: Cannot read properties of undefined (reading 'split')
    at AndroidModuleBuilder.generateRootProjectFiles (/home/miga/.titanium/mobilesdk/linux/12.3.0/android/cli/commands/_buildModule.js:518:42)
    at async AndroidModuleBuilder.run (/home/miga/.titanium/mobilesdk/linux/12.3.0/android/cli/commands/_buildModule.js:315:3)
[ERROR] An error occurred during build after 24ms
[ERROR] Cannot read properties of undefined (reading 'split')

@m1ga m1ga self-requested a review April 16, 2024 12:24
android/cli/commands/_buildModule.js Outdated Show resolved Hide resolved
Copy link
Author

@AbdullahFaqeir AbdullahFaqeir left a comment

Choose a reason for hiding this comment

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

check if this.manifest.plugins is there before splitting

check if this.manifest.plugins is there before splitting
@AbdullahFaqeir
Copy link
Author

@m1ga can you please review this, thanks!

path.join(this.buildDir, 'build.gradle'));
let buildGradleContent = await fs.readFile(path.join(templatesDir, 'root.build.gradle'));
buildGradleContent = ejs.render(buildGradleContent.toString(), {
classpathes: this.manifest.classpathes.split(','),
Copy link
Contributor

Choose a reason for hiding this comment

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

please add the same fix here

@m1ga
Copy link
Contributor

m1ga commented May 3, 2024

with the fixes I still get

[ERROR] [GRADLE] FAILURE: Build failed with an exception.
[ERROR] [GRADLE] 
[ERROR] [GRADLE] * Where:
[ERROR] [GRADLE] Build file '/home/miga/dev/ti.mlkit/android/build/build.gradle' line: 14

when building a module as it will add an empty classpath line to the build/build.gradle:

buildscript {
	ext.kotlin_version = '1.8.20'

	repositories {
		google()
		mavenCentral()
	}
	dependencies {
		classpath 'com.android.tools.build:gradle:7.0.4'
		classpath 'com.google.gms:google-services:4.3.10'
		classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
		
		classpath ''
		
	}
}
...

@m1ga
Copy link
Contributor

m1ga commented May 3, 2024

The hyperloop error also still exists. To test it: clone and build https://github.com/tidev/hyperloop-examples

@hansemannn hansemannn changed the title More flexibility for module development feat(android): be able to add plugins to build.gradle May 4, 2024
@AbdullahFaqeir
Copy link
Author

@m1ga I'll try to work on it today and finish it ASAP.

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.

None yet

3 participants