METAGEN-79 Unified skipGeneratedAnnotation and addGeneratedAnnotation
This commit is contained in:
parent
d5110ad8bc
commit
f946f60471
|
@ -0,0 +1,37 @@
|
|||
# Hibernate JPA 2 Metamodel Generator
|
||||
|
||||
## Latest stable version
|
||||
|
||||
*1.2.0.Final, 06.03.2012*
|
||||
|
||||
## What is it?
|
||||
|
||||
The Hibernate JPA 2 Metamodel Generator is a Java 6 annotation processor generating meta model classes for JPA 2 type-safe criteria queries.
|
||||
|
||||
The processor (*JPAMetaModelEntityProcessor*) processes classes annotated with *@Entity*, *@MappedSuperclass* or *@Embeddable*, as well as entities mapped in */META-INF/orm.xml* and mapping files specified in *persistence.xml*.
|
||||
|
||||
## System Requirements
|
||||
|
||||
JDK 1.6 or above.
|
||||
|
||||
## Licensing
|
||||
|
||||
Please see the file called license.txt
|
||||
|
||||
## Documentation
|
||||
|
||||
[JPA 2 Metamodel Generator Documentation](http://www.hibernate.org/subprojects/jpamodelgen/docs)
|
||||
|
||||
## Resources
|
||||
|
||||
* [Home Page](http://www.hibernate.org/subprojects/jpamodelgen.html)
|
||||
* [Source Code](http://github.com/hibernate/hibernate-metamodelgen)
|
||||
* [Mailing Lists](http://www.hibernate.org/community/mailinglists)
|
||||
* [Issue Tracking](http://opensource.atlassian.com/projects/hibernate/browse/METAGEN)
|
||||
|
||||
## Build from source
|
||||
|
||||
git clone git@github.com:hibernate/hibernate-metamodelgen.git
|
||||
cd hibernate-metamodelgen
|
||||
mvn clean package
|
||||
|
|
@ -1,6 +1,10 @@
|
|||
Hibernate JPA 2 Metamodel Generator Changelog
|
||||
=============================================
|
||||
|
||||
1.2.0.Final (06.03.2012)
|
||||
----------------------
|
||||
|
||||
|
||||
1.2.0.CR1 (25.01.2012)
|
||||
----------------------
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-jpamodelgen</artifactId>
|
||||
<version>1.2.0-SNAPSHOT</version>
|
||||
<version>1.3.0-SNAPSHOT</version>
|
||||
|
||||
<name>Hibernate JPA 2 Metamodel Generator</name>
|
||||
<description>Annotation Processor to generate JPA 2 static metamodel classes</description>
|
||||
|
@ -114,7 +114,7 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-enforcer-plugin</artifactId>
|
||||
<version>1.0-beta-1</version>
|
||||
<version>1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>enforce-java</id>
|
||||
|
@ -241,7 +241,7 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
<version>2.3.1</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
|
@ -258,26 +258,13 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>2.2-beta-2</version>
|
||||
<version>2.2.1</version>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>src/main/assembly/dist.xml</descriptor>
|
||||
</descriptors>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
<version>2.0-beta-9</version>
|
||||
<configuration>
|
||||
<autoVersionSubmodules>true</autoVersionSubmodules>
|
||||
<allowTimestampedSnapshots>true</allowTimestampedSnapshots>
|
||||
<goals>package deploy javadoc:javadoc org.jboss.maven.plugins:maven-jdocbook-plugin:2.2.1:resources
|
||||
org.jboss.maven.plugins:maven-jdocbook-plugin:2.2.1:generate assembly:assembly
|
||||
</goals>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.jboss.maven.plugins</groupId>
|
||||
<artifactId>maven-jdocbook-plugin</artifactId>
|
||||
|
@ -337,6 +324,24 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>2.7</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
<version>2.2.1</version>
|
||||
<configuration>
|
||||
<autoVersionSubmodules>true</autoVersionSubmodules>
|
||||
<allowTimestampedSnapshots>true</allowTimestampedSnapshots>
|
||||
<tagNameFormat>@{project.version}</tagNameFormat>
|
||||
<goals>package deploy javadoc:javadoc org.jboss.maven.plugins:maven-jdocbook-plugin:2.3.5:resources
|
||||
org.jboss.maven.plugins:maven-jdocbook-plugin:2.3.5:generate assembly:assembly
|
||||
</goals>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
Hibernate JPA 2 Metamodel Generator
|
||||
|
||||
What is it?
|
||||
-----------
|
||||
|
||||
This is a Java 6 annotation processor generating meta model classes for the JPA 2 criteria queries.
|
||||
The processor (JPAMetaModelEntityProcessor) processes all classes annotated with @Entity, @MappedSuperclass
|
||||
or @Embeddable, as well as entities mapped in /META-INF/orm.xml and mapping files specified in persistence.xml.
|
||||
|
||||
|
||||
Latest stable version
|
||||
-------------------
|
||||
|
||||
1.2.0.CR1, 25.01.2012
|
||||
|
||||
|
||||
System Requirements
|
||||
-------------------
|
||||
|
||||
JDK 1.6 or above.
|
||||
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
http://docs.jboss.org/hibernate/stable/jpamodelgen/reference/en-US/
|
||||
|
||||
|
||||
Licensing
|
||||
---------
|
||||
|
||||
Please see the file called license.txt
|
||||
|
||||
|
||||
Resources
|
||||
---------
|
||||
|
||||
Home Page: http://www.hibernate.org/subprojects/jpamodelgen.html
|
||||
Mailing Lists: http://www.hibernate.org/community/mailinglists
|
||||
Source Code: http://github.com/hibernate/hibernate-metamodelgen
|
||||
Issue Tracking: http://opensource.atlassian.com/projects/hibernate/browse/METAGEN
|
||||
|
|
@ -59,7 +59,7 @@
|
|||
<includes>
|
||||
<include>pom.xml</include>
|
||||
<include>license.txt</include>
|
||||
<include>readme.txt</include>
|
||||
<include>README.md</include>
|
||||
<include>changelog.txt</include>
|
||||
<include>src/**</include>
|
||||
</includes>
|
||||
|
|
|
@ -550,22 +550,12 @@ cq.where( cb.equal(itemNode.get(Item_.id), 5 ) ).distinct(true);
|
|||
<row>
|
||||
<entry>addGeneratedAnnotation</entry>
|
||||
|
||||
<entry>this option is deprecated and has no effect. The
|
||||
<classname>@Generation</classname> annotation is added per
|
||||
default.</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>skipGeneratedAnnotation</entry>
|
||||
|
||||
<entry>If set to <literal>true</literal> the processor will
|
||||
not the <classname>@Generated</classname> to the generated
|
||||
Java source file. The default for this option is
|
||||
<constant>false</constant> and the
|
||||
<classname>@Generated</classname> annotation is added to the
|
||||
source code. Adding this annotation using JDK 5will cause a
|
||||
compilation error. In this case set the flag to
|
||||
<constant>true</constant>.</entry>
|
||||
add the <classname>@Generated</classname> to the generated
|
||||
Java source file. Adding this annotation using JDK 5will cause
|
||||
a compilation error. In this case set the flag to
|
||||
<constant>false</constant>. The default for this option is
|
||||
<constant>true</constant></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
|
@ -575,8 +565,8 @@ cq.where( cb.equal(itemNode.get(Item_.id), 5 ) ).distinct(true);
|
|||
of the metamodel class will be inserted in the date parameter
|
||||
of the <classname>@Generated</classname> annotation. The
|
||||
default is <constant>false</constant>. This parameter is
|
||||
ignored if <constant>skipGeneratedAnnotation</constant> is
|
||||
specified.</entry>
|
||||
ignored if <constant>addGeneratedAnnotation</constant> is set
|
||||
to <constant>false</constant>.</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
|
|
|
@ -106,7 +106,7 @@ public final class ClassWriter {
|
|||
try {
|
||||
pw = new PrintWriter( sw );
|
||||
|
||||
if ( !context.skipGeneratedAnnotation() ) {
|
||||
if ( context.addGeneratedAnnotation() ) {
|
||||
pw.println( writeGeneratedAnnotation( entity, context ) );
|
||||
}
|
||||
if ( context.isAddSuppressWarningsAnnotation() ) {
|
||||
|
|
|
@ -61,7 +61,7 @@ public final class Context {
|
|||
private final List<String> ormXmlFiles;
|
||||
|
||||
private boolean isPersistenceUnitCompletelyXmlConfigured;
|
||||
private boolean skipGeneratedAnnotation;
|
||||
private boolean addGeneratedAnnotation = true;
|
||||
private boolean addGenerationDate;
|
||||
private boolean addSuppressWarningsAnnotation;
|
||||
private AccessType persistenceUnitDefaultAccessType;
|
||||
|
@ -102,12 +102,12 @@ public final class Context {
|
|||
return pe;
|
||||
}
|
||||
|
||||
public boolean skipGeneratedAnnotation() {
|
||||
return skipGeneratedAnnotation;
|
||||
public boolean addGeneratedAnnotation() {
|
||||
return addGeneratedAnnotation;
|
||||
}
|
||||
|
||||
public void setSkipGeneratedAnnotation(boolean skipGeneratedAnnotation) {
|
||||
this.skipGeneratedAnnotation = skipGeneratedAnnotation;
|
||||
public void setAddGeneratedAnnotation(boolean addGeneratedAnnotation) {
|
||||
this.addGeneratedAnnotation = addGeneratedAnnotation;
|
||||
}
|
||||
|
||||
public boolean addGeneratedDate() {
|
||||
|
|
|
@ -63,7 +63,6 @@ import org.hibernate.jpamodelgen.xml.XmlParser;
|
|||
JPAMetaModelEntityProcessor.ORM_XML_OPTION,
|
||||
JPAMetaModelEntityProcessor.FULLY_ANNOTATION_CONFIGURED_OPTION,
|
||||
JPAMetaModelEntityProcessor.LAZY_XML_PARSING,
|
||||
JPAMetaModelEntityProcessor.SKIP_GENERATED_ANNOTATION,
|
||||
JPAMetaModelEntityProcessor.ADD_GENERATED_ANNOTATION,
|
||||
JPAMetaModelEntityProcessor.ADD_SUPPRESS_WARNINGS_ANNOTATION
|
||||
})
|
||||
|
@ -73,11 +72,7 @@ public class JPAMetaModelEntityProcessor extends AbstractProcessor {
|
|||
public static final String ORM_XML_OPTION = "ormXml";
|
||||
public static final String FULLY_ANNOTATION_CONFIGURED_OPTION = "fullyAnnotationConfigured";
|
||||
public static final String LAZY_XML_PARSING = "lazyXmlParsing";
|
||||
public static final String SKIP_GENERATED_ANNOTATION = "skipGeneratedAnnotation";
|
||||
public static final String ADD_GENERATION_DATE = "addGenerationDate";
|
||||
/**
|
||||
* @deprecated since 1.2
|
||||
*/
|
||||
public static final String ADD_GENERATED_ANNOTATION = "addGeneratedAnnotation";
|
||||
public static final String ADD_SUPPRESS_WARNINGS_ANNOTATION = "addSuppressWarningsAnnotation";
|
||||
|
||||
|
@ -93,9 +88,11 @@ public class JPAMetaModelEntityProcessor extends AbstractProcessor {
|
|||
Diagnostic.Kind.NOTE, "Hibernate JPA 2 Static-Metamodel Generator " + Version.getVersionString()
|
||||
);
|
||||
|
||||
String tmp = env.getOptions().get( JPAMetaModelEntityProcessor.SKIP_GENERATED_ANNOTATION );
|
||||
boolean addGeneratedAnnotation = Boolean.parseBoolean( tmp );
|
||||
context.setSkipGeneratedAnnotation( addGeneratedAnnotation );
|
||||
String tmp = env.getOptions().get( JPAMetaModelEntityProcessor.ADD_GENERATED_ANNOTATION );
|
||||
if ( tmp != null ) {
|
||||
boolean addGeneratedAnnotation = Boolean.parseBoolean( tmp );
|
||||
context.setAddGeneratedAnnotation( addGeneratedAnnotation );
|
||||
}
|
||||
|
||||
tmp = env.getOptions().get( JPAMetaModelEntityProcessor.ADD_GENERATION_DATE );
|
||||
boolean addGenerationDate = Boolean.parseBoolean( tmp );
|
||||
|
|
|
@ -90,6 +90,7 @@ public class MetaAttributeGenerationVisitor extends SimpleTypeVisitor6<Annotatio
|
|||
return new AnnotationMetaSingleAttribute( entity, element, TypeUtils.toTypeString( t ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnnotationMetaAttribute visitTypeVariable(TypeVariable t, Element element) {
|
||||
// METAGEN-29 - for a type variable we use the upper bound
|
||||
TypeMirror mirror = t.getUpperBound();
|
||||
|
|
|
@ -48,7 +48,7 @@ public class SkipGeneratedAnnotationTest extends CompilationTest {
|
|||
@Override
|
||||
protected Map<String, String> getProcessorOptions() {
|
||||
Map<String, String> properties = new HashMap<String, String>();
|
||||
properties.put( JPAMetaModelEntityProcessor.SKIP_GENERATED_ANNOTATION, "true" );
|
||||
properties.put( JPAMetaModelEntityProcessor.ADD_GENERATED_ANNOTATION, "false" );
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue