kukido / fitnesse-gradle-classpath

fitnesse-gradle-classpath plugin will let you to use gradle build files to manage dependencies in FitNesse tests
3 stars 7 forks source link

Failed to apply plugin [id 'propdeps'] #3

Open davidmoshal opened 10 years ago

davidmoshal commented 10 years ago

17:58:40.098 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.memcache.InMemoryCachedRepositoryFactory] Creating new in-memory cache for repo 'maven' [11f4a460bd5f5c8d4de0569c8128391]. 17:58:40.155 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder] Visiting configuration :fitnesse-gradle-classpath:unspecified(classpath). 17:58:40.162 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder] Visiting dependency :fitnesse-gradle-classpath:unspecified(classpath) -> org.springframework.build.gradle:propdeps-plugin:0.0.1(dependency: org.springframework.build.gradle#propdeps-plugin;0.0.1 {classpath=[default]}) 17:58:40.165 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder] Selecting new module version org.springframework.build.gradle:propdeps-plugin:0.0.1 17:58:40.165 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainDependencyResolver] Attempting to resolve module 'org.springframework.build.gradle:propdeps-plugin:0.0.1' using repositories [maven] 17:58:40.179 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Opening cache module-metadata.bin (/Users/davem/.gradle/caches/modules-2/metadata-2.13/module-metadata.bin) 17:58:40.245 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.IvyXmlModuleDescriptorParser] post 1.3 ivy file: using exact as default matcher 17:58:40.262 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Using cached module metadata for module 'org.springframework.build.gradle:propdeps-plugin:0.0.1' in 'maven' 17:58:40.265 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainDependencyResolver] Using module 'org.springframework.build.gradle:propdeps-plugin:0.0.1' from repository 'maven' 17:58:40.268 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder] Visiting configuration org.springframework.build.gradle:propdeps-plugin:0.0.1(default). 17:58:40.271 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.ResolvedConfigurationDependencyGraphVisitor] Attaching :fitnesse-gradle-classpath:unspecified(classpath) to its parents. 17:58:40.274 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.ResolvedConfigurationDependencyGraphVisitor] Attaching org.springframework.build.gradle:propdeps-plugin:0.0.1(default) to its parents. 17:58:40.285 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.oldresult.TransientConfigurationResultsBuilder] Flushing resolved configuration data in Binary store in /private/var/folders/gd/qgg5gjt90_n6dcywjrm3jccc0000gn/T/gradle6839827972093238881.bin. Wrote root :fitnesse-gradle-classpath:unspecified:classpath. 17:58:40.307 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Opening cache artifact-at-repository.bin (/Users/davem/.gradle/caches/modules-2/metadata-2.13/artifact-at-repository.bin) 17:58:40.312 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Found artifact 'org.springframework.build.gradle:propdeps-plugin:0.0.1:propdeps-plugin.jar' in resolver cache: /Users/davem/.gradle/caches/modules-2/files-2.1/org.springframework.build.gradle/propdeps-plugin/0.0.1/fe44c3b38db2f5169adfba91e1577eaf6d476948/propdeps-plugin-0.0.1.jar 17:58:40.320 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on no_buildscript class cache for build file '/Users/davem/Documents/literate-programming/fitness/fitnesse-gradle-classpath/build.gradle' (/Users/davem/.gradle/caches/2.1/scripts/build_7c6mbhdps5rk623vu5bppm2ffk/ProjectScript/no_buildscript). 17:58:40.321 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired. 17:58:41.478 [DEBUG] [org.gradle.configuration.project.BuildScriptProcessor] Timing: Running the build script took 1.779 secs 17:58:41.500 [ERROR] [org.gradle.BuildExceptionReporter] 17:58:41.501 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception. 17:58:41.503 [ERROR] [org.gradle.BuildExceptionReporter] 17:58:42.348 [ERROR] [org.gradle.BuildExceptionReporter] * Where: 17:58:42.348 [ERROR] [org.gradle.BuildExceptionReporter] Build file '/Users/davem/Documents/literate-programming/fitness/fitnesse-gradle-classpath/build.gradle' line: 14 17:58:42.364 [ERROR] [org.gradle.BuildExceptionReporter] 17:58:42.365 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong: 17:58:42.365 [ERROR] [org.gradle.BuildExceptionReporter] A problem occurred evaluating root project 'fitnesse-gradle-classpath'. 17:58:42.366 [ERROR] [org.gradle.BuildExceptionReporter] > Failed to apply plugin [id 'propdeps'] 17:58:42.366 [ERROR] [org.gradle.BuildExceptionReporter] > java.lang.String cannot be cast to org.gradle.api.artifacts.Configuration 17:58:42.366 [ERROR] [org.gradle.BuildExceptionReporter] 17:58:42.367 [ERROR] [org.gradle.BuildExceptionReporter] * Try: 17:58:42.367 [ERROR] [org.gradle.BuildExceptionReporter] Run with --stacktrace option to get the stack trace. 17:58:42.368 [LIFECYCLE] [org.gradle.BuildResultLogger] 17:58:42.369 [LIFECYCLE] [org.gradle.BuildResultLogger] BUILD FAILED 17:58:42.369 [LIFECYCLE] [org.gradle.BuildResultLogger] 17:58:42.369 [LIFECYCLE] [org.gradle.BuildResultLogger] Total time: 4.319 secs

davidmoshal commented 10 years ago

OK, so I got this to build, but quite a process!

Firstly I couldn't find any project called: "propdeps-plugin" as required in line #9 (which caused the failure):

    dependencies {
        classpath 'org.springframework.build.gradle:propdeps-plugin:0.0.1
    }

In fact, I couldn't find a group in MavenCentral with the name "org.springframework.build.gradle".

I did however find this project which has a sub-project called "propdeps-plugin": https://github.com/spring-projects/gradle-plugins

Just to complicate matters, that project also wouldn't build. ie: "gradle jar" failed

So, in the settings.gradle file in that project, I had to comment out the other projects (which were failing):

rootProject.name = 'gradle-plugins'
//include 'bundlor-plugin'
//include 'docbook-reference-plugin'
include 'propdeps-plugin'
//include 'spring-io-plugin'

and, also in that project, I had to comment out the parts of the build.gradle file which reference those plugins:

buildscript {
    repositories {
        maven { url 'https://repo.spring.io/plugins-release' }
    }
    dependencies {
        classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:2.2.2'
    }
}

allprojects {
    apply plugin: 'idea'
    apply plugin: 'eclipse'
}

subprojects {
    apply plugin: 'groovy'
    apply plugin: 'maven'
    apply plugin: 'artifactory'

    group = 'org.springframework.build.gradle'

    repositories {
        maven { url 'https://repo.spring.io/libs-release' }
    }

    dependencies {
        compile gradleApi()
        compile localGroovy()
    }
}

/*
project(':spring-io-plugin') {
    version = springIoPluginVersion

    dependencies {
        testCompile 'org.spockframework:spock-core:0.7-groovy-1.8'
    }
}

project(':bundlor-plugin') {
    version = bundlorPluginVersion
    // dependencies are configured within BundlorPlugin
}

project(':docbook-reference-plugin') {
    version = '0,1,6' //docbookPluginVersion
    dependencies {
        compile 'net.sf.docbook:docbook-xsl:1.75.2:resources@zip'
        compile 'net.sf.docbook:docbook-xml:5.0:xsd-resources@zip'
        compile 'net.sf.docbook:docbook-xsl-saxon:1.0.0'
        compile 'org.apache.xerces:resolver:2.9.1'
        compile 'org.apache.xerces:xercesImpl:2.9.1'
        compile 'saxon:saxon:6.5.3'
        compile 'net.sf.xslthl:xslthl:2.0.1'
        compile 'org.apache.xmlgraphics:fop:0.95-1@jar'
        compile 'org.apache.xmlgraphics:xmlgraphics-commons:1.3'
        compile 'org.apache.xmlgraphics:batik-bridge:1.7@jar'
        compile 'org.apache.xmlgraphics:batik-util:1.7@jar'
        compile 'org.apache.xmlgraphics:batik-css:1.7@jar'
        compile 'org.apache.xmlgraphics:batik-dom:1.7'
        compile 'org.apache.xmlgraphics:batik-svg-dom:1.7@jar'
        compile 'org.apache.avalon.framework:avalon-framework-api:4.3.1'
    }

    task copyDocbookResources {
        outputs.dir "${project.buildDir}/docbook"

        doLast() {
            def docbookZip = configurations.compile.files.find { file -> file.name.contains('docbook-xsl-')};

            copy { // copy all images and highlighting files from docbook dist
                from zipTree(docbookZip)
                include 'docbook/images/**'
                include 'docbook/highlighting/**'
                into project.buildDir
            }

            copy { // copy docbook resources from src/main
                from 'src/main/docbook'
                into "${project.buildDir}/docbook"
            }
        }
    }

    task docbookResourcesZip(type: Zip, dependsOn: copyDocbookResources) {
        from copyDocbookResources.outputs.files
        destinationDir = new File(project.sourceSets.main.output.classesDir, "META-INF")
        archiveName = 'docbook-resources.zip'
    }

    jar.dependsOn docbookResourcesZip
}
*/

ext.repoUser = project.properties['REPO_USERNAME']
ext.repoPass = project.properties['REPO_PASSWORD']

gradle.taskGraph.whenReady {taskGraph ->
    if (taskGraph.hasTask(':docbook-reference-plugin:artifactoryPublish') &&
            (repoUser == null || repoPass == null)) {
        logger.warn("WARNING: artifactoryPublish task specified but REPO_USERNAME " +
            "and REPO_PASSWORD properties have not been provided. Authorization may fail.")
    }
}

artifactory {
    contextUrl = 'https://repo.spring.io'
    publish {
        repository {
            repoKey = 'plugins-snapshot-local'
            username = repoUser
            password = repoPass
        }
        defaults {
            publishConfigs('archives')
        }
    }
    resolve {
        repository {
            repoKey = 'libs-releases'
            username = repoUser
            password = repoPass
            maven = true
        }
    }
}

task wrapper(type: Wrapper) {
    description = 'Generates gradlew[.bat] scripts'
    gradleVersion = '1.11'
}

So, now that project was able to build the jar: propdeps-plugin:0.0.8-SNAPSHOT.jar

Then, I move that jar to a directory in the fitnesse-gradle-classpath project (this project), and put it in a folder \lib. I edited the buildscript section of the build.gradle file in this project to be able to find that jar in the local lib directory.

buildscript {
    repositories {
        maven { url 'http://repo.springsource.org/plugins-release' }
        flatDir {
            dirs 'lib'
        }
    }
    dependencies {
        classpath 'org.springframework.build.gradle:propdeps-plugin:0.0.8-SNAPSHOT'
    }
}

apply plugin: 'java'
apply plugin: 'findbugs'

configure(allprojects) {
    apply plugin: 'propdeps'
}

repositories {
    maven {
        url 'http://repo.gradle.org/gradle/libs-releases-local'
    }
    mavenCentral()
}

dependencies {
    compile 'org.gradle:gradle-tooling-api:1.6'
    provided 'org.fitnesse:fitnesse:20130531'
    testCompile 'junit:junit:4.11'
}

jar {
    from configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}

Now gradle build produced : fitnesse-gradle-classpath.jar

I have yet try the jar out with the latest version of Fitnesse. Assuming it works, it might be worth commiting the above propdeps dependency into a lib directory, and making the above changes to build.gradle.

davidmoshal commented 10 years ago

Well, after copying the above plugin, and creating plugins.properties, as described on the readme file of this project, turns out that this class doesn't exist:

fitnesse.wikitext.widgets.GradleClasspathSymbolType

java -jar fitnesse-standalone.jar -p 9090
Exception in thread "main" fitnesse.PluginException: Unable to load class fitnesse.wikitext.widgets.GradleClasspathSymbolType
    at fitnesse.PluginsLoader.forName(PluginsLoader.java:206)
    at fitnesse.PluginsLoader.loadSymbolTypes(PluginsLoader.java:122)
    at fitnesse.ContextConfigurator.makeFitNesseContext(ContextConfigurator.java:149)
    at fitnesseMain.FitNesseMain.launchFitNesse(FitNesseMain.java:62)
    at fitnesseMain.FitNesseMain.launchFitNesse(FitNesseMain.java:51)
    at fitnesseMain.FitNesseMain.main(FitNesseMain.java:35)
Caused by: java.lang.ClassNotFoundException: fitnesse.wikitext.widgets.GradleClasspathSymbolType
    at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:259)
    at fitnesse.PluginsLoader.forName(PluginsLoader.java:204)
    ... 5 more
