Copy JavaScript files from src/test/java to another module

We use a automation tool that suggests to keep js files in src/test/java below is the structure

Project : common
->src->test->java
->*.js and *.feature files inside

Project: DomainTest
->src->test->java
->*.js files

Project ‘DomainTest’ depends on ‘common’ and I need all js files from common copied to DomainTest[src/test/java],
I tried using processresources but it doesn’t copy javascript files. How do i copy files from common?

Also, if i publish common module to a repository how do i copy js files. Need help

As the name suggests, src/test/java (and src/main/java) are for java files only. I’m guessing your javascript files are looked up via the classpath? In which case they should be in src/test/resources.

If you want common test utilities, I suggest that you create a separate project and put the files in src/main/resources and add the test utilities project as a dependency where its needed.

Another option is to create a test jar which can be referenced by another project (putting javascript files in src/test/resources).

Eg:

task testJar(type: Jar, dependsOn: testClasses) {
   classifier = 'tests'
   from sourceSets.test.output
}
configurations {
   tests.extendsFrom testCompile 
} 
artifacts {
   tests testJar
} 

Then in another project

dependencies {
   testCompile project(path: ':other', configuration: 'tests') 
}