cbeust / kobalt

A Kotlin-based build system for the JVM.
Apache License 2.0
433 stars 60 forks source link

collect() and dependencies current issues #392

Closed ethauvin closed 7 years ago

ethauvin commented 7 years ago

Assuming:

    dependencies {
        compile("org.apache.velocity:velocity:1.7")
    }

which resolves to:

╟ commons-collections:commons-collections:jar:3.2.1
╟ commons-lang:commons-lang:jar:2.4
╙ oro:oro:jar:2.0.8 (optional)

collect(compileDependencies) will return velocity, commons-collections and commons-lang as expected.

Change to:

    dependencies {
        compile("org.apache.velocity:velocity:jar:1.7")
    }

collect(compileDependencies) will still return all three dependencies, not just velocity.

ethauvin commented 7 years ago

collect(compileDependencies) returns List<File>, which works in most case.

Assuming:

    dependencies {
        compile("org.apache.velocity:velocity:1.7")
        compile("example.com:foo:bar:1.0")
    }

How can I have velocity copied to my install target directory, but not foo.bar?

install {
        target = deploy
        collect(compileDependencies).forEach {
            if (it.absolutePath.contains("velocity")) {
                copy(from(it.absolutePath), to("$target/lib"))
            }
        }
}

Pretty weak, IMHO.

Is it viable to make collect() return both files and Maven coordinates?

cbeust commented 7 years ago

Sure but how would that help? You'd still need an if here.

-- Cédric

On Thu, Apr 6, 2017 at 8:00 PM, Erik C. Thauvin notifications@github.com wrote:

collect(compileDependencies) returns List, which works in most case.

Assuming:

dependencies {
    compile("org.apache.velocity:velocity:1.7")
    compile("example.com:foo:bar:1.0")
}

How can I have velocity copied to my install target directory, but not foo.bar?

install { target = deploy collect(compileDependencies).forEach { if (it.absolutePath.contains("velocity")) { copy(from(it.absolutePath), to("$target/lib")) } } }

Pretty weak, IMHO.

Is it viable to make collect() return both files and Maven coordinates?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/cbeust/kobalt/issues/392#issuecomment-292413326, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFoohIRWy3Qtna2-ym5aMq-sJQnMF-oks5rtabkgaJpZM4M2Y6M .

ethauvin commented 7 years ago

True, but it is a very weak if, because I have no clues as to what the filename is.

Take a scenario when multiple packages use a different version of 'commons-lang`, but I would only want the most recent version to be in my deployment directory; unless I hard-code the filename, there's no way to do it. On the other hand, if I can compare against my previously specified coordinates, I'm good.

ethauvin commented 7 years ago

As discussed, compileAptDependencies should be implemented for use in collect()

cbeust commented 7 years ago

So should I add a collectIds() directive or have collect() return both the file name and id?

ethauvin commented 7 years ago

I'm not wild about collectIds().

collect() could return both, or you could use a flag parameter, collect(dependencies: List<IClasspathDependency>, mavenIds: Boolean = false) or something like that.

ethauvin commented 7 years ago

I take that back, collect() returning both, is best. It'll allow for one call to collect() to check for multiple options, e.g.:


collect(compileDependencies).forEach {
    if (it.file.abolutePath.equals("blah")) {
        ...
    } else if (it.id.equals("foo") {
        ...
    }
}
ethauvin commented 7 years ago

Any comments on https://github.com/cbeust/kobalt/issues/392#issue-220091021?

That's a big one for me, and I think that's a caching issue.

ethauvin commented 7 years ago

Let me expand on https://github.com/cbeust/kobalt/issues/392#issue-220091021

I'm using an annotator, which requires both apt(annotatorJar) and compile(annotatorJar), like most do.

The problem is when I'm using collect(compileDependencies), I'm getting the annotator jar and it's dependencies, but I don't really need them to be deployed to the install target.

Gradle addresses that issue by providing a compileOnly 'annotatorJar' directive. Meaning that when collecting the compile dependencies, no annotator dependencies will be included.

cbeust commented 7 years ago

Fixed in 1.0.55.