gradle / kotlin-dsl-samples

Samples builds using the Gradle Kotlin DSL
https://gradle.org/kotlin/
Other
3.71k stars 433 forks source link

[Question] Can a plugin dependency version be included in a pre-compiled script #1390

Closed eldritch-dream closed 5 years ago

eldritch-dream commented 5 years ago

Expected Behavior

I am using the kotlin-dsl plugin to build a pre-compiled script plugin that depends on the artifactory plugin as shown below. What I would expect is that the version of the artifactory plugin would be included in the jar that gets produced so I could use my plugin in a different project without including the artifactory plugin with a defined version at the top level.

build.gradle.kts

plugins {
    `kotlin-dsl`
}

repositories {
    maven {
        url = uri("http://artifactory.wal.hds.com/artifactory/maven/")
    }
    maven {
        url = uri("http://artifactory.wal.hds.com/artifactory/plugins-gradle-remote")
    }
}

dependencies {
    implementation("com.jfrog.artifactory:com.jfrog.artifactory.gradle.plugin:4.9.9")
    implementation("org.jfrog.buildinfo:build-info-extractor-gradle:4.9.9")
} 

myPlugin.gradle.kts

plugins {
    id("com.jfrog.artifactory")
    `maven-publish`
}

val artifactoryUrl = "http://some.artifactory.url"

artifactory {
    setContextUrl(artifactoryUrl)
    publish(closureOf<PublisherConfig> {
        repository(delegateClosureOf<GroovyObject> {
            setProperty("repoKey", project.properties.get("artifactoryPublishRepository"))
            setProperty("username", project.properties.get("art-uname"))
            setProperty("password", project.properties.get("art-pw"))
        })
        defaults(closureOf<ArtifactoryTask> {
            publications("forDist")
            setPublishPom(false)
            setPublishIvy(false)
        })
    })
}

Current Behavior

Currently when I want to use my published plugin I have to do so as shown below. Without the artifactory plugin line, my-plugin complains that it doesn't know what the com.jfrog.artifactory plugin is like so. I am fairly certain that this error message is because my-plugin doesn't know which version of the artifactory plugin to use.

> Failed to apply plugin [id 'fnd-artifacts']
   > Plugin with id 'com.jfrog.artifactory' not found.

Some other project build.gradle.kts

plugins {
    id("com.jfrog.artifactory") version "4.9.9"
    id("my-plugin") version "1.0"
}

Is it possible to do what I am trying to do? If so could an example be created to help other people down the line?

Thanks

eskatos commented 5 years ago

This repository, kotlin-dsl-samples is only for extra Kotlin DSL samples. Please open Gradle Kotlin DSL issues on the gradle/gradle repository. I'll move this issue to gradle/gradle.

eskatos commented 5 years ago

Issue moved to gradle/gradle #10990 via ZenHub

eldritch-dream commented 5 years ago

I was asking for a sample to show a resolution to my question. Is this not the right place for that?