title: Gradle: How to make a compile scope file dependency excluded in packaging?
body: <p>I have a multi-module gradle project with the following basic structure:</p>
  
  <pre><code>root
    core
    c-interface
    m-interface
  </code></pre>
  
  <p>The c-interface and m-interface both depend on the core project:</p>
  
  <pre><code>compile project(':root:core')
  </code></pre>
  
  <p>c-interface and m-interface  use the WAR plugin, but core does not and is just a jar.</p>
  
  <p>In the core project, I am pulling in some file system dependencies with the following. One of these dependencies I cannot have packaged in the WARs generated by c-interface and m-interface. Previously I had this dependency in a nexus maven repository so I could exclude it by group,name,version in a providedRuntime configuration in c-interface and m-interface. </p>
  
  <p>I cannot figure out how to do the same for the file dependency. The gradle dependencies task does not list file dependencies so I don't know what I would put in a providedRuntime.</p>
  
  <p>I read <a href="http://issues.gradle.org/browse/GRADLE-471" rel="nofollow noreferrer">http://issues.gradle.org/browse/GRADLE-471</a> but trying to use the idea there doesn't seem to remove the archive from my packages. Here is what I am currently defining (in core's build.gradle):</p>
  
  <pre><code>compile fileTree(dir: 'dependencies/compile/archive', include: '*.jar', exclude: 'management.jar')
  compile(files('dependencies/compile/archive/management.jar')){ notPackaged = true  } // Excludes it from all publications
  </code></pre>
  
  <p><strong>Update</strong></p>
  
  <p><a href="https://stackoverflow.com/questions/13925724/providedcompile-without-war-plugin">providedCompile without war plugin</a> looked like a possibility. I set this up in the core build.gradle and it compiled fine, but c-interface and m-interface also needed the dependency at compile time. Including the file as providedCompile (or even a sanity check with compile) in c-interface and m-interface did not fix compile time errors related to missing the management.jar dependency. My speculation is because it was already scoped as providedCompile in core that the new declarations are ignored in c-interface and m-interface. </p>
  
  <p>core/build.gradle:</p>
  
  <pre><code>configurations { providedCompile }
  
  dependencies {
      providedCompile files('dependencies/compile/archive/management.jar')
  }
  
  sourceSets.main.compileClasspath += configurations.providedCompile
  sourceSets.test.compileClasspath += configurations.providedCompile
  sourceSets.test.runtimeClasspath += configurations.providedCompile
  </code></pre>
  
  <p>c-interface/build.gradle:</p>
  
  <pre><code>providedCompile files('dependencies/compile/archive/management.jar')
  </code></pre>