pom.xml 構成を gradle スクリプトに書き直そうとしています。pom の依存関係に関する部分は次のようになります。
<dependencies>
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework-version}</version>
<exclusions>
<!-- Exclude Commons Logging in favor of SLF4j -->
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<!-- Spring security -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>${spring.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-ldap</artifactId>
<version>${spring.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>${spring.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>${spring.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>${spring.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-acl</artifactId>
<version>${spring.security.version}</version>
</dependency>
<!-- Tiles dependancies -->
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-api</artifactId>
<version>2.1.4</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-core</artifactId>
<version>2.1.4</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-jsp</artifactId>
<version>2.1.4</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-servlet</artifactId>
<version>2.1.4</version>
</dependency>
<!-- AspectJ -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${org.aspectj-version}</version>
</dependency>
<!-- MySQL database driver -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.19</version>
</dependency>
<!-- PostgreSQL database driver -->
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901.jdbc4</version>
</dependency>
<!-- Required by databases -->
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbyclient</artifactId>
<version>10.9.1.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${org.slf4j-version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${org.slf4j-version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${org.slf4j-version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.15</version>
<exclusions>
<exclusion>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
</exclusion>
<exclusion>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jdmk</groupId>
<artifactId>jmxtools</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jmx</groupId>
<artifactId>jmxri</artifactId>
</exclusion>
</exclusions>
<scope>runtime</scope>
</dependency>
<!-- @Inject -->
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<!-- Servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- Validation -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
</dependency>
<!-- Hibernate -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.1.7.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.3.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>1.0.1.Final</version>
</dependency>
<!-- DOM4j -->
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
<!-- Commons -->
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.8.3</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>commons-digester</groupId>
<artifactId>commons-digester</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<!-- Language recognizer required by Spring -->
<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
<version>2.7.7</version>
</dependency>
<!-- Test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
</dependencies>
現在、依存関係を担当する gradle スクリプトの部分は次のようになります。
//----------------------------------------------------------------------------
// 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
)
}
}
WAR ファイルをビルドしようとすると、org.apache.log4j.Logger
パッケージが存在しないという情報が表示されます。I を i に置き換えるruntime
と、句が完全に無視されたかのようにcompile
エラーが発生します。Artifact 'javax.jms:jms:1.1@jar' not found
exclude
providedRuntime
とはそれぞれと とprovidedCompile
同じ結果になります。runtime
compile
WAR ファイルを正常にビルドするには、スクリプトをどのように変更すればよいですか?
編集:
gradle :WARProject:dependencies
表示:
...
+--- 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]
これは、gradle がそれらの依存関係を除外しなかったことを意味します (javax.jms:jms が発生する唯一の場所です)。@jar
定義の最後に追加transitive = false
し、除外ブロックに追加しようとしましたが、結果はありません。他に何を試す必要がありますか?