Changing Dependencies in the Build.gradle

Hi all,

I am having a problem with switching the dependencies from iText to openPDF. The reason is because iText is no longer provide update for open source. the problem i faced is the POM.xml File for the JasperReport plugins which using the iText Dependencies is read only file. So i am unable to change the dependencies directly from that file. i found out that i can use resolutionStrategy rule, but theres some errors pop up when i run bootrun.

Below is the code that i implemented:

configurations {
//    agent
    developmentOnly
    runtimeClasspath {
        extendsFrom developmentOnly
    }

    compileClasspath.resolutionStrategy {
        eachDependency{ DependencyResolveDetails details ->
            if (details.requested.group == 'com.lowagie' && details.requested.name == 'itext' ) {
                details.useTarget group: 'com.github.librepdf', name: 'openpdf', version: '1.3.24'
            }
        }
    }
}

dependencies {
//https://mvnrepository.com/artifact/net.sf.jasperreports/jasperreports
    compile group: 'net.sf.jasperreports', name: 'jasperreports', version: '6.16.0'

    //https://mvnrepository.com/artifact/com.lowagie/itext
    compile group: 'com.lowagie', name: 'itext', version: '2.1.7'

    // https://github.com/librepdf/openpdf
    compile group: 'com.github.librepdf', name: 'openpdf', version: '1.3.24'
}

Below is the error:
Execution failed for task ‘:server:bootRun’.

Main class name has not been configured and it could not be resolved

The error you’ve posted has nothing to do with dependencies. It has to do with the fact that you can’t bootRun a Spring Boot app unless the plugin finds a class with a public static void main(String[] args) { } method in the project as this is the entry point.

Hi @jjustinic thanks for your reply, but it work fine when i comment out this line

compileClasspath.resolutionStrategy {
        eachDependency{ DependencyResolveDetails details ->
            if (details.requested.group == 'com.lowagie' && details.requested.name == 'itext' ) {
                details.useTarget group: 'com.github.librepdf', name: 'openpdf', version: '1.3.24'
            }
        }
    }

but i need those few lines for changing the dependencies.