切换到1.3.0后,jQAssistant命令行停止工作

时间:2017-09-26 13:03:26

标签: gradle neo4j jqassistant

我习惯配置gradle构建以在build.gradle中使用jQAssistent(基本上)这个片段:

    project.ext["jqaversion"] = "1.3.0"
    project.ext["jqacoreversion"] = "1.3"
    configurations {
        jqaRuntime
    }

    dependencies {
        // jQA 1.2
    //    jqaRuntime("com.buschmais.jqassistant:commandline:${project.jqaversion}")
        // jQA 1.3
        jqaRuntime("com.buschmais.jqassistant:jqassistant-commandline:${project.jqaversion}")

        jqaRuntime("com.buschmais.jqassistant.plugin:java:${project.jqacoreversion}")
        jqaRuntime("com.buschmais.jqassistant.plugin:junit:${project.jqacoreversion}")
    }

    task removeJQAReport(type: Delete) {
        delete 'jqassistant/report'
        delete 'jqassistant/store'
    }

    task(jqascan, dependsOn: 'removeJQAReport', type: JavaExec) {
        main = 'com.buschmais.jqassistant.commandline.Main'
        classpath = configurations.jqaRuntime
        args 'scan'
        args '-p'
        args 'jqassistant/jqassistant.properties'
        args '-f'
        args 'java:classpath::build/classes/main'
        args 'java:classpath::build/classes/test'
    }

    task(jqaanalyze, type: JavaExec) {
        main = 'com.buschmais.jqassistant.commandline.Main'
        classpath = configurations.jqaRuntime
        args 'analyze'
        args '-r'
        args 'jqassistant/jqassistant-rules'
    }

    task(jqa, dependsOn: ['jqascan', 'jqaanalyze']) {
        jqaanalyze.mustRunAfter jqascan
    }

    task(jqs, type: JavaExec) {
        main = 'com.buschmais.jqassistant.commandline.Main'
        classpath = configurations.jqaRuntime
        args 'server'
        standardInput = System.in
    }

直到jQA 1.2.0才能正常工作。更新到1.3.0后,我遇到了这个例外:

    2017-09-26 14:42:33.793 [main] INFO PluginConfigurationReaderImpl - Loaded jQAssistant plugins [Common, Core Analysis, JUnit, Java, XML].
    2017-09-26 14:42:33.826 [main] INFO StoreFactory - Connecting to store at 'file:/C:/Users/jn/projects/jqa-with-gradle/jqassistant/store'
    Exception in thread "main" java.lang.NoSuchFieldError: BOOLEAN
            at org.neo4j.shell.ShellSettings.<clinit>(ShellSettings.java:42)
            at sun.misc.Unsafe.ensureClassInitialized(Native Method)
            at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:43)
            at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:142)
            at java.lang.reflect.Field.acquireFieldAccessor(Field.java:1088)
            at java.lang.reflect.Field.getFieldAccessor(Field.java:1069)
            at java.lang.reflect.Field.get(Field.java:393)
            at org.neo4j.kernel.configuration.AnnotatedFieldHarvester.findStatic(AnnotatedFieldHarvester.java:47)
            at org.neo4j.kernel.configuration.AnnotationBasedConfigurationMigrator.<init>(AnnotationBasedConfigurationMigrator.java:39)
            at org.neo4j.kernel.configuration.Config.<init>(Config.java:106)
            at org.neo4j.kernel.configuration.Config.<init>(Config.java:96)
            at org.neo4j.kernel.impl.factory.PlatformModule.<init>(PlatformModule.java:127)
            at org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory.createPlatform(GraphDatabaseFacadeFactory.java:232)
            at org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory.initFacade(GraphDatabaseFacadeFactory.java:146)
            at org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory.newFacade(GraphDatabaseFacadeFactory.java:130)
            at org.neo4j.graphdb.factory.GraphDatabaseFactory.newDatabase(GraphDatabaseFactory.java:101)
            at org.neo4j.graphdb.factory.GraphDatabaseFactory.lambda$createDatabaseCreator$0(GraphDatabaseFactory.java:89)
            at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:183)
            at com.buschmais.xo.neo4j.embedded.api.FileDatastoreFactory.createGraphDatabaseService(FileDatastoreFactory.java:31)
            at com.buschmais.xo.neo4j.embedded.api.FileDatastoreFactory.createGraphDatabaseService(FileDatastoreFactory.java:16)
            at com.buschmais.xo.neo4j.embedded.api.EmbeddedNeo4jXOProvider.createDatastore(EmbeddedNeo4jXOProvider.java:24)
            at com.buschmais.xo.impl.XOManagerFactoryImpl.<init>(XOManagerFactoryImpl.java:48)
          m.buschmais.xo.impl.bootstrap.XOBootstrapServiceImpl.createXOManagerFactory(XOBootstrapServiceImpl.java:39)
            at com.buschmais.xo.api.bootstrap.XO.createXOManagerFactory(XO.java:43)
            at com.buschmais.jqassistant.core.store.impl.AbstractGraphStore.start(AbstractGraphStore.java:49)
            at com.buschmais.jqassistant.commandline.task.AbstractTask.run(AbstractTask.java:67)
            at com.buschmais.jqassistant.commandline.Main.executeTask(Main.java:253)
            at com.buschmais.jqassistant.commandline.Main.interpretCommandLine(Main.java:205)
            at com.buschmais.jqassistant.commandline.Main.run(Main.java:91)
            at com.buschmais.jqassistant.commandline.Main.main(Main.java:62)
    :jqascan FAILED

您可以在https://github.com/kontext-e/jqa-gradle

找到完整的示例

Maven项目工作正常,命令行jQA版本无法下载1.3(只有1.2)。

有什么想法吗?我是否必须为1.3?

明确指定Neo4j版本

1 个答案:

答案 0 :(得分:0)

显然,这是一个Gradle类路径问题,因为jQAssistant命令行分配工作正常。所以我通过以下方式修改了build.gradle文件:

    dependencies {
        jqaRuntime("com.buschmais.jqassistant:jqassistant-commandline:${project.jqaversion}") {
            // because jQA 1.3 comes with Neo4j 2 and 3 support, there would be a classpath conflict
            exclude module: 'neo4j'
        }

        jqaRuntime("com.buschmais.jqassistant.plugin:java:${project.jqaversion.substring(0, 3)}")
        jqaRuntime("com.buschmais.jqassistant.plugin:junit:${project.jqaversion.substring(0, 3)}")
    }

https://github.com/kontext-e/jqa-gradle中提到的示例也以这种方式更新。