当前位置: 首页 > 知识库问答 >
问题:

无法更改配置SQLite的策略

微生耘豪
2023-03-14

在我的Gradle项目中,我对SQLite有一个依赖项。

这是我的build.gradle:

 import groovy.sql.Sql

    buildscript {
        ext{
            osPackageVersion = "3.4.0"
            kotlin_version = '1.2.41'
            requery_version = '1.5.1'
            sqlite_jdbc = '3.7.2'
            rxkotlin_version = '2.2.0'
            sqlDirPath = "src" + File.separator + "main" + File.separator + "Resources" + File.separator + "TestAppDbInit.sql"
        }

        repositories {
            mavenCentral()
            jcenter()
            maven{
                url "https://plugins.gradle.org/m2/"
            }
        }
        dependencies {
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
            classpath "edu.sc.seis.gradle:launch4j:2.4.4"
            classpath group: 'org.jooq', name: 'jooq-meta-extensions', version: '3.11.2'
            classpath 'org.jooq:jooq-codegen:3.11.2'
            classpath 'org.xerial:sqlite-jdbc:3.7.2'
        }
    }

    plugins {
        id 'java'
        id 'nu.studer.jooq' version '3.0.1'
    }

    group 'org.wycliffeassociates.translationrecorder'
    apply plugin: 'kotlin'
    apply plugin: 'kotlin-kapt'
    apply plugin: 'edu.sc.seis.launch4j'

    sourceCompatibility = 1.8

    configurations {
        sqllite
    }

    repositories {
        mavenCentral()
        jcenter()
        maven { url 'https://jitpack.io'}
        maven { url "https://plugins.gradle.org/m2/" }
        maven { url 'https://mvnrepository.com/artifac/'}
        maven { url  "https://dl.bintray.com/kotlin/exposed" }
        maven { url  "https://dl.bintray.com/dua3/public" }
    }

    allprojects {
        repositories {
            maven { url "https://jitpack.io" }
        }
    }


    dependencies {
        compile "no.tornado:tornadofx:1.7.16"
        compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

        compile "com.github.thomasnield:rxkotlinfx:2.2.2"
        compile "io.reactivex.rxjava2:rxkotlin:$rxkotlin_version"

        compile 'org.jooq:jooq:3.11.2'
        compile group: 'org.xerial', name: 'sqlite-jdbc', version: "$sqlite_jdbc"
        jooqRuntime group: 'org.jooq', name: 'jooq-meta-extensions', version: '3.11.2'
        jooqRuntime 'org.xerial:sqlite-jdbc:3.7.2'
        sqllite 'org.xerial:sqlite-jdbc:3.7.2'
        kapt "io.requery:requery-processor:$requery_version"

        compile "com.squareup.retrofit2:retrofit:2.0.0"
        compile "com.squareup.retrofit2:converter-moshi:2.0.0"
        compile 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'

        compile 'com.google.dagger:dagger:2.16'
        kapt 'com.google.dagger:dagger-compiler:2.16'

        implementation 'com.github.WycliffeAssociates:8woc2018-common:dev-SNAPSHOT'
        compile 'com.github.WycliffeAssociates:jdenticon-kotlin:-SNAPSHOT'

        compile 'de.jensd:fontawesomefx-commons:9.1.2-jpms'
        compile 'de.jensd:fontawesomefx-materialicons:2.2.0-9.1.2-jpms'
        compile 'de.jensd:fontawesomefx-icons525:4.2.0-9.1.2-jpms'
        compile 'com.github.afester.FranzXaver:Examples:0.1'
        compile 'com.jfoenix:jfoenix:8.0.5' // Java 8

        testCompile group: 'junit', name: 'junit', version: '4.12'
        testCompile "org.mockito:mockito-core:2.+"
        testCompile "org.mockito:mockito-core:2.+"
        testCompile 'org.powermock:powermock-module-junit4:2.+'
        testCompile 'org.powermock:powermock-module-junit4-rule:2.+'
        testCompile 'org.powermock:powermock-api-mockito2:2.+'
    }

    compileKotlin {
        kotlinOptions.jvmTarget = "1.8"
    }

    compileTestKotlin {
        kotlinOptions.jvmTarget = "1.8"
    }


    URLClassLoader loader = GroovyObject.class.classLoader
    configurations.sqllite.each { File file ->
        loader.addURL(file.toURL())
    }
    configurations.all {
        resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
    }

