watsonx.ai

watsonx.ai

A one-stop, integrated, end- to-end AI development studio

 View Only

Integrate AI Agents to Quickly Develop, Boost Productivity and Complex Queries Answered

By PANDURANGA H GANAPA posted 3 days ago

  

Overview

This article demonstrates how AI code assistants such as GitHub Copilot, Watson Code Assistant, and other AI tools can significantly enhance developer productivity. We'll explore one practical use case—upgrading a legacy Java application from Java 8 + Gradle 5.1.1 to Java 17 + Gradle 8.13—and how AI support accelerated problem resolution, reduced toil, and enabled smarter automation.

Problem Statement

Upgrading a large-scale multi-module Java application poses several challenges:

  • Imagine the project consists of plenty of subprojects and huge number of Gradle tasks.
  • The move from Java 8 + Gradle 5.1.1 to Java 17 + Gradle 8.13 introduces stricter dependency validation.
  • Several modules failed to compile due to:
    • Missing inter-project dependencies
    • External library conflicts
    • Implicit test class usage in production code
  • Many errors that were ignored or resolved implicitly in Java 8 now fail fast in Java 17.


Manually resolving dependency issues across dozens of modules is not only tedious but also highly error-prone.

Solution: AI-Enhanced Development

Instead of slogging through manual trial-and-error, we introduced AI development agents directly into our IDEs (like IntelliJ IDEA or VS Code) using tools such as:

  • GitHub Copilot
  • Watson Code Assistant
  • ChatGPT + JavaParser tooling

These AI agents helped:

  • Detect missing dependencies
  • Suggest fixes for Gradle configurations
  • Identify required versions for external libraries

Automatically generate and refactor Gradle scripts

Real-World Use Case: Upgrading a Legacy Java Application

Let's walk through an actual upgrade issue encountered during the Java 17 migration.

> Task :XYZ:compileJava FAILED

/qa/sample/testbase/AbstractSystemTest.java:91: error: cannot access ProjectTestCase

import com.sample.util.junit.ProjectTestCase;                             ^

  class file for com.sample.util.junit.ProjectTestCase not found


Root Cause:

  • ProjectTestCase.class exists in ABC/src/test/java.
  • It is being used in XYZ/src/main/java.
  • Java 17 + Gradle 8.13 doesn't allow implicit access to test classes.

Fix (with AI Guidance):

We updated XYZ/build.gradle:

implementation project(path: ':ABC', configuration: 'testArtifacts')

And added this to ABC/build.gradle:

configurations {

    testArtifacts.extendsFrom testRuntimeOnly

}

artifacts {

    testArtifacts tasks.named('testJar')

}

if (!tasks.findByName('testJar')) {

    tasks.register('testJar', Jar) {

        archiveClassifier.set('test')

        from sourceSets.test.output

    }

}

This explicitly exposes ABC's test classes as a testJar artifact and allows other modules to depend on them cleanly.

How AI Helped

Instead of troubleshooting Gradle internals manually, we leveraged AI for:

  • Instant Gradle script generation
  • Dependency visibility analysis
  • JavaParser integration for automated dependency detection
  • Accurate version suggestions for open-source libraries

Automating Dependency Discovery

In large multi-module projects, one of the main challenges is determining which module depends on which, especially when imports reference other modules' src/test/java directories.

We created a custom AI-assisted Dependency Analyzer tool that:

  • Parses import statements across modules
  • Detects missing project dependencies
  • Classifies them as implementation, testImplementation, or testArtifacts
  • Avoids introducing circular dependencies
  • Updates build.gradle files automatically

This drastically reduced manual effort and build failures.


#watsonx.ai
0 comments
12 views

Permalink