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

Avoid processing *.aar dependencies which can not be parsed and cause gradle failures #172

Conversation

flobetz
Copy link
Contributor

@flobetz flobetz commented Feb 15, 2022

Starting with the Android gradle plugin com.android.tools.build:gradle version 7.1.0 the dependency resolution changed and therefore different dependency types like '.aar' appear within the list of resolved artifacts/dependencies.
These types have to be excluded before parsing a dependency to avoid failures.
Currently .aar dependencies will cause following error:

> Task :app:licenseReleaseReport
circularimageview dependency does not have a license.
[Fatal Error] vectordrawable-animated-1.1.0.aar:1:1: Content is not allowed in prolog.

> Task :app:licenseReleaseReport FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:licenseReleaseReport'.
> org.xml.sax.SAXParseException; systemId: file:///home/user/caches/modules-2/files-2.1/androidx.vectordrawable/vectordrawable-animated/1.1.0/fcda1161354501471c30a4e077af6b5c4d4eddc6/vectordrawable-animated-1.1.0.aar; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 21s
11 actionable tasks: 5 executed, 6 up-to-date

if (resolvedArtifact.type != "pom") {
return@forEach
}

val pomFile = resolvedArtifact.file
val node = xmlParser.parse(pomFile)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

with the android gradle plugin < 7.1.0 following dependencies are getting resolved within our example project:

resolvedArtifact.id: vectordrawable-animated-1.1.0.pom (androidx.vectordrawable:vectordrawable-animated:1.1.0)
resolvedArtifact.type: pom
resolvedArtifact.file: /Users/flobetz/.gradle/caches/modules-2/files-2.1/androidx.vectordrawable/vectordrawable-animated/1.1.0/2c40e16427f4e94ea471526868ba5ac4bd13de6d/vectordrawable-animated-1.1.0.pom

with the android gradle plugin >= 7.1.0 following dependencies are getting resolved within our example project:

resolvedArtifact.id: vectordrawable-animated-1.1.0.pom (androidx.vectordrawable:vectordrawable-animated:1.1.0)
resolvedArtifact.type: pom
resolvedArtifact.file: /Users/flobetz/.gradle/caches/modules-2/files-2.1/androidx.vectordrawable/vectordrawable-animated/1.1.0/2c40e16427f4e94ea471526868ba5ac4bd13de6d/vectordrawable-animated-1.1.0.pom
-----
resolvedArtifact.id: vectordrawable-animated-1.1.0.aar (androidx.vectordrawable:vectordrawable-animated:1.1.0)
resolvedArtifact.type: aar
resolvedArtifact.file: /Users/flobetz/.gradle/caches/modules-2/files-2.1/androidx.vectordrawable/vectordrawable-animated/1.1.0/fcda1161354501471c30a4e077af6b5c4d4eddc6/vectordrawable-animated-1.1.0.aar

The gradle-license-plugin will obvously fail when trying to parse a .aar file which is currently done at L173
@jaredsburrows can you have a look at this please?

@flobetz flobetz force-pushed the feat/flobetz/exclude-non-pom-dependencies branch from 30255d2 to 6e4d4e9 Compare February 16, 2022 09:20
@flobetz flobetz marked this pull request as draft April 7, 2022 11:39
@flobetz flobetz force-pushed the feat/flobetz/exclude-non-pom-dependencies branch from 6e4d4e9 to b0b301e Compare April 7, 2022 11:40
… gradle failures

With the Android gradle plugin 'com.android.tools.build:gradle:7.1.0' the dependency resolution changed and therefore different dependency types like '.aar' appear within the list of resolved artifacts/dependencies.
These types have to be excluded before parsing a dependency to avoid failures.
Currently .aar dependencies will cause following error:
```
> Task :app:licenseReleaseReport
circularimageview dependency does not have a license.
[Fatal Error] vectordrawable-animated-1.1.0.aar:1:1: Content is not allowed in prolog.

> Task :app:licenseReleaseReport FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:licenseReleaseReport'.
> org.xml.sax.SAXParseException; systemId: file:///home/user/caches/modules-2/files-2.1/androidx.vectordrawable/vectordrawable-animated/1.1.0/fcda1161354501471c30a4e077af6b5c4d4eddc6/vectordrawable-animated-1.1.0.aar; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 21s
11 actionable tasks: 5 executed, 6 up-to-date
```
@flobetz flobetz force-pushed the feat/flobetz/exclude-non-pom-dependencies branch from b0b301e to 57b7b0c Compare April 7, 2022 11:40
@flobetz flobetz marked this pull request as ready for review April 7, 2022 11:50
@jaredsburrows jaredsburrows merged commit a0b5036 into jaredsburrows:master Apr 8, 2022
@jaredsburrows
Copy link
Owner

Thanks! I will work on a release soon!

@flobetz flobetz deleted the feat/flobetz/exclude-non-pom-dependencies branch April 8, 2022 07:04
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.

2 participants