ysb33r / ivypot-gradle-plugin

Ivypot is a Gradle plugin to help managing a local off-line repository for builds in restricted environments
Apache License 2.0
45 stars 14 forks source link

Use in build.gradle.kts (i.e. Kotlin-DSL for Gradle) #45

Closed phreed closed 4 years ago

phreed commented 4 years ago

This is a multi-project.

Starting a Gradle Daemon (subsequent builds will be faster) Configuration on demand is an incubating feature.

FAILURE: Build failed with an exception.

settings.gradle.kts

pluginManagement {
    plugins {
        kotlin("multiplatform").version("1.3.61")
        kotlin("jvm").version("1.3.61")
        kotlin("kapt").version("1.3.61")

        id("org.gradle.kotlin.embedded-kotlin").version("1.3.3")
        id("org.gradle.kotlin.kotlin-dsl").version("1.3.3")
        id("org.ysb33r.ivypot").version("0.10")
    }
    repositories {
        gradlePluginPortal()
        mavenCentral()
        jcenter()
    }
}
...
}

build.gradle.kts


plugins {
    id("java-library")
    id("maven-publish")
    kotlin("jvm") version "1.3.41"
    id("distribution")
    id ( "org.ysb33r.ivypot")
}
...
allprojects {
...
    tasks {
        named<org.ysb33r.gradle.ivypot.OfflineRepositorySync>("syncRemoteRepositories") {
            repoRoot("${buildDir}/offlineRepo")
            repositories {
                jcenter()
            }
        }
    }
...
}

sync/build.gradle.kts

plugins {
    id ( "org.ysb33r.ivypot")
}
val offlineRepoDir by extra { "${rootProject.projectDir}/repo" }
...
tasks {
    named<org.ysb33r.gradle.ivypot.OfflineRepositorySync>("syncRemoteRepositories") {
        val offlineRepoDir : String? by extra

        addAllProjects()
...
}
...
phreed commented 4 years ago

Excerpts from the stack-trace

* Exception is:
org.gradle.api.plugins.InvalidPluginException: An exception occurred applying plugin request [id: 'org.ysb33r.ivypot', version: '0.10']

at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.exceptionOccurred(DefaultPluginRequestApplicator.java:253)
...
Caused by: 
org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [id 'org.ysb33r.ivypot']
...
Caused by: 
org.gradle.api.internal.tasks.DefaultTaskContainer$TaskCreationException: Could not create task ':syncRemoteRepositories'.
...
Caused by: 
org.gradle.api.tasks.TaskInstantiationException: Could not create task of type 'OfflineRepositorySync'.
...
Caused by: 
java.lang.UnsupportedOperationException
phreed commented 4 years ago

The problem is with the version. By switching to version 0.9 (instead of 0.10) it seems to work correctly.

ysb33r commented 4 years ago

Great. I'll close this.