phonegap / build

This is the public repository for PhoneGap Build source and bug tracking
92 stars 33 forks source link

Support build-extras.gradle file #507

Open bluesliverx opened 8 years ago

bluesliverx commented 8 years ago

I understand that you don't want to enable cordova-style hooks on builds for security reasons, but it may be worthwhile to support a few known build cases, such as the build-extras.gradle file for gradle based android builds.

I would ask that if you include this file in the root of the repository, it be copied into the android platforms directory, and then the build.gradle that is used automatically (unless you modify it on the PGB side) includes the build-extras.gradle file already as part of cordova/phonegap.

I'd be happy to make the change myself if the code were available.

goya commented 8 years ago

what is your use case? what properties are you overriding in this gradle file?

bluesliverx commented 8 years ago

I was using some incompatible plugins where they would both pull in the android support library. When that happened, the gradle build would fail complaining about multiple libraries during dexing.

I was actually able to solve my problem because fortunately there was an updated version of one of the plugins, but I could see this being a use case in the future.

Some examples of what I was placing in there:

configurations {
    all*.exclude group: 'com.android.support', module: 'support-v4'
}
android {
    lintOptions {
        abortOnError false
    }
}
Heshyo commented 8 years ago

It looks like lots of people have issues with the push notification, facebook and google analytics plugins. Specifying the build-extras.gradle like @bluesliverx says seems to fix the problems.

macdonst commented 8 years ago

@bluesliverx what plugins were you using? It might be that we just need to fix the plugin.xml for those plugins to include the libraries correctly.

@Heshyo on the phonegap-plugin-push repo there are docs on what Facebook plugins play nice. IIRC I also sent a PR to fix the GA plugin.

bluesliverx commented 8 years ago

Mine were the crosswalk plugin and the local notifications plugin (the katzer repo). The crosswalk one was the biggest problem since it included the support library inline instead of using gradle dependencies. I've since found a fork that had it fixed correctly (or by using a beta released version of the same repo, can't remember), so my problem is actually resolved.

However, I could still see use for this. I can understand if it's too big of a security hole, however, since gradle can do many things. You could also use groovy sandboxing and run the script first to make sure it didn't call anything it wasn't supposed to. Just an idea.

macdonst commented 8 years ago

@bluesliverx yeah, most of the double dexing issues can be solved by plugin authors properly using the framework tag to include the libraries.

Heshyo commented 8 years ago

@macdonst I was able to build my app by changing some plugins: using your push notification plugin https://github.com/Telerik-Verified-Plugins/PushNotification , a clone of the original FB https://github.com/jeduan/cordova-plugin-facebook4 and the new GA from npm cordova-plugin-google-analytics.

I don't know why but I wasn't able to use https://github.com/Telerik-Verified-Plugins/Facebook as PGB was complaining about the missing parameters, even if they were specified in my config.xml. Just switching to https://github.com/jeduan/cordova-plugin-facebook4 without changing anything else in config.xml fixed the build.

macdonst commented 8 years ago

@Heshyo that's not my PushPlugin, that's Telerik's. Regarding Telerik's FB plugin it uses a gradle file while Jeduan's fork just includes that library via a framework tag which makes sense as to why it works when the other one doesn't.

Heshyo commented 8 years ago

@macdonst oops sorry indeed that's not your push plugin, I got confused. Thanks for the info on the plugins. It'd be nice if everyone were loading things properly to play well with the others, but it may be difficult to achieve, that's why having such a build-extras.gradle could help.

macdonst commented 8 years ago

@Heshyo yeah, whenever I come across a plugin with a problem I send a PR to help.

tmdevde commented 4 years ago

Would still be awesome!