Gradle Metamodel Plugin generates static metamodel classes
For Gradle 5+ use the new Gradle Sourcegen Plugin
Build script snippet for plugins DSL for Gradle 2.1 and later:
plugins {
id "com.scalified.plugins.gradle.metamodel" version "0.0.1"
}
Build script snippet for use in older Gradle versions or where dynamic configuration is required:
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.com.scalified.plugins.gradle:metamodel:0.0.1"
}
}
apply plugin: "com.scalified.plugins.gradle.metamodel"
After applying the plugin, the following takes place:
- JavaPlugin applied if not yet applied
- New directories are created (if missing):
- Generated source set directory for metamodel classes (the value of metamodel.srcDir property, which is src/generated/java by default)
- Metamodel source set directory marked as generated source directory (IntelliJ IDEA only)
- Gradle metamodel configuration added
- Gradle metamodel source set added
- Java source directories of main source set are extended with java source directories of metamodel source set
- Gradle tasks added:
- metamodelClean - cleans the content of metamodel source directory (does not remove the directory itself)
- metamodelCompile - generates metamodel classes into metamodel source directory
- Task dependencies added:
- clean depends on metamodelClean
- compileJava depends on metamodelCompile
- Hibernate static metamodel generator dependency added to metamodel configuration
Currently the following configuration parameters supported (default values are shown):
metamodel {
srcDir = 'src/generated/java' // metamodel generated source directory
hibernateVersion = '+' // hibernate static metamodel generator version
processor = 'org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor' // metamodel processor
}
You may also wish to add the metamodel source directory to .gitignore for exclusion
If you need more configuration options, you may send a request with description
MIT License
Copyright (c) 2018 Scalified
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.