Update builds to support strictMode testing

Open
#953 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
20/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
java

Research direction

Start by locating the Gradle and Maven build files and their existing test tasks, then determine how strictMode is configured and how the tests should be run twice. The issue does not name files or provide a verified implementation; completion requires a confirmed approach that works in both builds and passes the full test suite.

Written by the indexing model from the issue text.

Description

In progress

After executing the unit tests, set default strictMode to true, then re-run all of the tests.
Fix in both gradle and maven builds. It might be possible (?) to integrate this action into the existing test task, but if not:

In Gradle:
Modify the existing test task (copilot, I have not verified this):

apply plugin: 'java'

repositories {
    mavenCentral()
}

dependencies {
    testImplementation 'junit:junit:4.12'
}

task modifyCode {
    doLast {
        // Add your code modification logic here
        def file = file('src/main/java/com/example/YourClass.java')
        def text = file.text
        text = text.replaceAll('oldCode', 'newCode')
        file.text = text
        println 'Code modified.'
    }
}

task rerunTests(dependsOn: ['modifyCode', 'test']) {
    doLast {
        println 'Re-running tests...'
    }
}

test {
    finalizedBy 'rerunTests'
}

If a new task is needed (claude.ai, not verified):

    dependsOn test
    doLast {
        // Make your code change here
        File sourceFile = file('src/main/java/YourFile.java')
        String content = sourceFile.text
        content = content.replace('oldCode', 'newCode')
        sourceFile.text = content
        
        // Run tests again
        tasks.test.execute()
    }
}

Copilot also suggests a one-test-run fix for maven, but it requires a new ModifyCode class. Not shown here.

In Maven, new task (claude.ai, not verified):

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>3.1.0</version>
    <executions>
        <execution>
            <id>test-with-code-change</id>
            <phase>verify</phase>
            <goals>
                <goal>java</goal>
            </goals>
            <configuration>
                <mainClass>org.apache.maven.shared.utils.io.FileUtils</mainClass>
                <arguments>
                    <argument>src/main/java/YourFile.java</argument>
                    <argument>oldCode</argument>
                    <argument>newCode</argument>
                </arguments>
            </configuration>
        </execution>
    </executions>
</plugin>
Dominant language
Java
Stars
4.7k
Forks
2.6k
Avg merge
6d 20h
Merged PRs (30d)
2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from stleary/JSON-java

All issues in stleary/JSON-java

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.