Skip to content

Instantly share code, notes, and snippets.

@sh1nj1
Created June 18, 2014 09:39
Show Gist options
  • Save sh1nj1/90f10c2c2828830f5bab to your computer and use it in GitHub Desktop.
Save sh1nj1/90f10c2c2828830f5bab to your computer and use it in GitHub Desktop.
Gradle configuration strips off JPA Annotations
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