TestNg and Junit not running in same gradle project

I am using JUnit 4.13.1 and TestNg 6.14.3 in the same gradle project(Jenkins Plugin). One class has TestNg unit tests and other has JUnit unit tests. For me both are not working together.
If I use this config in build.gradle then only JUnit works

test {
    testLogging {
        showStandardStreams = true
    }

    doFirst {
        environment 'OUTPUT_DIR', project.buildDir
        systemProperty 'build.notifications.disabled', 'true'
    }
    useTestNG()
    useJUnit()
}

And if I use this config or remove useJUnit() then only JUnit works.

test {
    testLogging {
        showStandardStreams = true
    }

    doFirst {
        environment 'OUTPUT_DIR', project.buildDir
        systemProperty 'build.notifications.disabled', 'true'
    }
    useJUnit()
}

If I keep only useTestNG() then only TestNG works.
What is the proper configuration for both to run in same gradle project? The error I get -

Execution failed for task ':test'.
> No tests found for given includes: [com.build.plugins.TestDataTest](--tests filter)

As you observed, this does not work.
If you want to use both frameworks, you have to use two distinct test tasks.
They are not compatible to run together.
Others are compatible like JUnit Jupiter, JUnit 4 and Spock which all run on JUnit Platform.
They can be used in one test task, though not through multiple use...() methods, but manually adding the additional engines as dependencies.

Actually, while I wrote the above, I had the idea someone could have wrote a JUnit Platform engine to run TestNG tests and indeed the JUnit team itself did: GitHub - junit-team/testng-engine: TestNG Engine for the JUnit Platform.
So if you useJUnitPlatform() and then add the JUnit Vintage engine for running the JUnit 4 tests and the TestNG engine for running the TestNG tests, it should indeed work.