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

grails 2 different dependencies with same package names

Some dependencies from various libraries have same package name javax.mail. And all the classes inside them are equal with different versions.

I want to be able to choose which class to load at runtime. To be more specific, I have MimeMessage class for email and right now the program is choosing the old version rather than the newer version so this field protected InternetHeaders headers; is not correctly filled and the charset for email and subject is not added so I am unable to send mail with html body.
jar file names :

javax.mail-1.6.2.jar
geronimo-javamail_1.4_spec-1.2.jar
javax.mail-1.5.1.jar
javax.mail-api-1.5.1.jar

all of them have javax.mail.internet.MimeMessage

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

>Solution :

You may wanna try to

  • Exclude the conflicting dependency
dependencies {
    compile('org.example:conflict-library:1.0') {
        excludes 'geronimo-javamail_1.4_spec'
    }
}
  • Use dependency management
dependencyManagement {
    imports {
        mavenBom 'org.example:bom:1.0'
    }
    dependencies {
        dependency 'javax.mail:mail:1.6.2'
    }
}

forcing all dependencies on javax.mail:mail to use version 1.6.2

PS: remember to clean and rebuild your project after modifying

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