替换Gradle插件的可传递依赖项

n9vozmp4  于 2022-11-14  发布在  其他
关注(0)|答案(1)|浏览(191)

axion-release Gradle插件依赖于未维护的com.jcraft:jsch:0.1.55库。com.github.mwiede:jsch fork是提供相同命名空间的jcraft jsch的直接替代品。如何替换插件的依赖项?

这似乎不起作用:

buildscript {
  dependencies {
    classpath('pl.allegro.tech.build:axion-release-plugin:1.14.2') {
      exclude group: 'com.jcraft', module: 'jsch'
    }
  } 
  configurations.classpath {
    resolutionStrategy {
      force 'com.github.mwiede:jsch:0.2.4'
    }
  }
}

这将从类路径中删除com.jcraft.jsch,但不会将其替换为维护的库:

buildscript {
  configurations.classpath {
    resolutionStrategy {
      exclude group: 'com.jcraft', module: 'jsch'
    }
  }
}

这也不行

buildscript {
  dependencies {
    classpath('pl.allegro.tech.build:axion-release-plugin:1.14.2') {
      exclude group: 'com.jcraft', module: 'jsch'
    }
    classpath 'com.github.mwiede:jsch:0.2.4'
}
b1zrtrql

b1zrtrql1#

我试过替代

buildscript {
    dependencies {
        classpath "pl.allegro.tech.build:axion-release-plugin:1.14.2"
    }

    configurations.all {
        resolutionStrategy.dependencySubstitution {
            substitute module("com.jcraft:jsch") using module("com.github.mwiede:jsch:0.2.4") because "of https://stackoverflow.com/q/74355649/2290153"
        }
    }

}

buildEnvironment得到:

classpath
\--- pl.allegro.tech.build:axion-release-plugin:1.14.2
     +--- org.eclipse.jgit:org.eclipse.jgit:5.13.1.202206130422-r
     |    +--- com.googlecode.javaewah:JavaEWAH:1.1.13
     |    \--- org.slf4j:slf4j-api:1.7.30
     +--- org.eclipse.jgit:org.eclipse.jgit.ssh.jsch:5.13.1.202206130422-r
     |    +--- org.eclipse.jgit:org.eclipse.jgit:5.13.1.202206130422-r (*)
     |    +--- com.jcraft:jsch:0.1.55 -> com.github.mwiede:jsch:0.2.4
     |    +--- com.jcraft:jzlib:1.1.1
     |    \--- org.slf4j:slf4j-api:1.7.30
     +--- com.jcraft:jsch:0.1.55 -> com.github.mwiede:jsch:0.2.4
     +--- com.jcraft:jsch.agentproxy.core:0.0.9
     +--- com.jcraft:jsch.agentproxy.jsch:0.0.9
     |    +--- com.jcraft:jsch:0.1.49 -> com.github.mwiede:jsch:0.2.4
     |    \--- com.jcraft:jsch.agentproxy.core:0.0.9
     +--- com.jcraft:jsch.agentproxy.sshagent:0.0.9
     |    \--- com.jcraft:jsch.agentproxy.core:0.0.9
     +--- com.jcraft:jsch.agentproxy.pageant:0.0.9
     |    +--- com.jcraft:jsch.agentproxy.core:0.0.9
     |    +--- net.java.dev.jna:jna:4.1.0
     |    \--- net.java.dev.jna:jna-platform:4.1.0
     |         \--- net.java.dev.jna:jna:4.1.0
     +--- com.jcraft:jsch.agentproxy.usocket-jna:0.0.9
     |    +--- com.jcraft:jsch.agentproxy.core:0.0.9
     |    +--- net.java.dev.jna:jna:4.1.0
     |    \--- net.java.dev.jna:jna-platform:4.1.0 (*)
     +--- com.jcraft:jsch.agentproxy.usocket-nc:0.0.9
     |    \--- com.jcraft:jsch.agentproxy.core:0.0.9
     +--- com.github.zafarkhaja:java-semver:0.9.0
     +--- org.eclipse.jgit:org.eclipse.jgit.ssh.apache:5.13.1.202206130422-r
     |    +--- org.eclipse.jgit:org.eclipse.jgit:5.13.1.202206130422-r (*)
     |    +--- org.apache.sshd:sshd-osgi:2.7.0
     |    |    +--- org.slf4j:slf4j-api:1.7.30
     |    |    \--- org.slf4j:jcl-over-slf4j:1.7.30
     |    |         \--- org.slf4j:slf4j-api:1.7.30
     |    +--- org.apache.sshd:sshd-sftp:2.7.0
     |    |    +--- org.apache.sshd:sshd-core:2.7.0
     |    |    |    +--- org.apache.sshd:sshd-common:2.7.0
     |    |    |    |    +--- org.slf4j:slf4j-api:1.7.30
     |    |    |    |    \--- org.slf4j:jcl-over-slf4j:1.7.30 (*)
     |    |    |    +--- org.slf4j:slf4j-api:1.7.30
     |    |    |    \--- org.slf4j:jcl-over-slf4j:1.7.30 (*)
     |    |    +--- org.slf4j:slf4j-api:1.7.30
     |    |    \--- org.slf4j:jcl-over-slf4j:1.7.30 (*)
     |    +--- net.i2p.crypto:eddsa:0.3.0
     |    \--- org.slf4j:slf4j-api:1.7.30
     +--- org.eclipse.jgit:org.eclipse.jgit.ui:5.13.1.202206130422-r
     |    \--- org.eclipse.jgit:org.eclipse.jgit:5.13.1.202206130422-r (*)
     \--- org.eclipse.jgit:org.eclipse.jgit.gpg.bc:5.13.1.202206130422-r
          +--- org.eclipse.jgit:org.eclipse.jgit:5.13.1.202206130422-r (*)
          +--- org.bouncycastle:bcpg-jdk15on:1.69
          |    \--- org.bouncycastle:bcprov-jdk15on:1.69
          +--- org.bouncycastle:bcprov-jdk15on:1.69
          +--- org.bouncycastle:bcutil-jdk15on:1.69
          |    \--- org.bouncycastle:bcprov-jdk15on:1.69
          +--- org.bouncycastle:bcpkix-jdk15on:1.69
          |    +--- org.bouncycastle:bcprov-jdk15on:1.69
          |    \--- org.bouncycastle:bcutil-jdk15on:1.69 (*)
          \--- org.slf4j:slf4j-api:1.7.30

顺便说一句,jGit附带了可传递依赖,在https://github.com/mwiede/jsch/issues/85使用fork时出现了一个问题,但现在已经解决了。

相关问题