use of com.querydsl.codegen.GenericExporter in project querydsl by querydsl.
the class GenericExporterTest method execute3.
@Test
public void execute3() {
GenericExporter exporter = new GenericExporter();
exporter.setKeywords(Keywords.JPA);
exporter.setEntityAnnotation(Entity.class);
exporter.setEmbeddableAnnotation(Embeddable.class);
exporter.setEmbeddedAnnotation(Embedded.class);
exporter.setSupertypeAnnotation(MappedSuperclass.class);
exporter.setSkipAnnotation(Transient.class);
exporter.setTargetFolder(new File("target/GenericExporterTest3"));
exporter.setPropertyHandling(PropertyHandling.JPA);
exporter.export(CustomCollection.MyCustomCollection.class, CustomCollection.MyCustomCollection2.class, CustomCollection.MyEntity.class);
}
use of com.querydsl.codegen.GenericExporter in project querydsl by querydsl.
the class GenericExporterTest method execute4.
@Test
public void execute4() throws IOException {
GenericExporter exporter = new GenericExporter();
exporter.setKeywords(Keywords.JPA);
exporter.setEntityAnnotation(Entity.class);
exporter.setEmbeddableAnnotation(Embeddable.class);
exporter.setEmbeddedAnnotation(Embedded.class);
exporter.setSupertypeAnnotation(MappedSuperclass.class);
exporter.setSkipAnnotation(Transient.class);
exporter.setTargetFolder(new File("target/GenericExporterTest4"));
exporter.setPropertyHandling(PropertyHandling.JPA);
exporter.export(Generic2Test.class.getClasses());
}
use of com.querydsl.codegen.GenericExporter in project querydsl by querydsl.
the class GenericExporterTest method execute.
@Test
public void execute() throws IOException {
// via APT
process(QuerydslAnnotationProcessor.class, CLASSES, "QuerydslAnnotationProcessor");
// via GenericExporter
GenericExporter exporter = new GenericExporter();
exporter.setTargetFolder(new File("target/GenericExporterTest"));
exporter.export(AbstractEntityTest.class.getPackage(), A.class.getPackage());
List<String> expected = new ArrayList<String>();
// delegates are not supported
expected.add("QDelegateTest_SimpleUser.java");
expected.add("QDelegateTest_SimpleUser2.java");
expected.add("QDelegateTest_User.java");
expected.add("QDelegate2Test_Entity.java");
expected.add("QExampleEntity.java");
expected.add("QQueryProjectionTest_DTOWithProjection.java");
expected.add("QQueryProjectionTest_EntityWithProjection.java");
expected.add("QEmbeddable3Test_EmbeddableClass.java");
expected.add("QQueryEmbedded4Test_User.java");
execute(expected, "GenericExporterTest", "QuerydslAnnotationProcessor");
}
use of com.querydsl.codegen.GenericExporter in project querydsl by querydsl.
the class GenericExporterTest method execute2.
@Test
public void execute2() throws IOException {
// via APT
process(HibernateAnnotationProcessor.class, CLASSES, "HibernateAnnotationProcessor");
// via GenericExporter
GenericExporter exporter = new GenericExporter();
exporter.setKeywords(Keywords.JPA);
exporter.setEntityAnnotation(Entity.class);
exporter.setEmbeddableAnnotation(Embeddable.class);
exporter.setEmbeddedAnnotation(Embedded.class);
exporter.setSupertypeAnnotation(MappedSuperclass.class);
exporter.setSkipAnnotation(Transient.class);
exporter.setTargetFolder(new File("target/GenericExporterTest2"));
exporter.setStrictMode(true);
exporter.setPropertyHandling(PropertyHandling.JPA);
exporter.export(AbstractEntityTest.class.getPackage(), A.class.getPackage());
List<String> expected = new ArrayList<String>();
// GenericExporter doesn't include field/method selection
expected.add("QTemporalTest_MyEntity.java");
expected.add("QTemporal2Test_Cheque.java");
expected.add("QQueryProjectionTest_DTOWithProjection.java");
expected.add("QQueryProjectionTest_EntityWithProjection.java");
expected.add("QEmbeddable3Test_EmbeddableClass.java");
expected.add("QGeneric4Test_HidaBez.java");
expected.add("QGeneric4Test_HidaBezGruppe.java");
expected.add("QInterfaceType2Test_UserImpl.java");
expected.add("QOrderTest_Order.java");
expected.add("QManagedEmailTest_ManagedEmails.java");
expected.add("QGeneric12Test_ChannelRole.java");
expected.add("QManyToManyTest_Person.java");
expected.add("QOneToOneTest_Person.java");
expected.add("QGeneric16Test_HidaBez.java");
expected.add("QGeneric16Test_HidaBezGruppe.java");
execute(expected, "GenericExporterTest2", "HibernateAnnotationProcessor");
}
use of com.querydsl.codegen.GenericExporter in project querydsl by querydsl.
the class AbstractExporterMojo method execute.
@SuppressWarnings("unchecked")
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (testClasspath) {
project.addTestCompileSourceRoot(targetFolder.getAbsolutePath());
} else {
project.addCompileSourceRoot(targetFolder.getAbsolutePath());
}
if (skip || !hasSourceChanges()) {
// prevent m2e from entering an infinite build cycle.
return;
}
ClassLoader classLoader = null;
try {
classLoader = getProjectClassLoader();
} catch (MalformedURLException | DependencyResolutionRequiredException e) {
throw new MojoFailureException(e.getMessage(), e);
}
Charset charset = sourceEncoding != null ? Charset.forName(sourceEncoding) : Charset.defaultCharset();
GenericExporter exporter = new GenericExporter(classLoader, charset);
exporter.setTargetFolder(targetFolder);
if (scala) {
try {
exporter.setSerializerClass((Class<? extends Serializer>) Class.forName("com.querydsl.scala.ScalaEntitySerializer"));
exporter.setTypeMappingsClass((Class<? extends TypeMappings>) Class.forName("com.querydsl.scala.ScalaTypeMappings"));
exporter.setCreateScalaSources(true);
} catch (ClassNotFoundException e) {
throw new MojoFailureException(e.getMessage(), e);
}
}
configure(exporter);
exporter.export(packages);
}
Aggregations