Skip to content
This repository has been archived by the owner on Jan 17, 2020. It is now read-only.

Commit

Permalink
Merge pull request #89 from cookpad/fix/resolve_configuration
Browse files Browse the repository at this point in the history
Fix resolved artifacts over android-gradle-plugin 3.0
  • Loading branch information
litmon committed Jun 26, 2018
2 parents 57e07ca + 93c172f commit d79e54c
Show file tree
Hide file tree
Showing 5 changed files with 765 additions and 81 deletions.
51 changes: 0 additions & 51 deletions README.md
Expand Up @@ -156,57 +156,6 @@ Available configuration fields:
forceGenerate: true
```

## Notice
### For Gradle Plugin 3 users
- If you'd like to use `project` like the following, don't forget to set `configuration: 'default'`
- https://stackoverflow.com/questions/45679847/android-studio-3-0-compile-issue-cannot-choose-between-configurations

```gradle
dependencies {
implementation project(path: ':example-dep', configuration: 'default')
}
```

- If your project's dependencies break with `configuration: 'default'`, you can switch which `implementation project()` call like the following control flow.

```gradle
dependencies {
if(project.gradle.startParameter.taskNames.contains("checkLicenses")) {
implementation project(path: ':example-dep', configuration: 'default')
} else {
implementation project(path: ':example-dep')
}
}
```

You can also define method like `implementation_project` in `example/build.gradle` to reduce some boilerplate code.

### For enabling `androidExtensions.experimental = true`
When we run `checkLicense`, the command fails since the command can't resolve dependencies with `aar`s.
The `aar` are generated by `assemble` build.

We can fix the issue calling `checkLicense` after building.

https://github.com/cookpad/license-tools-plugin/pull/84

Or ignore `kotlin-android-extensions` like the below in particular tasks.

```groovy
if (project.gradle.startParameter.taskNames.contains("checkLicenses")
|| project.gradle.startParameter.taskNames.contains("generateLicensePage")
|| project.gradle.startParameter.taskNames.contains("generateLicenseJson")
|| project.gradle.startParameter.taskNames.contains("updateLicenses")
|| project.gradle.startParameter.taskNames.contains("check")) {
// skip `kotlin-android-extensions` to ignore running `aar`s
// https://github.com/JetBrains/kotlin/blob/d6d6cef10dec57aafb909e6dba763ca599a930ec/plugins/android-extensions/android-extensions-idea/src/org/jetbrains/kotlin/android/synthetic/idea/AndroidExtensionsProjectResolverExtension.kt#L94:30
} else {
apply plugin: 'kotlin-android-extensions'
androidExtensions {
experimental = true
}
}
```

## See Also

- [オープンソースライセンスの管理を楽にする -Android アプリ編 - クックパッド開発者ブログ](http://techlife.cookpad.com/entry/2016/04/28/183000)
Expand Down
29 changes: 4 additions & 25 deletions example/build.gradle
Expand Up @@ -7,18 +7,9 @@ repositories {
google() //required for databinding
}

if (project.gradle.startParameter.taskNames.contains("checkLicenses")
|| project.gradle.startParameter.taskNames.contains("generateLicensePage")
|| project.gradle.startParameter.taskNames.contains("generateLicenseJson")
|| project.gradle.startParameter.taskNames.contains("updateLicenses")
|| project.gradle.startParameter.taskNames.contains("check")) {
// skip `kotlin-android-extensions` to ignore running `aar`s
// https://github.com/JetBrains/kotlin/blob/d6d6cef10dec57aafb909e6dba763ca599a930ec/plugins/android-extensions/android-extensions-idea/src/org/jetbrains/kotlin/android/synthetic/idea/AndroidExtensionsProjectResolverExtension.kt#L94:30
} else {
apply plugin: 'kotlin-android-extensions'
androidExtensions {
experimental = true
}
apply plugin: 'kotlin-android-extensions'
androidExtensions {
experimental = true
}

android {
Expand Down Expand Up @@ -71,20 +62,8 @@ licenseTools {
// ]
}

def implementation_project(arg) {
if (project.gradle.startParameter.taskNames.contains("checkLicenses")
|| project.gradle.startParameter.taskNames.contains("generateLicensePage")
|| project.gradle.startParameter.taskNames.contains("generateLicenseJson")
|| project.gradle.startParameter.taskNames.contains("updateLicenses")
|| project.gradle.startParameter.taskNames.contains("check")) {
dependencies.implementation(dependencies.project(path: arg.path, configuration: 'default'))
} else {
dependencies.implementation(dependencies.project(path: arg.path))
}
}

dependencies {
implementation_project(path: ':example-dep')
implementation project(':example-dep')
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:25.3.1'
implementation 'com.android.support:cardview-v7:25.3.1'
Expand Down
18 changes: 18 additions & 0 deletions example/licenses.yml
Expand Up @@ -96,3 +96,21 @@
licenseUrl: https://dev.twitter.com/overview/terms/twitterkit.html
forceGenerate: true
# Libraries not listed in licenses.yml:
- artifact: org.jetbrains.kotlin:kotlin-stdlib:+
name: org.jetbrains.kotlin:kotlin-stdlib
copyrightHolder: JetBrains
license: The Apache License, Version 2.0
licenseUrl: http://www.apache.org/licenses/LICENSE-2.0.txt
url: https://kotlinlang.org/
- artifact: org.jetbrains:annotations:+
name: IntelliJ IDEA Annotations
copyrightHolder: JetBrains
license: The Apache Software License, Version 2.0
licenseUrl: http://www.apache.org/licenses/LICENSE-2.0.txt
url: http://www.jetbrains.org
- artifact: org.jetbrains.kotlin:kotlin-android-extensions-runtime:+
name: org.jetbrains.kotlin:kotlin-android-extensions-runtime
copyrightHolder: JetBrains
license: The Apache License, Version 2.0
licenseUrl: http://www.apache.org/licenses/LICENSE-2.0.txt
url: https://kotlinlang.org/

0 comments on commit d79e54c

Please sign in to comment.