2222import org .gradle .api .file .RegularFile ;
2323import org .gradle .api .provider .Property ;
2424import org .gradle .api .provider .Provider ;
25+ import org .gradle .api .tasks .Input ;
2526import org .gradle .api .tasks .OutputFile ;
2627import org .gradle .api .tasks .SourceSet ;
2728import org .gradle .api .tasks .SourceSetContainer ;
3637 * @author Steve Ebersole
3738 */
3839public abstract class DialectReportTask extends AbstractJandexAwareTask {
40+ private final Property <String > sourceProject ;
41+ private final Property <String > sourcePackage ;
3942 private final Property <RegularFile > reportFile ;
4043
4144 public DialectReportTask () {
42- setDescription ( "Generates a report of the supported Dialects" );
45+ setDescription ( "Generates a report of Dialects" );
46+ sourceProject = getProject ().getObjects ().property (String .class );
47+ sourcePackage = getProject ().getObjects ().property (String .class );
4348 reportFile = getProject ().getObjects ().fileProperty ();
4449 }
4550
51+ @ Input
52+ public Property <String > getSourceProject () {
53+ return sourceProject ;
54+ }
55+
56+ @ Input
57+ public Property <String > getSourcePackage () {
58+ return sourcePackage ;
59+ }
60+
4661 @ OutputFile
4762 public Property <RegularFile > getReportFile () {
4863 return reportFile ;
@@ -55,16 +70,19 @@ protected Provider<RegularFile> getTaskReportFileReference() {
5570
5671 @ TaskAction
5772 public void generateDialectReport () {
58- // the ones we want are all in the hibernate-core project
59- final Project coreProject = getProject ().getRootProject ().project ( "hibernate-core" );
60- final SourceSetContainer sourceSets = coreProject .getExtensions ().getByType ( SourceSetContainer .class );
73+ // TODO this probably messes up the cache since we don't declare an explicit dependency to a source set
74+ // but the problem is pre-existing and I don't have time to investigate.
75+ Project sourceProject = getProject ().getRootProject ().project ( this .sourceProject .get () );
76+ final SourceSetContainer sourceSets = sourceProject .getExtensions ().getByType ( SourceSetContainer .class );
6177 final SourceSet sourceSet = sourceSets .getByName ( SourceSet .MAIN_SOURCE_SET_NAME );
62- final ClassLoader classLoader = Helper .asClassLoader ( sourceSet , coreProject .getConfigurations ().getByName ( "testRuntimeClasspath" ) );
78+ final ClassLoader classLoader = Helper .asClassLoader ( sourceSet , sourceProject .getConfigurations ().getByName ( "testRuntimeClasspath" ) );
6379
6480 final DialectClassDelegate dialectClassDelegate = new DialectClassDelegate ( classLoader );
6581
6682 final Index index = getIndexManager ().getIndex ();
6783 final Collection <ClassInfo > allDialectClasses = index .getAllKnownSubclasses ( DialectClassDelegate .DIALECT_CLASS_NAME );
84+ String sourcePackagePrefix = this .sourcePackage .get () + "." ;
85+ allDialectClasses .removeIf ( c -> !c .name ().toString ().startsWith ( sourcePackagePrefix ) );
6886 if ( allDialectClasses .isEmpty () ) {
6987 throw new RuntimeException ( "Unable to find Dialects" );
7088 }
0 commit comments