NativeScript / NativeScript/nativescript-cli

Plugin's include.gradle is not properly respected when building aar

Offen
#3,563 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

bug os: android
Vorherrschende Sprache
JavaScript
Sterne
1.1k
Forks
204
Ø Merge
1 T. 9 Std.
Gemergte PRs (30 T.)
8

Beschreibung

Tell us about the problem

Currently {N} CLI detects if a plugin has any Android resources/java files/etc. and tries to build an android archive (.aar) for said plugin. During building of this .aar file CLI takes into account the plugin's include.gradle file, if it exists, however the logic for this is incomplete. Instead of only taking into account certain tags (like dependencies or repositories), it seems more appropriate that the whole include.gradle be included in the process of building the plugin's .aar file.

In other words instead of any additional parsing CLI should only include a
apply from: <path-to-plugin-include.gradle-file>

section in the plugin's build.gradle.

Which platform(s) does your issue occur on?

Android

Please tell us how to recreate the issue in as much detail as possible.
  1. tns create myApp
  2. cd myApp
  3. tns plugin add nativescript-mapbox
  4. edit node_modules/nativescript-mapbox/platforms/android/include.gradle so that the contents become:
android {
    productFlavors {
        "mapbox" {
            dimension "mapbox"
        }
    }
}

repositories {
    mavenCentral()
}

def coreLibrary = 'com.mapbox.mapboxsdk:mapbox-android-sdk:5.3.1@aar'
def serviceLibrary = 'com.mapbox.mapboxsdk:mapbox-android-services:2.2.9@aar'
def pluginsString = 'com.mapbox.mapboxsdk:mapbox-android-plugin-locationlayer:0.3.0'

// see https://www.mapbox.com/android-sdk/
dependencies {
    // core library
    compile ("$coreLibrary"){
        transitive=true
    }

    // service library
    compile ("$serviceLibrary"){
        transitive=true
    }

    // plugins
    compile "$pluginsString"
}
  1. Try to execute tns build android

CLI fails to build the .aar file in this case, because the dependencies section is copied, however it is in its essence incomplete.

This is only a dummy example to illustrate the flaw in the CLI logic. The content of the include.gradle may contain more complex logic, which needs to be taken into account.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Lies lib/services/android-plugin-build-service.ts im Bereich der Zeilen 232–239 und reproduziere anschließend das Problem mit dem nativescript-mapbox-Beispiel für include.gradle und tns build android. Verfolge, wie include.gradle in den Plugin-Build einbezogen wird; erledigt ist die Aufgabe, wenn die vollständige Datei während der Erstellung von .aar angewendet wird, anstatt dass nur ausgewählte Abschnitte kopiert werden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
android, groovy, javascript
Bereich
build-system, cli, mobile-dev
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
48/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.