davidmoshal commented 10 years ago

Ok, got this to work. The key is to create a plugins directory at the same level as the fitnesse-standalone.jar

ie: NOT /FitNessRoot as described in the readme of this project, but one directory higher.

java -jar fitnesse-standalone-20140901.jar -p 9090
Loaded SymbolType fitnesse.wikitext.widgets.GradleClasspathSymbolType
Bootstrapping FitNesse, the fully integrated standalone wiki and acceptance testing framework.
root page: fitnesse.wiki.fs.FileSystemPage at ./FitNesseRoot#latest
logger: none
authenticator: fitnesse.authentication.PromiscuousAuthenticator
page factory: fitnesse.html.template.PageFactory
page theme: fitnesse_straight
Starting FitNesse on port: 9090
xubean commented 9 years ago

Strangely enough, I started with the same problem. However, unlike you @davidmoshal I just changed the dependencies here:

dependencies {
    classpath 'org.springframework.build.gradle:propdeps-plugin:0.0.1
}

to

dependencies {
    classpath 'org.springframework.build.gradle:propdeps-plugin:0.0.7
}

and that worked. After rebuilding gradle and copying over the jar files as instructions, I end up with this error however:

java -jar fitnesse-standalone.jar -p 8080
Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
at sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:286)
at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:239)
at java.util.jar.JarVerifier.processEntry(JarVerifier.java:274)
at java.util.jar.JarVerifier.update(JarVerifier.java:228)
at java.util.jar.JarFile.initializeVerifier(JarFile.java:348)
at java.util.jar.JarFile.getInputStream(JarFile.java:415)
at sun.misc.URLClassPath$JarLoader$2.getInputStream(URLClassPath.java:775)
at sun.misc.Resource.cachedInputStream(Resource.java:77)
at sun.misc.Resource.getByteBuffer(Resource.java:160)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:436)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:191)
at fitnesse.PluginsLoader.forName(PluginsLoader.java:202)
at fitnesse.PluginsLoader.loadSymbolTypes(PluginsLoader.java:120)
at fitnesse.ContextConfigurator.makeFitNesseContext(ContextConfigurator.java:145)
at fitnesseMain.FitNesseMain.launchFitNesse(FitNesseMain.java:59)
at fitnesseMain.FitNesseMain.launchFitNesse(FitNesseMain.java:48)
at fitnesseMain.FitNesseMain.main(FitNesseMain.java:32) 
twodarek commented 9 years ago

