如何为某些依赖项禁用org.jetbrains.intellij的缓存重定向器?

时间:2019-06-08 00:16:04

标签: maven gradle intellij-idea intellij-plugin

我想在插件项目中引入com.alibaba:fastjson:1.2.58,但是当gradle解决依赖项时,org.jetbrains.intellij插件会将下载请求重定向到https://cache-redirector.jetbrains.com/www.jetbrains.com/intellij-repository/releases/com/alibaba/fastjson/1.2.58/fastjson-1.2.58.pom,该请求不存在。

如何强制gradle从mavenCentral下载此依赖项?

这是我的build.gradle

buildscript {
    repositories {
        mavenCentral()

        maven {
            url "https://oss.sonatype.org/content/repositories/snapshots/"
        }
        maven {
            url 'https://dl.bintray.com/jetbrains/intellij-plugin-service'
        }
    }
}

plugins {
    id "org.jetbrains.intellij" version "0.4.4"
}

dependencies {
   implementation 'com.alibaba:fastjson:1.2.58'
}

apply plugin: 'idea'
apply plugin: 'org.jetbrains.intellij'
apply plugin: 'java'

sourceCompatibility = 1.8
targetCompatibility = 1.8

intellij {
    version ideaVersion
    updateSinceUntilBuild false
    plugins = [
            "com.jetbrains.php:${phpPluginVersion}",
            "com.jetbrains.php.blade:${bladePluginVersion}",
            'CSS',
            'java-i18n',
            'properties',
            'git4idea'
    ]
    pluginName 'tw tools'
}

patchPluginXml {
    sinceBuild '173'
}

group 'com.baiguiren'

version '1.2'

wrapper {
    gradleVersion '5.4.1'
}

./gradlew clean && ./gradlew build的输出:

BUILD SUCCESSFUL in 0s
1 actionable task: 1 up-to-date

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':prepareSandbox'.
> Could not resolve all files for configuration ':runtimeClasspath'.
   > Could not find com.alibaba:fastjson:1.2.58.
     Searched in the following locations:
         https://cache-redirector.jetbrains.com/www.jetbrains.com/intellij-repository/releases/com/alibaba/fastjson/1.2.58/fastjson-1.2.58.pom
         https://cache-redirector.jetbrains.com/www.jetbrains.com/intellij-repository/releases/com/alibaba/fastjson/1.2.58/fastjson-1.2.58.jar
         file:/Users/ruby/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIU/2018.3.5/3abea719ce307bc4f573cba4e3d86f4e35cab07/ideaIU-2018.3.5/com.alibaba/fastjson/1.2.58/ivy-1.2.58.xml
         file:/Users/ruby/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIU/2018.3.5/3abea719ce307bc4f573cba4e3d86f4e35cab07/ideaIU-2018.3.5/fastjson-1.2.58-withKotlin-withSources.xml
         file:/Users/ruby/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIU/2018.3.5/3abea719ce307bc4f573cba4e3d86f4e35cab07/ideaIU-2018.3.5/com.alibaba/fastjson/1.2.58/fastjson-1.2.58.jar
         file:/Users/ruby/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIU/2018.3.5/3abea719ce307bc4f573cba4e3d86f4e35cab07/ideaIU-2018.3.5/fastjson.jar
         file:/Users/ruby/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIC/2018.3.5/78cbcd517ec112fbb0c7b45b00b464c1aa6371f3/fastjson-1.2.58-[classifier].jar
         https://cache-redirector.jetbrains.com/plugins.jetbrains.com/maven/com/alibaba/fastjson/1.2.58/fastjson-1.2.58.pom
         https://cache-redirector.jetbrains.com/plugins.jetbrains.com/maven/com/alibaba/fastjson/1.2.58/fastjson-1.2.58.jar
         file:/Users/ruby/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/com.alibaba/fastjson-1.2.58.xml
         file:/Users/ruby/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIU/2018.3.5/3abea719ce307bc4f573cba4e3d86f4e35cab07/ideaIU-2018.3.5/plugins/fastjson/fastjson.jar
         file:/Users/ruby/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/fastjson-1.2.58/fastjson.jar
         file:/Users/ruby/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIC/2018.3.5/78cbcd517ec112fbb0c7b45b00b464c1aa6371f3/fastjson-2018.3.5.jar
     Required by:
         project :

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

我曾经尝试Invalid caches and restart,但没有用。

我什至尝试删除org.jetbrains.intellij插件,但这是项目必需的。

1 个答案:

答案 0 :(得分:0)

cache-redirector没什么问题,它只是项目中注册的存储库之一,Gradle会全部检查它们。

尝试将mavenCentral存储库添加到build.gradle中(目前仅为buildscript定义):

repositories {
        mavenCentral()
}