Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How we can do mvn install:install-file for in gradle for 3rd party transient dependencies?

We have Bouncycastle dependencies, coming from one dependency and another one. Sothey are something like that:

implementation 'org.bouncycastle:bcprov-jdk14:1.61' <- explicitly added

'bouncycastle:bcprov-jdk14:138' <- taken from another dependency

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

They have the different group name, so I can’t just exclude 138. But I can’t inrement it to 161 too, as is hosts nowhere in the repos.

Can I set up something to my Gradle script to

  1. Take org.bouncycastle:bcprov-jdk14:1.61 jar

  2. Do something like

    mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>

but with Gradle where I’ll put the desired format like bouncycastle:bcprov-jdk14:161

  1. Only then do the rest of the build?

>Solution :

You can do it locally when you have the Jar file. Create a folder named lib in your project directory to store the Bouncy Castle JAR file. Place the bcprov-jdk14-1.61.jar file in the lib folder.

Modify your Gradle script (build.gradle) to include the following configuration,The configurations block defines a custom configuration named bouncyCastle

configurations {
    bouncyCastle
}

dependencies {
    // Other dependencies...
    
    bouncyCastle 'org.bouncycastle:bcprov-jdk14:1.61'
}

task installBouncyCastleJar {
    doLast {
        def bcFile = file('lib/bcprov-jdk14-1.61.jar')
        def groupId = 'bouncycastle'
        def artifactId = 'bcprov-jdk14'
        def version = '161'
        def packaging = 'jar'
        
        project.repositories.mavenInstaller.install([
                file: bcFile,
                groupId: groupId,
                artifactId: artifactId,
                version: version,
                packaging: packaging
        ])
    }
}

project.afterEvaluate {
   build.dependsOn(installBouncyCastleJar)
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading