【发布时间】:2014-06-04 07:35:58
【问题描述】:
我看到的大多数使用 Gradle + Spring-data-neo4j + Aspectj 的配置都是用于 Eclipse 和/或使用 Maven。我找不到一个完整的设置来正常工作。
这是我的 build.gradle:
apply plugin:'base'
apply plugin:'java'
apply plugin:'idea'
buildscript {
repositories {
maven {
url "https://maven.eveoh.nl/content/repositories/releases"
}
}
dependencies {
classpath "nl.eveoh:gradle-aspectj:1.4"
}
}
repositories {
maven {
url "http://m2.neo4j.org/content/repositories/releases/"
}
mavenCentral()
mavenLocal()
}
project.ext {
springVersion = "4.0.3.RELEASE"
neo4jVersion = "2.0.1.RELEASE"
springDataGraphVersion = "3.0.1.RELEASE"
aspectjVersion = "1.7.4"
sourceCompatibility = 1.7
targetCompatibility = 1.7
}
apply plugin: 'aspectj'
compileAspect {
xlint = 'warning'
}
dependencies {
compile 'org.slf4j:slf4j-api:1.7.6'
compile "org.springframework:spring-context:${springVersion}"
compile "org.neo4j:neo4j:${neo4jVersion}"
// Provides Repository based Object <-> Graph Mapping
compile "javax.validation:validation-api:1.0.0.GA"
compile "org.springframework.data:spring-data-neo4j-aspects:${springDataGraphVersion}"
compile 'javax.persistence:persistence-api:1.0-rev-1'
testCompile 'junit:junit-dep:4.11'
testCompile "org.springframework:spring-test:${springVersion}"
testCompile 'org.hamcrest:hamcrest-all:1.3'
// Access to Neo4j testing facilities: TestGraphDatabaseFactory
testCompile "org.neo4j:neo4j-kernel:${neo4jVersion}:tests@jar"
testRuntime 'org.slf4j:slf4j-simple:1.7.5'
//aspectj dependencies
aspectpath "org.aspectj:aspectjtools:${aspectjVersion}"
compile "org.aspectj:aspectjrt:${aspectjVersion}"
aspectpath group: "org.springframework.data", name: "spring-data-neo4j", version: springDataGraphVersion
}
configurations {
runtime
compileJava
testCompileJava
}
// Generate wrapper for Gradle
task wrapper(type: Wrapper) {
gradleVersion = '1.11'
}
current documentation 中似乎没有 Aspectj gradle 信息。我使用了来自2.3.5.RELEASE 的信息,这些信息已合并到此版本中。我还为编译器设置了 ajc,但我仍然认为有些东西已经过时了。另外,我没有使用 pom.xml,而是使用下面的 Java 配置文件。
@Configuration
@ComponentScan(basePackages = "domains")
@EnableNeo4jRepositories(basePackages = "repos")
//@EnableSpringConfigured
@EnableTransactionManagement
public class AppConfigTest extends Neo4jAspectConfiguration {
public AppConfigTest () {
setBasePackage("domains");
}
@Bean (destroyMethod = "shutdown")
public GraphDatabaseService graphDatabaseService() {
return new TestGraphDatabaseFactory().newImpermanentDatabase();
}
}
==============[编辑1]=================
使用项目eveoh/gradle-aspectj 更新了上面的 Gradle 构建文件,如下面的@StefanArmbruster 所述。但是,现在我收到此错误:
* Where:
Build file 'build.gradle' line: 52
> Could not find method aspectpath() for arguments [org.aspectj:aspectjtools:1.7.4] on root project
==============[编辑 2]=================
更新的 Gradle 版本暂时修复了上述问题,但现在我遇到了这个问题:
10:44:10 AM: Executing external task 'build'...
:processResources UP-TO-DATE
:compileAspect FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileAspect'.
> Error creating temporary file
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 42.556 secs
Permission denied
10:44:53 AM: External task execution finished 'build'.
【问题讨论】:
-
不确定,但也许使用一个现成的 aspectj 插件用于 gradle 可能会有所帮助:github.com/eveoh/gradle-aspectj
-
@StefanArmbruster 这很有趣:我大约一个小时前才发现那个项目。你有使用插件的好例子吗?
-
我自己还没有用过这个,但是看起来差不多是你需要的。
-
稍后让我进一步研究并让您知道
-
@StefanArmbruster 更新了我的问题。
标签: intellij-idea neo4j gradle spring-data