title: Migration from maven to gradle: "gradle build" fails for WAR building task
body: <p>I am trying to rewrite pom.xml configuration into gradle script. The part concerning dependencies in pom looks like that:</p>
  
  <pre><code>&lt;dependencies&gt;
      &lt;!-- Spring --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
          &lt;version&gt;${org.springframework-version}&lt;/version&gt;
          &lt;exclusions&gt;
              &lt;!-- Exclude Commons Logging in favor of SLF4j --&gt;
              &lt;exclusion&gt;
                  &lt;groupId&gt;commons-logging&lt;/groupId&gt;
                  &lt;artifactId&gt;commons-logging&lt;/artifactId&gt;
               &lt;/exclusion&gt;
          &lt;/exclusions&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
          &lt;version&gt;${org.springframework-version}&lt;/version&gt;
      &lt;/dependency&gt; 
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-aop&lt;/artifactId&gt;
          &lt;version&gt;${org.springframework-version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-orm&lt;/artifactId&gt;
          &lt;version&gt;${org.springframework-version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Spring security --&gt;    
      &lt;dependency&gt; 
          &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;  
          &lt;artifactId&gt;spring-security-core&lt;/artifactId&gt;  
          &lt;version&gt;${spring.security.version}&lt;/version&gt; 
      &lt;/dependency&gt; 
      &lt;dependency&gt;  
          &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;  
          &lt;artifactId&gt;spring-security-ldap&lt;/artifactId&gt;  
          &lt;version&gt;${spring.security.version}&lt;/version&gt;  
      &lt;/dependency&gt;  
      &lt;dependency&gt;  
          &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;  
          &lt;artifactId&gt;spring-security-config&lt;/artifactId&gt;  
          &lt;version&gt;${spring.security.version}&lt;/version&gt;  
      &lt;/dependency&gt; 
      &lt;dependency&gt; 
            &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;  
            &lt;artifactId&gt;spring-security-web&lt;/artifactId&gt;  
            &lt;version&gt;${spring.security.version}&lt;/version&gt; 
      &lt;/dependency&gt; 
      &lt;dependency&gt;
           &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;  
           &lt;artifactId&gt;spring-security-taglibs&lt;/artifactId&gt;  
          &lt;version&gt;${spring.security.version}&lt;/version&gt; 
      &lt;/dependency&gt; 
      &lt;dependency&gt; 
          &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;  
          &lt;artifactId&gt;spring-security-acl&lt;/artifactId&gt; 
          &lt;version&gt;${spring.security.version}&lt;/version&gt; 
      &lt;/dependency&gt;
  
      &lt;!-- Tiles dependancies --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.tiles&lt;/groupId&gt;
          &lt;artifactId&gt;tiles-api&lt;/artifactId&gt;
          &lt;version&gt;2.1.4&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.tiles&lt;/groupId&gt;
          &lt;artifactId&gt;tiles-core&lt;/artifactId&gt;
          &lt;version&gt;2.1.4&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.tiles&lt;/groupId&gt;
          &lt;artifactId&gt;tiles-jsp&lt;/artifactId&gt;
          &lt;version&gt;2.1.4&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
      &lt;groupId&gt;org.apache.tiles&lt;/groupId&gt;
          &lt;artifactId&gt;tiles-servlet&lt;/artifactId&gt;
          &lt;version&gt;2.1.4&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- AspectJ --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.aspectj&lt;/groupId&gt;
          &lt;artifactId&gt;aspectjrt&lt;/artifactId&gt;
          &lt;version&gt;${org.aspectj-version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- MySQL database driver --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;mysql&lt;/groupId&gt;
          &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
          &lt;version&gt;5.1.19&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- PostgreSQL database driver --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;postgresql&lt;/groupId&gt;
          &lt;artifactId&gt;postgresql&lt;/artifactId&gt;
          &lt;version&gt;9.1-901.jdbc4&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Required by databases --&gt;
      &lt;dependency&gt; 
          &lt;groupId&gt;org.apache.derby&lt;/groupId&gt; 
           &lt;artifactId&gt;derbyclient&lt;/artifactId&gt; 
          &lt;version&gt;10.9.1.0&lt;/version&gt; 
      &lt;/dependency&gt; 
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-jdbc&lt;/artifactId&gt;
          &lt;version&gt;${org.springframework-version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Logging --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
          &lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;
          &lt;version&gt;${org.slf4j-version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
          &lt;artifactId&gt;jcl-over-slf4j&lt;/artifactId&gt;
          &lt;version&gt;${org.slf4j-version}&lt;/version&gt;
          &lt;scope&gt;runtime&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
          &lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt;
          &lt;version&gt;${org.slf4j-version}&lt;/version&gt;
          &lt;scope&gt;runtime&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;log4j&lt;/groupId&gt;
          &lt;artifactId&gt;log4j&lt;/artifactId&gt;
          &lt;version&gt;1.2.15&lt;/version&gt;
          &lt;exclusions&gt;
              &lt;exclusion&gt;
                  &lt;groupId&gt;javax.mail&lt;/groupId&gt;
                  &lt;artifactId&gt;mail&lt;/artifactId&gt;
              &lt;/exclusion&gt;
              &lt;exclusion&gt;
                  &lt;groupId&gt;javax.jms&lt;/groupId&gt;
                  &lt;artifactId&gt;jms&lt;/artifactId&gt;
              &lt;/exclusion&gt;
              &lt;exclusion&gt;
                  &lt;groupId&gt;com.sun.jdmk&lt;/groupId&gt;
                  &lt;artifactId&gt;jmxtools&lt;/artifactId&gt;
              &lt;/exclusion&gt;
              &lt;exclusion&gt;
                  &lt;groupId&gt;com.sun.jmx&lt;/groupId&gt;
                  &lt;artifactId&gt;jmxri&lt;/artifactId&gt;
              &lt;/exclusion&gt;
          &lt;/exclusions&gt;
          &lt;scope&gt;runtime&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;!-- @Inject --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.inject&lt;/groupId&gt;
          &lt;artifactId&gt;javax.inject&lt;/artifactId&gt;
          &lt;version&gt;1&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Servlet --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
          &lt;version&gt;2.5&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet.jsp&lt;/groupId&gt;
          &lt;artifactId&gt;jsp-api&lt;/artifactId&gt;
          &lt;version&gt;2.1&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;jstl&lt;/artifactId&gt;
          &lt;version&gt;1.2&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Validation --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.validation&lt;/groupId&gt;
          &lt;artifactId&gt;validation-api&lt;/artifactId&gt;
          &lt;version&gt;1.0.0.GA&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Hibernate --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
          &lt;version&gt;4.1.7.Final&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-validator&lt;/artifactId&gt;
          &lt;version&gt;4.3.0.Final&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate.javax.persistence&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-jpa-2.0-api&lt;/artifactId&gt;
          &lt;version&gt;1.0.1.Final&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- DOM4j --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;dom4j&lt;/groupId&gt;
          &lt;artifactId&gt;dom4j&lt;/artifactId&gt;
          &lt;version&gt;1.6.1&lt;/version&gt;
      &lt;/dependency&gt;
  
       &lt;!-- Commons --&gt;        
      &lt;dependency&gt;
          &lt;groupId&gt;commons-beanutils&lt;/groupId&gt;
          &lt;artifactId&gt;commons-beanutils&lt;/artifactId&gt;
          &lt;version&gt;1.8.3&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;commons-collections&lt;/groupId&gt;
          &lt;artifactId&gt;commons-collections&lt;/artifactId&gt;
          &lt;version&gt;3.2.1&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;commons-digester&lt;/groupId&gt;
          &lt;artifactId&gt;commons-digester&lt;/artifactId&gt;
          &lt;version&gt;2.1&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
           &lt;groupId&gt;commons-fileupload&lt;/groupId&gt;
           &lt;artifactId&gt;commons-fileupload&lt;/artifactId&gt;
           &lt;version&gt;1.2.2&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;commons-io&lt;/groupId&gt;
        &lt;artifactId&gt;commons-io&lt;/artifactId&gt;
        &lt;version&gt;2.3&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;commons-lang&lt;/groupId&gt;
          &lt;artifactId&gt;commons-lang&lt;/artifactId&gt;
          &lt;version&gt;2.6&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;commons-logging&lt;/groupId&gt;
          &lt;artifactId&gt;commons-logging&lt;/artifactId&gt;
          &lt;version&gt;1.1.1&lt;/version&gt;
      &lt;/dependency&gt;
  
       &lt;!-- Language recognizer required by Spring --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;antlr&lt;/groupId&gt;
          &lt;artifactId&gt;antlr&lt;/artifactId&gt;
          &lt;version&gt;2.7.7&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Test --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;junit&lt;/groupId&gt;
          &lt;artifactId&gt;junit&lt;/artifactId&gt;
          &lt;version&gt;4.7&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;        
  &lt;/dependencies&gt;
  </code></pre>
  
  <p>Currently the part of gradle script responsible for dependencies looks like that:</p>
  
  <pre><code>//----------------------------------------------------------------------------
  //                    SERVER'S DEPENDENCIES' CONFIGURATION
  //----------------------------------------------------------------------------
  
  configure(serverProjects) {
      repositories {
          mavenCentral()
          maven { url 'http://repository.jboss.org/nexus/content/groups/public' }
      }
  }
  
  // Spring Framework:
  def springVersion = '3.1.0.RELEASE'
  def springContext = "org.springframework:spring-context:${springVersion}"
  def springMVC     = "org.springframework:spring-webmvc:${springVersion}"
  def springAOP     = "org.springframework:spring-aop:${springVersion}"
  def springORM     = "org.springframework:spring-orm:${springVersion}"
  def springJDBC    = "org.springframework:spring-jdbc:${springVersion}"
  
  
  // Spring Security:
  def springSecurityVersion = '3.1.2.RELEASE'
  def springSecurityCore    = "org.springframework.security:spring-security-core:${springSecurityVersion}"
  def springSecurityLDAP    = "org.springframework.security:spring-security-ldap:${springSecurityVersion}"
  def springSecurityConfig  = "org.springframework.security:spring-security-config:${springSecurityVersion}"
  def springSecurityWeb     = "org.springframework.security:spring-security-web:${springSecurityVersion}"
  def springSecurityTaglibs = "org.springframework.security:spring-security-taglibs:${springSecurityVersion}"
  def springSecurityACL     = "org.springframework.security:spring-security-acl:${springSecurityVersion}"
  
  
  // Tiles:
  def tilesVersion = '2.1.4'
  def tilesCore    = "org.apache.tiles:tiles-core:${tilesVersion}"
  def tilesAPI     = "org.apache.tiles:tiles-api:${tilesVersion}"
  def tilesJSP     = "org.apache.tiles:tiles-jsp:${tilesVersion}"
  
  
  // AspectJ:
  def aspectJVersion = '1.6.9'
  def aspectJ        = "org.aspectj:aspectjrt:${aspectJVersion}"
  
  
  // Databases:
  def apacheDerbyVersion = '10.9.1.0'
  def apacheDerby        = "org.apache.derby:derbyclient:${apacheDerbyVersion}"
  
  def mySQLVersion = '5.1.19'
  def mySQL        = "mysql:mysql-connector-java:${mySQLVersion}"
  
  def postgreSQLVersion = '9.1-901.jdbc4'
  def postgreSQL        = "postgresql:postgresql:${postgreSQLVersion}"
  
  
  // Logging:
  def slf4jVersion = '1.5.10'
  def slf4jAPI     = "org.slf4j:slf4j-api:${slf4jVersion}"
  def slf4jJCL     = "org.slf4j:jcl-over-slf4j:${slf4jVersion}"
  def slf4jLog4J   = "org.slf4j:slf4j-log4j12:${slf4jVersion}"
  
  def log4JVersion = '1.2.15'
  def log4J        = "log4j:log4j:${log4JVersion}"
  
  // Javax:
  def javaxServletAPIVersion = '2.5'
  def javaxServletAPI        = "javax.servlet:servlet-api:${javaxServletAPIVersion}"
  
  def javaxJspApiVersion     = '2.1'
  def javaxJspApi            = "javax.servlet.jsp:jsp-api:${javaxJspApiVersion}"
  
  def javaxJSTLVersion       = '1.2'
  def javaxJSTL              = "javax.servlet:jstl:${javaxJSTLVersion}"
  
  def javaxInjectVersion     = '1'
  def javaxInject            = "javax.inject:javax.inject:${javaxInjectVersion}"
  
  def javaxValidationVersion = '1.0.0.GA'
  def javaxValidation        = "javax.validation:validation-api:${javaxValidationVersion}"
  
  
  // Hibernate:
  def hibernateCoreVersion      = '4.1.7.Final'
  def hibernateCore             = "org.hibernate:hibernate-core:${hibernateCoreVersion}"
  
  def hibernateValidatorVersion = '4.3.0.Final'
  def hibernateValidator        = "org.hibernate:hibernate-validator:${hibernateValidatorVersion}"
  
  def hibernateJPAVersion       = '1.0.1.Final'
  def hibernateJPA              = "org.hibernate.javax.persistence:hibernate-jpa-2.0-api:${hibernateJPAVersion}"
  
  
  // dom4j:
  def dom4JVersion = '1.6.1'
  def dom4J        = "dom4j:dom4j:${dom4JVersion}"
  
  
  // antlr:
  def antlrVersion = '2.7.7'
  def antlr        = "antlr:antlr:${antlrVersion}"
  
  
  // commons:
  def commonsBeanUtilsVersion   = '1.8.3'
  def commonsBeanUtils          = "commons-beanutils:commons-beanutils:${commonsBeanUtilsVersion}"
  
  def commonsCollectionsVersion = '3.2.1'
  def commonsCollections        = "commons-collections:commons-collections:${commonsCollectionsVersion}"
  
  def commonsDigesterVersion    = '2.1'
  def commonsDigester           = "commons-digester:commons-digester:${commonsDigesterVersion}"
  
  def commonsFileUploadVersion  = '1.2.2'
  def commonsFileUpload         = "commons-fileupload:commons-fileupload:${commonsFileUploadVersion}"
  
  def commonsIOVersion          = '2.3'
  def commonsIO                 = "commons-io:commons-io:${commonsIOVersion}"
  
  def commonsLangVersion        = '2.6'
  def commonsLang               = "commons-lang:commons-lang:${commonsLangVersion}"
  
  def commonsLoggingVersion     = '1.1.1'
  def commonsLogging            = "commons-logging:commons-logging:${commonsLoggingVersion}"
  
  
  // JUnit4:
  def jUnitVersion = '4.7'
  def jUnit        = "junit:junit:${jUnitVersion}"
  
  project(':WARProject') {
      dependencies {
          // Spring Framework:
          compile(springContext) {
              exclude group: 'commons-logging', module: 'commons-logging'
          }
          compile(
              springMVC,    springAOP,    springORM,     springJDBC
          )
  
          // Spring Security:
          compile(
              springSecurityCore,    springSecurityLDAP,        springSecurityConfig,
              springSecurityWeb,    springSecurityTaglibs,    springSecurityACL
          )
  
          // Tiles:
          compile(
              tilesCore, tilesAPI, tilesJSP
          )
  
          // AspectJ:
          compile(aspectJ)
  
          // Databases:
          compile(
              apacheDerby, mySQL, postgreSQL
          )
  
          // Logging:
          compile(slf4jAPI)
          runtime(
              slf4jJCL, slf4jLog4J
          )
          runtime(log4J) {
              exclude group: 'javax.mail',   module: 'mail'
              exclude group: 'javax.jms',    module: 'jms'
              exclude group: 'com.sun.jdmk', module: 'jmxtools'
              exclude group: 'com.sun.jmx',  module: 'jmxri'
          }
  
          // Javax:
          compile(
              javaxInject,        javaxValidation,        javaxJSTL
          )
          providedCompile(
              javaxServletAPI,    javaxJspApi
          )
  
          // Hibernate:
          compile(
              hibernateCore, hibernateValidator, hibernateJPA
          )
  
          // dom4j:
          compile(dom4J)
  
          // antlr:
          compile(antlr)
  
          // commons:
          compile(
              commonsBeanUtils,    commonsCollections,    commonsDigester,
              commonsFileUpload,    commonsIO,            commonsLang,
              commonsLogging
          )
  
          // JUnit:
          testCompile(
              jUnit
          )
      }
  }
  </code></pre>
  
  <p>When I try to build the WAR file, I receive information that <code>org.apache.log4j.Logger</code> package doesn't exists. If I replace <code>runtime</code> with <code>compile</code> i receive error <code>Artifact 'javax.jms:jms:1.1@jar' not found</code> as if <code>exclude</code> clauses were completely ignored.</p>
  
  <p><code>providedRuntime</code> and <code>providedCompile</code> have the same results as respectively <code>runtime</code> and <code>compile</code>.</p>
  
  <p>How should I modify script to build WAR file successfully?</p>
  
  <p>EDIT:</p>
  
  <p><code>gradle :WARProject:dependencies</code> shown:</p>
  
  <pre><code>...
  +--- org.slf4j:slf4j-log4j12:1.5.10 [default]
  |    +--- org.slf4j:slf4j-api:1.5.10 [compile,runtime,master] (*)
  |    \--- log4j:log4j:1.2.15 [compile,runtime,master]
  |         +--- javax.mail:mail:1.4 [compile,master,runtime]
  |         |    \--- javax.activation:activation:1.1 [compile,master,runtime]
  |         +--- javax.jms:jms:1.1 [compile,master,runtime]
  |         +--- com.sun.jdmk:jmxtools:1.2.1 [compile,master,runtime]
  |         \--- com.sun.jmx:jmxri:1.2.1 [compile,master,runtime]
  </code></pre>
  
  <p>which means that gradle didn't excluded those dependencies (it's the only, place where javax.jms:jms occurs). I tries adding <code>@jar</code> at the end of definition, as well as adding <code>transitive = false</code> in exclusion block - with no result. What else should I try?</p>