Created
June 18, 2014 09:39
-
-
Save sh1nj1/90f10c2c2828830f5bab to your computer and use it in GitHub Desktop.
Gradle configuration strips off JPA Annotations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task serverJar(type: Jar) { | |
classifier = 'server' | |
from sourceSets.main.output | |
} | |
task removeAnnotation << { | |
ant.echo("strip annotation") | |
ant.taskdef(resource: 'org/dyndns/fichtner/purgeannotationrefs/tasks/antlib.xml') { | |
classpath { | |
fileset(dir: '../app/ant/par_ant-0.3.1', includes: '*.jar') | |
} | |
} | |
println sourceSets.main.output.classesDir | |
ant.purgeannotationrefs() { | |
src { | |
fileset(dir: sourceSets.main.output.classesDir) | |
} | |
remove(annotation: "javax.persistence.Entity") | |
remove(annotation: "javax.persistence.MappedSuperclass") | |
remove(annotation: "javax.persistence.Column") | |
remove(annotation: "javax.persistence.Id") | |
remove(annotation: "javax.persistence.GeneratedValue") | |
remove(annotation: "javax.persistence.Transient") | |
remove(annotation: "javax.persistence.ManyToOne") | |
remove(annotation: "javax.persistence.OneToMany") | |
remove(annotation: "javax.persistence.OneToOne") | |
remove(annotation: "javax.persistence.ElementCollection") | |
remove(annotation: "javax.persistence.Embeddable") | |
remove(annotation: "javax.persistence.PrePersist") | |
remove(annotation: "javax.persistence.PreUpdate") | |
} | |
ant.echo("end strip annotation") | |
} | |
serverJar.dependsOn classes | |
removeAnnotation.dependsOn serverJar | |
jar { | |
dependsOn removeAnnotation | |
classifier = 'client' | |
from(sourceSets.main.output) | |
exclude('android/**/*') | |
} | |
artifacts { | |
archives jar | |
archives serverJar | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment