Exclude file dependency in dependent subproject

I have two dependent projects
< 1 >

buildConfig.artifactId = 'project1'
...
dependencies {
   ...
   testRuntime files ( 
      buildConfig.findProjectByShortName('projectA').file('config'), // File 1
      buildConfig.findProjectByShortName('projectB').file('config') // File 2
   )
}
task ('test1', type: Test) {
   // task is executed using dependency to File1 and File2
}

< 2 >

buildConfig.artifactId = 'project 2'
...
dependencies {
   compile "project1"
   ...
   testRuntime files {
      // I would like to exclude File 2 dependency and use only File 1 when run the task
   }
}
task('test2', type: Test) {
   // goal is execute this task using only File 1 dependency
}

I cannot exclude or change direction of compile dependency to project 1 in project 2.
When I execute test1 everything is Ok but I cannot find a way how exclude task2 only with File 1 dependency.
So the question: How exclude File 2 dependency for test2?

Thanks!