Skip to content
This repository was archived by the owner on Aug 19, 2020. It is now read-only.
This repository was archived by the owner on Aug 19, 2020. It is now read-only.

Using apply(from...) partial files android #1287

Closed
@mtrakal

Description

@mtrakal

Main file, which use apply from

build.gradle.kts

plugins {
    id("com.android.library")
    kotlin("android")
    kotlin("android.extensions")
    kotlin("kapt")
}
apply {
    from("$rootDir/config/include.gradle.kts")
}
android {
...
}

second file which includes single files for apply
include.gradle.kts

apply {
    from("$rootDir/config/exclude.gradle.kts")
    from("$rootDir/config/default.gradle.kts")
    from("$rootDir/config/testing/testing.gradle")
}

and in exclude.gradle.kts I have:

android {
  packagingOptions {
        exclude ("META-INF/DEPENDENCIES.TXT")
        exclude ("META-INF/LICENSE.TXT")
}}

But it failed on:

Script compilation errors:

  Line 01: android {
           ^ Unresolved reference: android

  Line 02:   packagingOptions {
             ^ Unresolved reference: packagingOptions

  Line 03:         exclude ("META-INF/DEPENDENCIES.TXT")
                   ^ Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: 
                       public fun Configuration.exclude(group: String? = ..., module: String? = ...): Configuration defined in org.gradle.kotlin.dsl

When I didn't use KTS file, but .gradle and Groovy and proper syntax, it works as expected. All excludes from the file are "included" into main build.gradle.kts into android and work as expected without any error.

Expected Behavior

Work same as when use Groovy

Current Behavior

Failed on: Unresolved reference: android

Your Environment

------------------------------------------------------------
Gradle 5.0
------------------------------------------------------------

Build time:   2018-11-26 11:48:43 UTC
Revision:     7fc6e5abf2fc5fe0824aec8a0f5462664dbcd987

Kotlin DSL:   1.0.4
Kotlin:       1.3.10
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM:          1.8.0_181 (Oracle Corporation 25.181-b13)
OS:           Windows 10 10.0 amd64

Android Studio 3.4 Canary 7
Build #AI-183.4284.148.34.5159543, built on December 3, 2018
JRE: 1.8.0_152-release-1248-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0

kotlin: 1.3.11
using buildSrc

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions