Use jwebassemble-gradle plugin from local jar

50 Views Asked by At

I created a build of jwebassembly-gradle, and I have copied the jar, source jar, and javadoc jar files to a subdirectory called “libs” in my project directory structure. I am using Gradle 6.8.2. I am getting the error:

“Plugin [id: ‘jwebassembly-gradle’] was not found in any of the following sources:”

How can I fix this? All the searches I have done say this should work. The directory structure is similar to:

Project
- .gradle
- src
- build
- libs

The build.gradle file:

// this handles the actual build script (build.gradle) dependencies!
buildscript {
    repositories {
        flatDir {
            // to use local builds
            dirs 'libs'
        }
    }
    dependencies {
        classpath fileTree(include: ['*.jar'], dir: 'libs')
        classpath files('libs/jwebassembly-gradle-0.4.jar')
        classpath files('libs/jwebassembly-gradle-0.4-sources.jar')
        classpath files('libs/jwebassembly-gradle-0.4-javadoc.jar')
    }
}

plugins {
    id 'java'
    id 'application'
    id 'jwebassembly-gradle'
}

repositories {
    flatDir {
        // to use local builds
        dirs 'libs'
    }
    mavenCentral()
}


jar {
    manifest {
        attributes(
            "Specification-Title" : "",
            "Specification-Version" : project.version,
            "Specification-Vendor" : "",
            "Implementation-Title" : project.group,
            "Implementation-Version" : project.version,
            "Implementation-Vendor" : "",
            "Main-Class" : "com.myproject.UrlImageGrabber"
        )
    }
}

dependencies {
    classpath fileTree(include: ['*.jar'], dir: 'libs')
    classpath files('libs/jwebassembly-gradle-0.4.jar')
    classpath files('libs/jwebassembly-gradle-0.4-sources.jar')
    classpath files('libs/jwebassembly-gradle-0.4-javadoc.jar')

    // other dependencies ..

}

task sourcesJar(type: Jar) {
   archiveBaseName=artifactBaseName
   classifier 'sources'
   from sourceSets.main.allSource
}

task javadocJar(type: Jar, dependsOn: javadoc) {
   archiveBaseName=artifactBaseName
   classifier 'javadoc'
   from javadoc.destinationDir
}

task(debug, dependsOn: 'classes', type: JavaExec) {
    main = mainClassName
    classpath = sourceSets.main.runtimeClasspath
    args ''
    debug true
}

//task webAssembly() {
//
//}

build {
    doLast {
//        webAssembly()
    }
}

artifacts {
   archives sourcesJar
   archives javadocJar
}

I have tried various forms of trying to include the jar files in the buildscript section of the build.gradle file. I still get the error.

1

There are 1 best solutions below

0
Horcrux7 On

I think you can't use the plugins ID syntax with local plugins. This syntax works only with the Gradle plugin database.

Use instead the apply syntax:

apply plugin: 'de.inetsoftware.jwebassembly'