serverless-java-container icon indicating copy to clipboard operation
serverless-java-container copied to clipboard

Could com.amazonaws.serverless.sample:serverless-jersey-example:1.0-SNAPSHOT drop off redundant dependencies?

Open Celebrate-future opened this issue 3 years ago • 2 comments

Hi! I found the pom file of project com.amazonaws.serverless.sample:serverless-jersey-example:1.0-SNAPSHOT introduced 41 dependencies. However, among them, 7 libraries (17%) are not used by your project. I list the redundant dependencies below (labelled as red ones in the figure):

Redundant dependencies

javax.servlet:javax.servlet-api:jar:3.1.0:compile javax.ws.rs:javax.ws.rs-api:jar:2.1:compile jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile org.glassfish.hk2.external:jakarta.inject:jar:2.6.1:compile jakarta.validation:jakarta.validation-api:jar:2.0.2:compile jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.2:compile jakarta.activation:jakarta.activation-api:jar:1.2.1:compile


Removing the redundant dependencies can reduce the size of project and prevent potential dependency conflict issues (i.e., multiple versions of the same library). More importantly, one of the redundant dependencies jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile incorporates an incompatible license EPL 2.0 (EPL 2.0 cannot be used by the project with license The Apache Software License, Version 2.0), one of the redundant dependencies org.glassfish.hk2.external:jakarta.inject:jar:2.6.1:compile incorporates an incompatible license EPL 2.0 (EPL 2.0 cannot be used by the project with license The Apache Software License, Version 2.0). 2 of the redundant dependencies jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile, org.glassfish.hk2.external:jakarta.inject:jar:2.6.1:compile induced dependency conflict in the dependency graph. As such, I suggest a refactoring operation for com.amazonaws.serverless.sample:serverless-jersey-example:1.0-SNAPSHOT’s pom file.

The attached PR helps resolve the reported problem. It is safe to remove the unused libraries (we considered Java reflection relations when analyzing the dependencies). These changes have passed com.amazonaws.serverless.sample:serverless-jersey-example:1.0-SNAPSHOT’s maven tests.

Best regards image

Celebrate-future avatar Mar 29 '22 02:03 Celebrate-future

Hi, thank you for your contribution. In my view instead of just cleaning up the petstore sample app it makes more sense to apply the changes also to the aws-serverless-java-container-jersey module so that other users also benefit from it. What do you think?

In general we should probably update to the Jakarta EE 9 Jersey version (latest version 3.0.4) at some point but so far I haven't seen any user feedback for this.

deki avatar Mar 29 '22 08:03 deki

嗨,感谢您的贡献。在我看来,不仅仅是清理宠物店示例应用程序,更有意义的是将这些更改也应用于 aws-server-java-container-jersey 模块,以便其他用户也能从中受益。你觉得怎么样?

一般来说,我们可能应该在某个时候更新到Jakarta EE 9 Jersey版本(最新版本3.0.4),但到目前为止,我还没有看到任何用户对此的反馈。

Thanks for your attention, I will finish it

Celebrate-future avatar Apr 02 '22 09:04 Celebrate-future

@Celebrate-future please check the main branch and let us know if you see further optimizations.

deki avatar Apr 25 '23 15:04 deki