Following @davidmoshal 's steps, I was still getting the following error:

java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
    at sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:286)
    at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:239)
    at java.util.jar.JarVerifier.processEntry(JarVerifier.java:274)
    at java.util.jar.JarVerifier.update(JarVerifier.java:228)
    at java.util.jar.JarFile.initializeVerifier(JarFile.java:348)
    at java.util.jar.JarFile.getInputStream(JarFile.java:415)
    at sun.misc.URLClassPath$JarLoader$2.getInputStream(URLClassPath.java:775)
    at sun.misc.Resource.cachedInputStream(Resource.java:77)
    at sun.misc.Resource.getByteBuffer(Resource.java:160)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:436)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:191)
    at fitnesse.plugins.PropertyBasedPluginFeatureFactory.forName(PropertyBasedPluginFeatureFactory.java:198)
    at fitnesse.plugins.PropertyBasedPluginFeatureFactory.forEachClass(PropertyBasedPluginFeatureFactory.java:143)
    at fitnesse.plugins.PropertyBasedPluginFeatureFactory.forEachObject(PropertyBasedPluginFeatureFactory.java:150)
    at fitnesse.plugins.PropertyBasedPluginFeatureFactory.registerSymbolTypes(PropertyBasedPluginFeatureFactory.java:75)
    at fitnesse.plugins.PluginsLoader.loadSymbolTypes(PluginsLoader.java:83)
    at fitnesse.ContextConfigurator.makeFitNesseContext(ContextConfigurator.java:151)
    at fitnesseMain.FitNesseMain.launchFitNesse(FitNesseMain.java:65)
    at fitnesseMain.FitNesseMain.launchFitNesse(FitNesseMain.java:54)
    at fitnesseMain.FitNesseMain.main(FitNesseMain.java:34)

It turns out that Spring is signing jars and the java classloader didn't like the combined signatures. I got around this by having the jar packaging step exclude signatures (VERY hacky, but I'm in the middle of a hack-a-thon, so meh). Here's the updated build.gradle that excludes signatures:

buildscript {
    repositories {
        maven { url 'http://repo.springsource.org/plugins-release' }
        flatDir {
            dirs 'lib'
        }
    }
    dependencies {
        classpath 'org.springframework.build.gradle:propdeps-plugin:0.0.8-SNAPSHOT'
    }
}

apply plugin: 'java'
apply plugin: 'findbugs'

configure(allprojects) {
    apply plugin: 'propdeps'
}

repositories {
    maven {
        url 'http://repo.gradle.org/gradle/libs-releases-local'
    }
    mavenCentral()
}

dependencies {
    compile 'org.gradle:gradle-tooling-api:1.6'
    provided 'org.fitnesse:fitnesse:20150226'
    testCompile 'junit:junit:4.11'
}

jar {
    from (configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }) {
        // remove all signature files
        exclude "META-INF/*.SF"
        exclude "META-INF/*.DSA"
        exclude "META-INF/*.RSA"
    }
}