我尝试运行项目的构建,得到以下错误:

Caused by: org.gradle.api.InvalidUserDataException: Cannot change strategy of configuration ':sqllite' after it has been resolved.
        at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.preventIllegalMutation(DefaultConfiguration.java:896)
        at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.validateMutation(DefaultConfiguration.java:867)
        at org.gradle.api.internal.artifacts.ivyservice.resolutionstrategy.DefaultCachePolicy.eachModule(DefaultCachePolicy.java:161)
        at org.gradle.api.internal.artifacts.ivyservice.resolutionstrategy.DefaultCachePolicy.cacheChangingModulesFor(DefaultCachePolicy.java:121)
        at org.gradle.api.internal.artifacts.ivyservice.resolutionstrategy.DefaultResolutionStrategy.cacheChangingModulesFor(DefaultResolutionStrategy.java:190)
        at org.gradle.api.internal.artifacts.ivyservice.resolutionstrategy.DefaultResolutionStrategy.cacheChangingModulesFor(DefaultResolutionStrategy.java:186)
        at org.gradle.api.artifacts.ResolutionStrategy$cacheChangingModulesFor.call(Unknown Source)
        at build_2rl70kyg6ax354v7xbsnpa8n1$_run_closure8.doCall(C:\Users\dipinton\8woc2018-jvm\build.gradle:114)
        at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:71)
        at org.gradle.util.ConfigureUtil.configureTarget(ConfigureUtil.java:155)
        at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:106)
        at org.gradle.util.ConfigureUtil$WrappedConfigureAction.execute(ConfigureUtil.java:167)
        at org.gradle.api.internal.DefaultDomainObjectCollection.all(DefaultDomainObjectCollection.java:158)
        at org.gradle.api.internal.DefaultDomainObjectCollection.all(DefaultDomainObjectCollection.java:174)
        at org.gradle.api.DomainObjectCollection$all.call(Unknown Source)
        at build_2rl70kyg6ax354v7xbsnpa8n1.run(C:\Users\dipinton\8woc2018-jvm\build.gradle:113)
        at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:90)
        ... 99 more

我的印象是,我收到的此错误与我有 2 个配置块的事实有关。一个用于配置我的 SQLite 模块,另一个用于处理所有模块的解析策略。这两个闭包似乎相互冲突。

有人对如何消除这两个闭包之间的冲突有什么建议吗?

共有1个答案

傅博瀚
2023-03-14

这将在配置副本上使用addUrl:

def sqliteCopy = configurations.sqlite.copy()
sqliteCopy.each {File file -> 
    loader.addURL(file.toURI().toURL())
}

而不是:

configurations.sqllite.each { File file ->
        loader.addURL(file.toURL())
    }

或者将com.android.tools.build:gradle降级到3.1.4版本。

 类似资料:
  • 我有一个OS-X设置,并使用Netbeans IDE进行PHP编程。我已经在以下路径中安装了xdebug zend_extension=“/Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so” 在它下面我有xdebug。远程\u启用设置为打开。。例如xdebug。远程启用

  • 我不能改变本地ES索引位置-不能修改path.data。 在JournalCTL-XE中: 不幸的是,这些建议并没有帮助: 如何移动elasticsearch数据目录?;

  • 为Ant[pattern='/session']添加web访问控制表达式“has role('role_admin')' 正在为org.springframework.security.web.util.matcher.anyrequestmatcher@1添加web访问控制表达式“anonymous”,已验证配置属性 验证的配置属性 检查请求的匹配:“/API/Member/Account”;针

  • Neo4j版本:Community Edition 2.3.2 通过提供的可视化工具启动Neo4j ce 2.3.2,在使用自定义DB目录时工作正确。 数据库位置: 数据库调优文件: 服务器配置文件: 这里我设置: 只有在使用默认配置()时,但如果将文件设置更改为 (如在使用提供的可视化工具时)Windows PowerShell出现以下错误:

  • 我使用以下Java配置: 我做错了什么?

  • 我已经创建了一个Flink原生Kubernetes(1.14.2)集群,这是成功的。我正在尝试更新使用Flink Native Kubernetes公开的configmap的logback配置。Flink Native Kubernetes在集群启动期间创建此configmap,在集群停止时将其删除,此行为符合官方文档。 我更新了同样成功的回退配置图,这个过程甚至更新了作业管理器和任务管理器中的实