how do I add dependency without being tied to version?

62 views
Skip to first unread message

Yan Zhou

unread,
Feb 5, 2024, 11:30:29 AM2/5/24
to CAS Community
HI there,

with CAS 6.6.x overlay, I need to create my own authentication handler, which uses Apache Shiro's hash service, etc., it comes with CAS, but I have to explicitly list them in my project dependency so my code can compile.

looks like the following,  Note that I first find out CAS is using shiro-core 1.9.1 and then explicitly include it in build.gradle, is there a better way to manage this (such as I do Not have to explicitly include shiro dependency by specific version# ? this makes it difficult for upgrade.)

implementation "org.apereo.cas:cas-server-support-jdbc"
implementation "org.apereo.cas:cas-server-support-jdbc-authentication"
implementation "org.apache.shiro:shiro-core:1.9.1"
implementation "org.apereo.cas:cas-server-support-ldap"

Thanks,
Yan

Ray Bon

unread,
Feb 5, 2024, 11:36:17 PM2/5/24
to cas-...@apereo.org
Yan,

You  can put the version into gradle.properties (I put this at the bottom of my file):

lombokVersion=1.18.30
...

In build.gradle:

compileOnly "org.projectlombok:lombok:${lombokVersion}"
testCompileOnly("org.projectlombok:lombok:${lombokVersion}")

If the library is included in cas, then you  do not need to use implementation.


Ray

On Mon, 2024-02-05 at 08:22 -0800, Yan Zhou wrote:
Notice: This message was sent from outside the University of Victoria email system. Please be cautious with links and sensitive information.

Petr Bodnár

unread,
Feb 6, 2024, 9:51:39 PM2/6/24
to CAS Community, Ray Bon
Hi,

AFAIK, just specifying the library without the version should be sufficient:

     implementation "org.apache.shiro:shiro-core"

Because like for the other libraries from your example, the version of the dependency is already specified in the imported CAS BOM (e.g. cas-server-support-bom-6.6.15.pom). The BOM is imported by the following line in the CAS overlay's build.gradle:

    implementation enforcedPlatform("org.apereo.cas:cas-server-support-bom:${project.'cas.version'}")


(Ad lombokVersion: As this special, compile-only, library is not specified in the BOM, I'm doing the same, i.e. I copy the version manually to my project.)

I hope this helps
Petr

Yan Zhou

unread,
Feb 7, 2024, 10:38:29 AM2/7/24
to CAS Community, Petr Bodnár, Ray Bon
that did help, thanks a lot to you both!

Yan

Reply all
Reply to author
Forward
0 new messages