Index: com/mysema/query/apt/Processor.java =================================================================== --- com/mysema/query/apt/Processor.java (revision 13922) +++ com/mysema/query/apt/Processor.java (working copy) @@ -551,9 +551,13 @@ Messager msg = env.getMessager(); for (EntityType model : models) { try { + Type type = configuration.getTypeMappings().getPathType(model, model, true); String packageName = type.getPackageName(); String className = !packageName.isEmpty() ? (packageName + "." + type.getSimpleName()) : type.getSimpleName(); + if (configuration.isExcludedPackage(packageName) || configuration.isExcludedClass(type.getFullName())) { + continue; + } Filer filer = env.getFiler(); FileObject generatedFile = filer.getResource(StandardLocation.SOURCE_OUTPUT, packageName, type.getSimpleName() + ".java"); Index: com/mysema/query/apt/Configuration.java =================================================================== --- com/mysema/query/apt/Configuration.java (revision 13922) +++ com/mysema/query/apt/Configuration.java (working copy) @@ -83,5 +83,9 @@ boolean isDefaultOverwrite(); QueryTypeFactory getQueryTypeFactory(); + + boolean isExcludedPackage(String packageName); + + boolean isExcludedClass(String className); } Index: com/mysema/query/apt/DefaultConfiguration.java =================================================================== --- com/mysema/query/apt/DefaultConfiguration.java (revision 13922) +++ com/mysema/query/apt/DefaultConfiguration.java (working copy) @@ -8,9 +8,12 @@ import java.lang.annotation.Annotation; import java.util.Collection; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; +import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.annotation.processing.RoundEnvironment; import javax.lang.model.element.Element; @@ -20,6 +23,8 @@ import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; +import org.apache.commons.lang.StringUtils; + import com.mysema.codegen.model.ClassType; import com.mysema.commons.lang.Assert; import com.mysema.query.annotations.Config; @@ -60,6 +65,12 @@ private static final String QUERYDSL_ENTITY_ACCESSORS = "querydsl.entityAccessors"; + private static final String QUERYDSL_EXCLUDED_PACKAGES = "querydsl.excludedPackages"; + + private static final String QUERYDSL_EXCLUDED_CLASSES = "querydsl.excludedClasses"; + + private static final String DEFAULT_SEPARATOR = ","; + private static final String DEFAULT_OVERWRITE = "defaultOverwrite"; private final CodegenModule module = new CodegenModule(); @@ -70,6 +81,12 @@ protected final Class entityAnn; + @Nonnull + private final Set excludedPackages; + + @Nonnull + private final Set excludedClasses; + @Nullable protected final Class entitiesAnn, superTypeAnn, embeddedAnn, embeddableAnn, skipAnn; @@ -87,6 +104,8 @@ @Nullable Class embeddableAnn, @Nullable Class embeddedAnn, @Nullable Class skipAnn) { + this.excludedClasses = new HashSet(); + this.excludedPackages = new HashSet(); module.bind(RoundEnvironment.class, roundEnv); module.bind(CodegenModule.KEYWORDS, keywords); this.entitiesAnn = entitiesAnn; @@ -134,6 +153,22 @@ if (options.containsKey(DEFAULT_OVERWRITE)){ defaultOverwrite = Boolean.valueOf(options.get(DEFAULT_OVERWRITE)); } + if (options.containsKey(QUERYDSL_EXCLUDED_PACKAGES)) { + final String packageString = options.get(QUERYDSL_EXCLUDED_PACKAGES); + if (StringUtils.isNotBlank(packageString)) { + for (String packageName : packageString.split(DEFAULT_SEPARATOR)) { + excludedPackages.add(packageName); + } + } + } + if (options.containsKey(QUERYDSL_EXCLUDED_CLASSES)) { + final String classString = options.get(QUERYDSL_EXCLUDED_CLASSES); + if (StringUtils.isNotBlank(classString)) { + for (String className : classString.split(DEFAULT_SEPARATOR)) { + excludedClasses.add(className); + } + } + } defaultSerializerConfig = new SimpleSerializerConfig(entityAccessors, listAccessors, mapAccessors, createDefaultVariable); @@ -312,7 +347,8 @@ return module.get(Collection.class, CodegenModule.KEYWORDS); } - public String getNameSuffix() { + @Override + public String getNameSuffix() { return module.get(String.class, CodegenModule.SUFFIX); } @@ -329,4 +365,19 @@ return module.get(QueryTypeFactory.class); } + @Override + public boolean isExcludedPackage(@Nonnull String packageName) { + for (String excludedPackage : excludedPackages) { + if (packageName.startsWith(excludedPackage)) { + return true; + } + } + return false; + } + + @Override + public boolean isExcludedClass(@Nonnull String className) { + return excludedClasses.contains(className); + } + }