1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-27 00:38:11 -07:00

Don't warn if a .jar can't be found.

This commit is contained in:
Cedric Beust 2016-06-14 21:00:18 -08:00
parent be866c17b3
commit 438e72038a

View file

@ -25,6 +25,7 @@ import org.eclipse.aether.graph.DependencyNode
import org.eclipse.aether.metadata.DefaultMetadata import org.eclipse.aether.metadata.DefaultMetadata
import org.eclipse.aether.repository.RemoteRepository import org.eclipse.aether.repository.RemoteRepository
import org.eclipse.aether.resolution.* import org.eclipse.aether.resolution.*
import org.eclipse.aether.transfer.ArtifactNotFoundException
import org.eclipse.aether.util.artifact.JavaScopes import org.eclipse.aether.util.artifact.JavaScopes
import org.eclipse.aether.util.filter.AndDependencyFilter import org.eclipse.aether.util.filter.AndDependencyFilter
import org.eclipse.aether.util.filter.DependencyFilterUtils import org.eclipse.aether.util.filter.DependencyFilterUtils
@ -139,13 +140,8 @@ class Aether(val localRepo: File, val settings: KobaltSettings) {
return result return result
} }
fun resolve(artifact: Artifact): List<ArtifactResult>? { fun resolve(artifact: Artifact): List<ArtifactResult> {
try { fun manageException(ex: Exception, artifact: Artifact) : List<ArtifactResult> {
val dependencyRequest = DependencyRequest(collectRequest(artifact), classpathFilter)
val result = system.resolveDependencies(session, dependencyRequest).artifactResults
return result
} catch(ex: DependencyResolutionException) {
if (artifact.extension == "pom") { if (artifact.extension == "pom") {
// Only display a warning for .pom files. Not resolving a .jar or other artifact // Only display a warning for .pom files. Not resolving a .jar or other artifact
// is not necessarily an error as long as there is a pom file. // is not necessarily an error as long as there is a pom file.
@ -153,6 +149,16 @@ class Aether(val localRepo: File, val settings: KobaltSettings) {
} }
return emptyList() return emptyList()
} }
try {
val dependencyRequest = DependencyRequest(collectRequest(artifact), classpathFilter)
val result = system.resolveDependencies(session, dependencyRequest).artifactResults
return result
} catch(ex: ArtifactNotFoundException) {
return manageException(ex, artifact)
} catch(ex: DependencyResolutionException) {
return manageException(ex, artifact)
}
} }
fun transitiveDependencies(artifact: Artifact) = directDependencies(artifact) fun transitiveDependencies(artifact: Artifact) = directDependencies(artifact)