Skip to content

Address "path may not be null or empty" issue in UnusedTracker#478

Closed
sormuras wants to merge 2 commits intoGradleUp:masterfrom
sormuras:check-for-nullable-jar-in-unused-tracker
Closed

Address "path may not be null or empty" issue in UnusedTracker#478
sormuras wants to merge 2 commits intoGradleUp:masterfrom
sormuras:check-for-nullable-jar-in-unused-tracker

Conversation

@sormuras
Copy link
Copy Markdown
Contributor

@sormuras sormuras commented Apr 2, 2019

Adresses issue #425 by preventing null values being added to the list of api jars.

Note: this PR also relaxes the filter predicate from it.name.endsWith("${dep.name}.jar") to it.name.contains("${dep.name}") && it.name.endsWith(".jar"). Not sure, if this a) allows wrong jars to be included and if it b) helps @swankjesse's use-cases described here: #425 (comment)

This PR is effectively a duplicate of #477

apiJars.addAll(getApiJarsFromProject(dep.dependencyProject))
apiJars.add(runtimeConfiguration.find { it.name.endsWith("${dep.name}.jar") } as File)
def jar = runtimeConfiguration.find { it.name.contains("${dep.name}") && it.name.endsWith(".jar") }
if (jar != null) apiJars.add(jar as File)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since ProjectDependency extends SelfResolvingDependency I'm wondering why this first if clause is needed at all. Couldn't we just call resolve()?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Running a build without the first if clause...

What's the purpose of the final else branch checking for it.name.startsWith("${dep.name}-"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Without the first if clause two integration tests fail:

com.github.jengelman.gradle.plugins.shadow.ShadowPluginSpec > use minimize with dependencies with api scope FAILED
org.spockframework.runtime.ConditionNotSatisfiedError at ShadowPluginSpec.groovy:556

com.github.jengelman.gradle.plugins.shadow.ShadowPluginSpec > use minimize with transitive dependencies with api scope FAILED
org.spockframework.runtime.ConditionNotSatisfiedError at ShadowPluginSpec.groovy:632

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Bad tests or it has to do with minimize...

@sormuras
Copy link
Copy Markdown
Contributor Author

sormuras commented Apr 2, 2019

Added link to #477 in initial description of this PR.

@sormuras
Copy link
Copy Markdown
Contributor Author

sormuras commented Apr 3, 2019

Produces another error in real-world scenario:

Caused by: java.lang.IllegalArgumentException: neither file nor directory
	at shadow.org.vafer.jdependency.Clazzpath.addClazzpathUnit(Clazzpath.java:122)
	at shadow.org.vafer.jdependency.Clazzpath.addClazzpathUnit(Clazzpath.java:95)
	at shadow.org.vafer.jdependency.Clazzpath.addClazzpathUnit(Clazzpath.java:86)
	at shadow.org.vafer.jdependency.Clazzpath$addClazzpathUnit.call(Unknown Source)
	at com.github.jengelman.gradle.plugins.shadow.internal.UnusedTracker$_closure2.doCall(UnusedTracker.groovy:22)

@sormuras sormuras closed this Apr 3, 2019
@sormuras sormuras deleted the check-for-nullable-jar-in-unused-tracker branch April 3, 2019 15:55
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