-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
209 lines (180 loc) · 6.7 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
def aspectjversion = "1.8.9"
/**
* This gradle 1.9 file is building one java and source fiiles with groovy gradle
* plugin and with (ant) ajc compiler compiling aspectj classes and weaving those aspects
* into compiled classes. In class weaving there are used normal mode weaving for java
* aspects and incremental weaving for groovy aspects.
* At last as default tasks two java/groovy apps are started.
*/
// apply plugin: 'java'
apply plugin: 'groovy'
def alllibjars = fileTree(dir: 'libs', includes: ['*.jar'])
buildscript {
repositories {
maven {
url "https://maven.eveoh.nl/content/repositories/releases"
}
}
dependencies {
// classpath "nl.eveoh:gradle-aspectj:1.4
classpath "nl.eveoh:gradle-aspectj:1.6"
//classpath "gradle-aspectj:1.5"
}
}
repositories {
// alllibjars
// flatDir name: 'localRepository', dirs: 'lib'
// flatDir name: 'localRepository', dirs: ['lib', '/java/versiot/git/gradle-aspectj/build/libs']
// url "https://maven.eveoh.nl/content/repositories/releases"
//classpath fileTree(dir: '/java/versiot/git/gradle-aspectj/build/libs',
// includes: ['gradle-aspectj-1.5.jar'])
mavenCentral()
}
project.ext {
//aspectjVersion = '1.8.0'
aspectjVersion = aspectjversion
}
configurations {
ajc
aspects
aspectCompile
compile {
extendsFrom aspects
}
}
/* earlier copy/paste from java version, which is workign for java files:
*
compileJava {
sourceCompatibility="1.8"
targetCompatibility="1.8"
doLast{
ant.taskdef( resource:"org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties", classpath: configurations.ajc.asPath)
ant.iajc(source:"1.8", target:"1.8", destDir:sourceSets.main.output.classesDir.absolutePath, maxmem:"512m", fork:"true",
aspectPath:configurations.aspects.asPath, sourceRootCopyFilter:"** /.svn/*,** /*.java",classpath:"${configurations.compile.asPath};${configurations.aspectCompile.asPath};${configurations.aspects.asPath}:${configurations.ajc.asPath}"){
sourceroots{
sourceSets.main.java.srcDirs.each{
pathelement(location:it.absolutePath)
}
}
}
}
}
*/
def tagfilename = "iajc.woven.tag"
compileGroovy {
sourceCompatibility="1.8"
targetCompatibility="1.8"
doLast{
ant.taskdef( resource:"org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties", classpath: configurations.ajc.asPath)
/**
* This iajc ant call may need an buildDir value for find all ready compiled classes!
* It compiles all .java and .groovy and .aj classes and weaving java aspect .classes but not groovy aspect .classes:
*/
ant.iajc(source:sourceCompatibility, target:targetCompatibility, destDir:sourceSets.main.output.classesDir.absolutePath, maxmem:"512m", fork:"true",
aspectPath:configurations.aspects.asPath, sourceRootCopyFilter:"**/.svn/*,**/*.java,**/*.class",classpath:"${sourceSets.main.output.classesDir.absolutePath};${configurations.compile.asPath};${configurations.aspectCompile.asPath}"){
sourceroots{
sourceSets.main.java.srcDirs.each{
// println "java.source " +it.absolutePath
pathelement(location:it.absolutePath)
}
}
}
/**
* For real situaation this tag file should be deleted/updated only when needed
* for incremental compiling. That is some source files are just compiled/updated
* to start this next ant.iajc call:
*/
ant.delete(file: tagfilename)
/*
File file = new File("iajc.woven.tag");
try {
if (file.exists())
file.delete()
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
*/
ant.touch(file: tagfilename)
/**
* This iajc ant call needs an buildDir value for find all ready compiled classes!
* Normal mode iajc call is not working for groovy aspect classes (class weaving)!
* It weaves groovy aspect .classes by incremental compiling:
*/
ant.iajc(source:sourceCompatibility, target:targetCompatibility,
destDir:sourceSets.main.output.classesDir.absolutePath,
maxmem:"512m", fork:"true",
tagfile: tagfilename,
aspectPath:configurations.aspects.asPath,
sourceRootCopyFilter:"**/.svn/*,**/*.groovy,**/*.class",
inpathDirCopyFilter:"**/.svn/*,**/*.groovy,**/*.class",
classpath:"${sourceSets.main.output.classesDir.absolutePath};${configurations.compile.asPath};${configurations.aspectCompile.asPath}",
incremental: "true"){
sourceroots{
sourceSets.main.groovy.srcDirs.each{
println "groovy.source " +it.absolutePath
pathelement(location:it.absolutePath)
}
}
inpath {
pathelement(location:buildDir.absolutePath)
}
}
}
}
// def aspectjversion = "1.6.10"
// def aspectjversion = "1.7.4"
// def aspectjversion = "1.8.0"
//def springversion = "3.2.2.RELEASE"
def springversion = "3.2.6.RELEASE"
//def springversion = "4.0.6.RELEASE"
// def groovy_compiler_version = '2.4.6'
def groovy_compiler_version = '2.4.7'
def groovy_all = 'org.codehaus.groovy:groovy-all:' +groovy_compiler_version
def aspectj_tool = 'org.aspectj:aspectjtools:'+aspectjversion
//def aspectj_rt = 'org.codehaus.groovy:groovy-all:2.1.9'
def aspectj_rt = 'org.aspectj:aspectjrt:'+aspectjversion
def aspectj_aspects = 'org.springframework:spring-aspects:' + springversion
dependencies {
ajc aspectj_tool
ajc groovy_all
compile aspectj_rt
compile groovy_all
aspects aspectj_aspects
aspectCompile "javax.persistence:persistence-api:1.0"
aspectCompile "org.springframework:spring-tx:$springversion"
// aspectCompile aspectj_rt
aspectCompile groovy_all
runtime aspectj_rt
runtime groovy_all
}
apply plugin: 'aspectj'
/**
* not needed here:
*/
task defaultProperties << {
println "Project: $project"
println "Name: $name"
println "Path: $path"
println "Project directory: $projectDir"
println "Build directory: $buildDir"
println "Version: $version"
println "Group: $project.group"
println "Description: $project.description"
println "AntBuilder: $ant"
println "sourceSets.main.runtimeClasspath" +sourceSets.main.runtimeClasspath.each { println it }
}
task(runJava, dependsOn: 'classes', type: JavaExec) {
main = 'fi.test.Test'
classpath = sourceSets.main.runtimeClasspath
args 'mrhaki'
systemProperty 'simple.message', 'Hello '
}
task(runGroovymy, dependsOn: 'classes', type: JavaExec) {
buildscript.configurations.classpath.each { println it }
main = 'testgroovyaspect.TestGroovyAspectj'
classpath = sourceSets.main.runtimeClasspath
args 'mrhaki'
systemProperty 'simple.message', 'Hello'
}
defaultTasks 'runJava', 'runGroovy'