Skip to content

Commit d6c73c0

Browse files
committed
Only classes with suffix 'Entity' / performance / fail-safe
1 parent a089683 commit d6c73c0

File tree

3 files changed

+44
-12
lines changed

3 files changed

+44
-12
lines changed

README.md

+20-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,23 @@ Plugin for enhancing JPA entity classes at compile time to be ready for OpenJPA.
1616

1717
## License
1818

19-
Apache License 2.0
19+
Apache License 2.0
20+
21+
## Usage
22+
23+
By default, plugin enhances all classes that have suffix `Entity`, e.g `UserEntity`, `PostEntity` etc.
24+
But that behavior can be customized to any needs, see below example.
25+
26+
```
27+
28+
apply plugin: 'neva.openjpa'
29+
30+
enhanceEntities {
31+
32+
includeFilter = {
33+
include '**/*Entity.class'
34+
}
35+
36+
}
37+
38+
```

build.gradle

+14-6
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ buildscript {
99
}
1010
}
1111

12-
group 'com.neva.gradle.plugin'
13-
version '1.0.0'
14-
defaultTasks = ['clean', 'install']
15-
1612
apply plugin: 'groovy'
17-
apply plugin: 'maven'
13+
apply plugin: 'maven-publish'
1814
apply plugin: 'com.gradle.plugin-publish'
1915

16+
group = 'com.neva.gradle.plugin'
17+
version = '1.0.1'
18+
defaultTasks = ['clean', 'install']
19+
2020
repositories {
2121
jcenter()
2222
mavenCentral()
@@ -26,7 +26,7 @@ dependencies {
2626
compile gradleApi()
2727
compile localGroovy()
2828

29-
compile 'org.apache.openjpa:openjpa:2.3.0'
29+
compile 'org.apache.openjpa:openjpa:2.4.1'
3030
}
3131

3232
jar {
@@ -38,6 +38,14 @@ jar {
3838
}
3939
}
4040

41+
publishing {
42+
publications {
43+
mavenJava(MavenPublication) {
44+
from components.java
45+
}
46+
}
47+
}
48+
4149
pluginBundle {
4250
website = 'http://javarel.neva.zone/'
4351
vcsUrl = 'https://github.com/neva-dev/gradle-openjpa-plugin'

src/main/groovy/com/neva/gradle/plugin/openjpa/task/EnhanceTask.groovy

+10-5
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ class EnhanceTask extends AbstractTask {
88

99
static final NAME = "enhanceEntities"
1010

11+
def includeFilter = {
12+
include '**/*Entity.class'
13+
}
14+
1115
EnhanceTask() {
1216
description = "Enhance JPA entity classes using OpenJPA Enhancer"
1317

1418
configure {
15-
outputs.upToDateWhen { false }
16-
19+
inputs.dir(inputDir)
1720
dependsOn([project.compileJava, project.processResources])
1821
project.classes.dependsOn this
1922
}
@@ -22,9 +25,7 @@ class EnhanceTask extends AbstractTask {
2225
@TaskAction
2326
def run() {
2427
// define the entity classes
25-
def entityFiles = project.fileTree(project.sourceSets.main.output.classesDir).matching {
26-
include '**/*.class'
27-
}
28+
def entityFiles = project.fileTree(inputDir).matching(this.includeFilter)
2829

2930
println "Enhancing with OpenJPA, the following files..."
3031
entityFiles.getFiles().each {
@@ -51,4 +52,8 @@ class EnhanceTask extends AbstractTask {
5152
}
5253
}
5354

55+
def getInputDir() {
56+
return project.sourceSets.main.output.classesDir
57+
}
58+
5459
}

0 commit comments

Comments
 (0)