Pivotal + VMware: Transforming how more of the world builds software

Dependency Management Refactoring

Analyze code to identify libraries that might be provided by Spring.

Often, upgrading of dependencies means switching to Spring Framework provided functionality that was not available when application was initially written several years ago. Using Spring starter dependencies simplifies library version management.

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-tomcat</artifactId>
    <scope>provided</scope>
</dependency>

Run following command to list and analyze dependencies.

mvn dependency:tree

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building instrument-details Maven Webapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ instrument-details ---
[INFO] com.jpmc:instrument-details:war:1.0-SNAPSHOT
[INFO] +- mysql:mysql-connector-java:jar:6.0.6:compile
[INFO] +- org.projectlombok:lombok:jar:1.16.18:provided
[INFO] +- javax.servlet:javax.servlet-api:jar:3.1.0:provided
[INFO] +- junit:junit:jar:4.12:test
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.slf4j:slf4j-api:jar:1.7.7:compile
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.7:compile
[INFO] |  \- log4j:log4j:jar:1.2.17:compile
[INFO] \- com.jcabi:jcabi-log:jar:0.17.1:compile
[INFO]    \- com.jcabi:jcabi-aspects:jar:0.22:compile
[INFO]       +- org.aspectj:aspectjrt:jar:1.8.4:compile
[INFO]       \- javax.validation:validation-api:jar:1.1.0.Final:compile

Write Application Context Load test.

Optimize the development cycle by adding the test that loads Spring application context that is being tested. Prefer to load only functionality that is being refactored. Spring Boot 1.4 introduced the ability to test slices of functionality.

Refactor pom.xml or build.gradle - upgrade dependencies.

Remove / Replace dependencies in pom.xml one at the time, executing the tests that test functionality provided by the library being worked on.

Increase test coverage of identified upgrade candidates.

Code changes will most probably be required when upgrading from the legacy versions of components to a new, Springified version, therefore, having a good test coverage is critical.

Kontakt