report-tasks

This commit is contained in:
Steve Ebersole 2022-03-09 12:28:13 -06:00
parent 256dc64e87
commit e16fbb6c31
14 changed files with 428 additions and 229 deletions

View File

@ -14,14 +14,29 @@ plugins {
apply from: rootProject.file( 'gradle/java-module.gradle' )
apply plugin: 'org.hibernate.matrix-test'
apply plugin: 'org.hibernate.orm.build.reports'
tasks.build.dependsOn 'buildDocs'
defaultTasks 'buildDocs'
dependencies {
ext.pressgangVersion = '3.0.0'
reportAggregation project( ':hibernate-agroal' )
reportAggregation project( ':hibernate-c3p0' )
reportAggregation project( ':hibernate-core' )
reportAggregation project(':hibernate-envers')
reportAggregation project(':hibernate-graalvm')
reportAggregation project(':hibernate-hikaricp')
reportAggregation project(':hibernate-jcache')
reportAggregation project(':hibernate-micrometer')
reportAggregation project(':hibernate-proxool')
reportAggregation project(':hibernate-spatial')
reportAggregation project(':hibernate-vibur')
reportAggregation project(':hibernate-ant')
reportAggregation project(':hibernate-enhance-maven-plugin')
reportAggregation project(':hibernate-jpamodelgen')
implementation project( ':hibernate-core' )
annotationProcessor project( ':hibernate-jpamodelgen' )

View File

@ -8,7 +8,6 @@
apply plugin: 'signing'
apply from: rootProject.file( 'gradle/java-module.gradle' )
apply from: rootProject.file( 'gradle/publishing-pom.gradle' )
apply plugin: 'org.hibernate.orm.build.post-collector'
configurations {
javadocSources {

View File

@ -14,7 +14,7 @@ import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PACKAGE;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.CLASS;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* Annotation used to identify a package, class, interface or method
@ -24,7 +24,7 @@ import static java.lang.annotation.RetentionPolicy.CLASS;
* @author Steve Ebersole
*/
@Target({PACKAGE, TYPE, METHOD, FIELD, CONSTRUCTOR})
@Retention(CLASS)
@Retention(RUNTIME)
public @interface Internal {
}

View File

@ -43,9 +43,9 @@ gradlePlugin {
id = 'org.hibernate.orm.jakarta-publish'
implementationClass = 'org.hibernate.orm.jakarta.JakartaPublishingPlugin'
}
collectorPlugin {
id = 'org.hibernate.orm.build.post-collector'
implementationClass = 'org.hibernate.orm.post.CollectorPlugin'
reportsPlugin {
id = 'org.hibernate.orm.build.reports'
implementationClass = 'org.hibernate.orm.post.ReportGenerationPlugin'
}
}
}

View File

@ -11,19 +11,16 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Comparator;
import java.util.List;
import java.util.TreeSet;
import javax.inject.Inject;
import org.gradle.api.DefaultTask;
import org.gradle.api.Project;
import org.gradle.api.file.RegularFile;
import org.gradle.api.provider.Provider;
import org.gradle.api.tasks.InputFile;
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.OutputFile;
import org.gradle.api.tasks.TaskAction;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationTarget;
@ -32,19 +29,25 @@ import org.jboss.jandex.FieldInfo;
import org.jboss.jandex.Index;
import org.jboss.jandex.MethodInfo;
import static org.hibernate.orm.post.ReportGenerationPlugin.TASK_GROUP_NAME;
/**
* @author Steve Ebersole
*/
public abstract class IncubatingCollectorTask extends DefaultTask {
public static final String INCUBATING_ANN_NAME = "org.hibernate.Incubating";
public class AbstractJandexAwareTask extends DefaultTask {
private final IndexManager indexManager;
private final Provider<RegularFile> reportFileReferenceAccess;
@Inject
public IncubatingCollectorTask(IndexManager indexManager, Project project) {
public AbstractJandexAwareTask(IndexManager indexManager, Provider<RegularFile> reportFileReferenceAccess) {
this.indexManager = indexManager;
this.reportFileReferenceAccess = project.getLayout().getBuildDirectory().file( "reports/orm/" + project.getName() + "-incubating.txt" );
this.reportFileReferenceAccess = reportFileReferenceAccess;
setGroup( TASK_GROUP_NAME );
}
@Internal
protected IndexManager getIndexManager() {
return indexManager;
}
@InputFile
@ -57,138 +60,108 @@ public abstract class IncubatingCollectorTask extends DefaultTask {
return reportFileReferenceAccess;
}
@TaskAction
public void collectIncubationDetails() {
final Index index = indexManager.getIndex();
final List<AnnotationInstance> usages = index.getAnnotations( DotName.createSimple( INCUBATING_ANN_NAME ) );
final TreeSet<Incubation> incubations = new TreeSet<>( Comparator.comparing( Incubation::getPath ) );
usages.forEach( (usage) -> {
final AnnotationTarget usageLocation = usage.target();
final Incubation incubation = determinePath( usageLocation );
if ( incubation != null ) {
incubations.add( incubation );
}
} );
// NOTE : at this point, `usagePathSet` contains a set of incubating
// names ordered alphabetically..
reportIncubations( incubations );
}
private void reportIncubations(TreeSet<Incubation> incubations) {
final File reportFile = prepareReportFile();
assert reportFile.exists();
try ( final OutputStreamWriter fileWriter = new OutputStreamWriter( new FileOutputStream( reportFile ) ) ) {
generateReport( incubations, fileWriter );
}
catch (FileNotFoundException e) {
throw new RuntimeException( "Should never happen" );
}
catch (IOException e) {
throw new RuntimeException( "Error writing to `@Incubating` report file", e );
}
}
private File prepareReportFile() {
final File reportFile = reportFileReferenceAccess.get().getAsFile();
protected File prepareReportFile() {
final File reportFile = getReportFileReferenceAccess().get().getAsFile();
if ( reportFile.getParentFile().exists() ) {
if ( reportFile.exists() ) {
if ( !reportFile.delete() ) {
throw new RuntimeException( "Unable to delete `@Incubating` report file" );
throw new RuntimeException( "Unable to delete report file - " + reportFile.getAbsolutePath() );
}
}
}
else {
if ( !reportFile.getParentFile().mkdirs() ) {
throw new RuntimeException( "Unable to create directories for `@Incubating` report file" );
throw new RuntimeException( "Unable to create report file directories - " + reportFile.getAbsolutePath() );
}
}
try {
if ( !reportFile.createNewFile() ) {
throw new RuntimeException( "Unable to create file for `@Incubating` report file" );
throw new RuntimeException( "Unable to create report file - " + reportFile.getAbsolutePath() );
}
}
catch (IOException e) {
throw new RuntimeException( "Unable to create file for `@Incubating` report file" );
throw new RuntimeException( "Unable to create report file - " + reportFile.getAbsolutePath() );
}
return reportFile;
}
private void generateReport(TreeSet<Incubation> incubations, OutputStreamWriter fileWriter) {
protected void processAnnotations(DotName annotationName, TreeSet<Inclusion> inclusions) {
final Index index = getIndexManager().getIndex();
final List<AnnotationInstance> usages = index.getAnnotations( annotationName );
usages.forEach( (usage) -> {
final AnnotationTarget usageLocation = usage.target();
final Inclusion inclusion = determinePath( usageLocation );
if ( inclusion != null ) {
inclusions.add( inclusion );
}
} );
}
protected void writeReport(TreeSet<Inclusion> inclusions) {
final File reportFile = prepareReportFile();
assert reportFile.exists();
try ( final OutputStreamWriter fileWriter = new OutputStreamWriter( new FileOutputStream( reportFile ) ) ) {
writeReport( inclusions, fileWriter );
}
catch (FileNotFoundException e) {
throw new RuntimeException( "Should never happen" );
}
catch (IOException e) {
throw new RuntimeException( "Error writing to report file", e );
}
}
private void writeReport(TreeSet<Inclusion> inclusions, OutputStreamWriter fileWriter) {
String previousPath = null;
for ( Incubation incubation : incubations ) {
if ( previousPath != null && incubation.path.startsWith( previousPath ) ) {
for ( Inclusion inclusion : inclusions ) {
if ( previousPath != null && inclusion.getPath().startsWith( previousPath ) ) {
continue;
}
// `usagePath` is a path we want to document
// `inclusion` is a path we want to document
try {
fileWriter.write( incubation.path );
if ( incubation.isPackage ) {
fileWriter.write( inclusion.getPath() );
if ( inclusion.isPackage() ) {
fileWriter.write( ".*" );
}
fileWriter.write( '\n' );
fileWriter.flush();
}
catch (IOException e) {
throw new RuntimeException( "Error writing entry (" + incubation.path + ") to `@Incubating` report file", e );
throw new RuntimeException( "Error writing entry (" + inclusion.getPath() + ") to report file", e );
}
previousPath = incubation.path;
previousPath = inclusion.getPath();
}
}
private static class Incubation {
private final String path;
private final boolean isPackage;
public Incubation(String path, boolean isPackage) {
this.path = path;
this.isPackage = isPackage;
}
public Incubation(String path) {
this( path, false );
}
public String getPath() {
return path;
}
public boolean isPackage() {
return isPackage;
}
}
private Incubation determinePath(AnnotationTarget usageLocation) {
private Inclusion determinePath(AnnotationTarget usageLocation) {
switch ( usageLocation.kind() ) {
case CLASS: {
final DotName name = usageLocation.asClass().name();
if ( name.local().equals( "package-info" ) ) {
return new Incubation( name.packagePrefix(), true );
return new Inclusion( name.packagePrefix(), true );
}
return new Incubation( name.toString() );
return new Inclusion( name.toString() );
}
case FIELD: {
final FieldInfo fieldInfo = usageLocation.asField();
final String path = fieldInfo.declaringClass().name().toString()
+ "#"
+ fieldInfo.name();
return new Incubation( path );
return new Inclusion( path );
}
case METHOD: {
final MethodInfo methodInfo = usageLocation.asMethod();
final String path = methodInfo.declaringClass().name().toString()
+ "#"
+ methodInfo.name();
return new Incubation( path );
return new Inclusion( path );
}
default: {
return null;

View File

@ -1,55 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.orm.post;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.file.Directory;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.provider.Provider;
import org.gradle.api.tasks.SourceSet;
import static org.gradle.api.tasks.SourceSet.MAIN_SOURCE_SET_NAME;
/**
* @author Steve Ebersole
*/
public class CollectorPlugin implements Plugin<Project> {
@Override
public void apply(Project project) {
final JavaPluginExtension javaPluginExtension = project.getExtensions().getByType( JavaPluginExtension.class );
final SourceSet projectMainSourceSet = javaPluginExtension.getSourceSets().getByName( MAIN_SOURCE_SET_NAME );
final Provider<Directory> classesDirectory = projectMainSourceSet.getJava().getClassesDirectory();
final IndexManager indexManager = new IndexManager( classesDirectory, project );
final IndexerTask indexerTask = project.getTasks().create(
"indexProject",
IndexerTask.class,
indexManager
);
// NOTE : `indexProject` implicitly depends on the compilation task.
// it uses the `classesDirectory` from the `main` sourceSet. Gradle
// understands that the `classesDirectory` is generated from the
// compilation task and implicitly creates the task dependency
final IncubatingCollectorTask incubatingTask = project.getTasks().create(
"createIncubatingReport",
IncubatingCollectorTask.class,
indexManager
);
incubatingTask.dependsOn( indexerTask );
final LoggingCollectorTask loggingTask = project.getTasks().create(
"createLoggingReport",
LoggingCollectorTask.class,
indexManager
);
loggingTask.dependsOn( indexerTask );
}
}

View File

@ -0,0 +1,33 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.orm.post;
/**
* @author Steve Ebersole
*/
class Inclusion {
private final String path;
private final boolean isPackage;
public Inclusion(String path, boolean isPackage) {
this.path = path;
this.isPackage = isPackage;
}
public Inclusion(String path) {
this( path, false );
}
public String getPath() {
return path;
}
public boolean isPackage() {
return isPackage;
}
}

View File

@ -0,0 +1,45 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.orm.post;
import java.util.Comparator;
import java.util.TreeSet;
import javax.inject.Inject;
import org.gradle.api.Project;
import org.gradle.api.tasks.TaskAction;
import org.jboss.jandex.DotName;
/**
* @author Steve Ebersole
*/
public abstract class IncubationReportTask extends AbstractJandexAwareTask {
public static final String INCUBATING_ANN_NAME = "org.hibernate.Incubating";
@Inject
public IncubationReportTask(IndexManager indexManager, Project project) {
super(
indexManager,
project.getLayout().getBuildDirectory().file( "reports/orm/incubating.txt" )
);
setDescription( "Generates a report for things considered incubating" );
}
@TaskAction
public void generateIncubationReport() {
final TreeSet<Inclusion> incubations = new TreeSet<>( Comparator.comparing( Inclusion::getPath ) );
processAnnotations( DotName.createSimple( INCUBATING_ANN_NAME ), incubations );
// NOTE : at this point, `incubations` contains a set of incubating
// names ordered alphabetically..
writeReport( incubations );
}
}

View File

@ -10,12 +10,19 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Comparator;
import java.util.Set;
import java.util.TreeSet;
import org.gradle.api.Project;
import org.gradle.api.file.Directory;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.file.FileTree;
import org.gradle.api.file.FileVisitDetails;
import org.gradle.api.file.FileVisitor;
import org.gradle.api.file.RegularFile;
import org.gradle.api.file.RelativePath;
import org.gradle.api.provider.Provider;
import org.jboss.jandex.ClassInfo;
@ -29,30 +36,41 @@ import org.jboss.jandex.Indexer;
* @author Steve Ebersole
*/
public class IndexManager {
private final Provider<Directory> classesDirectoryReferenceAccess;
private final Configuration artifactsToProcess;
private final Provider<RegularFile> indexFileReferenceAccess;
private final Provider<RegularFile> packageFileReferenceAccess;
private final Project project;
private Index index;
private TreeSet<Inclusion> internalPackageNames;
public IndexManager(
Provider<Directory> classesDirectoryReferenceAccess,
Project project) {
this.classesDirectoryReferenceAccess = classesDirectoryReferenceAccess;
public IndexManager(Configuration artifactsToProcess, Project project) {
this.artifactsToProcess = artifactsToProcess;
this.indexFileReferenceAccess = project.getLayout()
.getBuildDirectory()
.file( "reports/orm/" + project.getName() + ".idx" );
.file( "reports/orm/indexing/jandex.idx" );
this.packageFileReferenceAccess = project.getLayout()
.getBuildDirectory()
.file( "reports/orm/indexing/internal-packages.txt" );
this.project = project;
}
public Provider<Directory> getClassesDirectoryReferenceAccess() {
return classesDirectoryReferenceAccess;
public Configuration getArtifactsToProcess() {
return artifactsToProcess;
}
public Provider<RegularFile> getIndexFileReferenceAccess() {
return indexFileReferenceAccess;
}
public Provider<RegularFile> getPackageFileReferenceAccess() {
return packageFileReferenceAccess;
}
public TreeSet<Inclusion> getInternalPackageNames() {
return internalPackageNames;
}
public Index getIndex() {
if ( index == null ) {
throw new IllegalStateException( "Index has not been created yet" );
@ -60,55 +78,81 @@ public class IndexManager {
return index;
}
/**
* Used from {@link IndexerTask} as its action
*/
void index() {
if ( index != null ) {
assert internalPackageNames != null;
return;
}
final Indexer indexer = new Indexer();
internalPackageNames = new TreeSet<>( Comparator.comparing( Inclusion::getPath ) );
final Directory classesDirectory = classesDirectoryReferenceAccess.get();
final Set<File> classFiles = classesDirectory.getAsFileTree().getFiles();
for ( File classFile : classFiles ) {
if ( !classFile.getName().endsWith( ".class" ) ) {
continue;
// note: each of `artifacts` is a jar-file
final Set<File> artifacts = artifactsToProcess.resolve();
artifacts.forEach( (jar) -> {
final FileTree jarFileTree = project.zipTree( jar );
jarFileTree.visit(
new FileVisitor() {
private boolean isInOrmPackage(RelativePath relativePath) {
return relativePath.getPathString().startsWith( "org/hibernate/" );
}
if ( !classFile.getAbsolutePath().contains( "org/hibernate" ) ) {
continue;
@Override
public void visitDir(FileVisitDetails details) {
final RelativePath relativePath = details.getRelativePath();
if ( !isInOrmPackage( relativePath ) ) {
return;
}
try ( final FileInputStream stream = new FileInputStream( classFile ) ) {
if ( relativePath.getPathString().endsWith( "internal" )
|| relativePath.getPathString().endsWith( "internal/" ) ) {
final String packageName = relativePath.toString().replace( '/', '.' );
internalPackageNames.add( new Inclusion( packageName, true ) );
}
}
@Override
public void visitFile(FileVisitDetails details) {
final RelativePath relativePath = details.getRelativePath();
if ( !isInOrmPackage( relativePath ) ) {
return;
}
if ( relativePath.getPathString().endsWith( ".class" ) ) {
try ( final FileInputStream stream = new FileInputStream( details.getFile() ) ) {
final ClassInfo indexedClassInfo = indexer.index( stream );
if ( indexedClassInfo == null ) {
project.getLogger().lifecycle( "Problem indexing class file - " + classFile.getAbsolutePath() );
project.getLogger()
.lifecycle( "Problem indexing class file - " + details.getFile()
.getAbsolutePath() );
}
}
catch (FileNotFoundException e) {
throw new RuntimeException( "Problem locating project class file - " + classFile.getAbsolutePath(), e );
throw new RuntimeException( "Problem locating project class file - " + details.getFile()
.getAbsolutePath(), e );
}
catch (IOException e) {
throw new RuntimeException( "Error accessing project class file - " + classFile.getAbsolutePath(), e );
throw new RuntimeException( "Error accessing project class file - " + details.getFile()
.getAbsolutePath(), e );
}
}
}
}
);
} );
this.index = indexer.complete();
storeIndex( index );
storeIndex();
storePackageNames();
}
private void storeIndex(Index index) {
final File indexFile = indexFileReferenceAccess.get().getAsFile();
if ( indexFile.exists() ) {
indexFile.delete();
}
try {
indexFile.getParentFile().mkdirs();
indexFile.createNewFile();
}
catch (IOException e) {
throw new RuntimeException( "Unable to create index file - " + indexFile.getAbsolutePath(), e );
}
private void storeIndex() {
final File indexFile = prepareOutputFile( indexFileReferenceAccess );
try ( final FileOutputStream stream = new FileOutputStream( indexFile ) ) {
final IndexWriter indexWriter = new IndexWriter( stream );
@ -121,4 +165,43 @@ public class IndexManager {
throw new RuntimeException( "Error accessing index file - " + indexFile.getAbsolutePath(), e );
}
}
private void storePackageNames() {
final File packageNameFile = prepareOutputFile( packageFileReferenceAccess );
try ( final FileWriter fileWriter = new FileWriter( packageNameFile ) ) {
internalPackageNames.forEach( (inclusion) -> {
try {
fileWriter.write( inclusion.getPath() );
fileWriter.write( '\n' );
}
catch (IOException e) {
throw new RuntimeException( "Unable to write to package-name file - " + packageNameFile.getAbsolutePath(), e );
}
} );
}
catch (FileNotFoundException e) {
throw new RuntimeException( "Should never happen", e );
}
catch (IOException e) {
throw new RuntimeException( "Error accessing package-name file - " + packageNameFile.getAbsolutePath(), e );
}
}
private File prepareOutputFile(Provider<RegularFile> outputFileReferenceAccess) {
final File outputFile = outputFileReferenceAccess.get().getAsFile();
if ( outputFile.exists() ) {
outputFile.delete();
}
try {
outputFile.getParentFile().mkdirs();
outputFile.createNewFile();
}
catch (IOException e) {
throw new RuntimeException( "Unable to create index file - " + outputFile.getAbsolutePath(), e );
}
return outputFile;
}
}

View File

@ -9,14 +9,17 @@ package org.hibernate.orm.post;
import javax.inject.Inject;
import org.gradle.api.DefaultTask;
import org.gradle.api.file.Directory;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.file.RegularFile;
import org.gradle.api.provider.Provider;
import org.gradle.api.tasks.InputDirectory;
import org.gradle.api.tasks.InputFiles;
import org.gradle.api.tasks.OutputFile;
import org.gradle.api.tasks.SkipWhenEmpty;
import org.gradle.api.tasks.TaskAction;
import static org.hibernate.orm.post.ReportGenerationPlugin.CONFIG_NAME;
import static org.hibernate.orm.post.ReportGenerationPlugin.TASK_GROUP_NAME;
/**
* Task for creating Jandex Index within Gradle UP-TO-DATE handling
*
@ -28,12 +31,14 @@ public abstract class IndexerTask extends DefaultTask {
@Inject
public IndexerTask(IndexManager indexManager) {
this.indexManager = indexManager;
setGroup( TASK_GROUP_NAME );
setDescription( "Builds a Jandex Index from the artifacts attached to the `" + CONFIG_NAME + "` Configuration" );
}
@InputDirectory
@InputFiles
@SkipWhenEmpty
public Provider<Directory> getClassesDirectory() {
return indexManager.getClassesDirectoryReferenceAccess();
public Configuration getArtifactsToProcess() {
return indexManager.getArtifactsToProcess();
}
@OutputFile
@ -41,6 +46,11 @@ public abstract class IndexerTask extends DefaultTask {
return indexManager.getIndexFileReferenceAccess();
}
@OutputFile
public Provider<RegularFile> getPackageFileReferenceAccess() {
return indexManager.getPackageFileReferenceAccess();
}
@TaskAction
public void createIndex() {
indexManager.index();

View File

@ -0,0 +1,43 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.orm.post;
import java.io.File;
import java.nio.file.Path;
import java.util.Comparator;
import java.util.TreeSet;
import javax.inject.Inject;
import org.gradle.api.Project;
import org.gradle.api.tasks.TaskAction;
import org.jboss.jandex.DotName;
/**
* @author Steve Ebersole
*/
public abstract class InternalsReportTask extends AbstractJandexAwareTask {
public static final String INTERNAL_ANN_NAME = "org.hibernate.Internal";
@Inject
public InternalsReportTask(IndexManager indexManager, Project project) {
super(
indexManager,
project.getLayout().getBuildDirectory().file( "reports/orm/internal.txt" )
);
}
@TaskAction
public void generateInternalsReport() {
final TreeSet<Inclusion> internals = new TreeSet<>( Comparator.comparing( Inclusion::getPath ) );
internals.addAll( getIndexManager().getInternalPackageNames() );
processAnnotations( DotName.createSimple( INTERNAL_ANN_NAME ), internals );
writeReport( internals );
}
}

View File

@ -1,31 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.orm.post;
import javax.inject.Inject;
import org.gradle.api.DefaultTask;
import org.gradle.api.tasks.TaskAction;
import org.jboss.jandex.Index;
/**
* @author Steve Ebersole
*/
public abstract class LoggingCollectorTask extends DefaultTask {
private final IndexManager indexManager;
@Inject
public LoggingCollectorTask(IndexManager indexManager) {
this.indexManager = indexManager;
}
@TaskAction
public void collectLoggingDetails() {
getProject().getLogger().lifecycle( "Logging collection not implemented yet" );
}
}

View File

@ -0,0 +1,30 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.orm.post;
import javax.inject.Inject;
import org.gradle.api.Project;
import org.gradle.api.tasks.TaskAction;
/**
* @author Steve Ebersole
*/
public abstract class LoggingReportTask extends AbstractJandexAwareTask {
@Inject
public LoggingReportTask(IndexManager indexManager, Project project) {
super(
indexManager,
project.getLayout().getBuildDirectory().file( "reports/orm/logging.txt" )
);
}
@TaskAction
public void generateLoggingReport() {
getProject().getLogger().lifecycle( "Logging report not implemented yet" );
}
}

View File

@ -0,0 +1,54 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.orm.post;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
/**
* @author Steve Ebersole
*/
public class ReportGenerationPlugin implements Plugin<Project> {
public static final String CONFIG_NAME = "reportAggregation";
public static final String TASK_GROUP_NAME = "hibernate-reports";
@Override
public void apply(Project project) {
final Configuration artifactsToProcess = project.getConfigurations()
.maybeCreate( CONFIG_NAME )
.setDescription( "Used to collect the jars with classes files to be used in the aggregation reports for `@Internal`, `@Incubating`, etc" );
final IndexManager indexManager = new IndexManager( artifactsToProcess, project );
final IndexerTask indexerTask = project.getTasks().create(
"buildAggregatedIndex",
IndexerTask.class,
indexManager
);
final IncubationReportTask incubatingTask = project.getTasks().create(
"createIncubationReport",
IncubationReportTask.class,
indexManager
);
incubatingTask.dependsOn( indexerTask );
final InternalsReportTask internalsTask = project.getTasks().create(
"createInternalsReport",
InternalsReportTask.class,
indexManager
);
internalsTask.dependsOn( indexerTask );
final LoggingReportTask loggingTask = project.getTasks().create(
"createLoggingReport",
LoggingReportTask.class,
indexManager
);
loggingTask.dependsOn( indexerTask );
}
}