-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix gradle 8.11 compatibility (#100);
fix report file disable; add AnimalSniffer task shortcut (to simplify report configuration) (cherry picked from commit b45a7fd)
- Loading branch information
Showing
12 changed files
with
671 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 16 additions & 10 deletions
26
src/main/groovy/ru/vyarus/gradle/plugin/animalsniffer/report/AnimalSnifferReportsImpl.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,37 @@ | ||
package ru.vyarus.gradle.plugin.animalsniffer.report | ||
|
||
import groovy.transform.CompileStatic | ||
import org.gradle.api.Action | ||
import org.gradle.api.Task | ||
import org.gradle.api.internal.CollectionCallbackActionDecorator | ||
import org.gradle.api.model.ObjectFactory | ||
import org.gradle.api.reporting.SingleFileReport | ||
import org.gradle.api.reporting.internal.TaskGeneratedSingleFileReport | ||
import org.gradle.api.reporting.internal.TaskReportContainer | ||
import ru.vyarus.gradle.plugin.animalsniffer.report.internal.Reports | ||
import ru.vyarus.gradle.plugin.animalsniffer.report.internal.DefaultSingleFileReport | ||
|
||
/** | ||
* AnimalSniffer reports implementation. | ||
* AnimalSniffer reports implementation. Compatible with gradle >= 7 | ||
* | ||
* @author Vyacheslav Rusakov | ||
* @since 14.12.2015 | ||
*/ | ||
@CompileStatic | ||
class AnimalSnifferReportsImpl extends TaskReportContainer<SingleFileReport> implements AnimalSnifferReports { | ||
class AnimalSnifferReportsImpl extends Reports<SingleFileReport> implements AnimalSnifferReports { | ||
|
||
private static final String TEXT = 'text' | ||
private static final String TYPE_TEXT = 'text' | ||
|
||
AnimalSnifferReportsImpl(Task task, CollectionCallbackActionDecorator callbackActionDecorator) { | ||
super(SingleFileReport, task, callbackActionDecorator) | ||
AnimalSnifferReportsImpl(Task task, ObjectFactory objects) { | ||
super(task.project, SingleFileReport) | ||
|
||
add(TaskGeneratedSingleFileReport, TEXT, task) | ||
addReport(objects.newInstance(DefaultSingleFileReport, TYPE_TEXT, task)) | ||
} | ||
|
||
@Override | ||
SingleFileReport getText() { | ||
return getByName(TEXT) | ||
return getByName(TYPE_TEXT) | ||
} | ||
|
||
@Override | ||
void text(Action<SingleFileReport> action) { | ||
action.execute(text) | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...ain/groovy/ru/vyarus/gradle/plugin/animalsniffer/report/LegacyAnimalsnifferReports.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package ru.vyarus.gradle.plugin.animalsniffer.report | ||
|
||
import groovy.transform.CompileStatic | ||
import org.gradle.api.Action | ||
import org.gradle.api.Task | ||
import org.gradle.api.internal.CollectionCallbackActionDecorator | ||
import org.gradle.api.reporting.SingleFileReport | ||
import org.gradle.api.reporting.internal.TaskGeneratedSingleFileReport | ||
import org.gradle.api.reporting.internal.TaskReportContainer | ||
|
||
/** | ||
* AnimalSniffer reports implementation. Compatible with gradle <= 8.10 | ||
* | ||
* @author Vyacheslav Rusakov | ||
* @since 14.12.2015 | ||
*/ | ||
@CompileStatic | ||
class LegacyAnimalsnifferReports extends TaskReportContainer<SingleFileReport> implements AnimalSnifferReports { | ||
|
||
private static final String TEXT = 'text' | ||
|
||
LegacyAnimalsnifferReports(Task task, CollectionCallbackActionDecorator callbackActionDecorator) { | ||
super(SingleFileReport, task, callbackActionDecorator) | ||
|
||
add(TaskGeneratedSingleFileReport, TEXT, task) | ||
} | ||
|
||
@Override | ||
SingleFileReport getText() { | ||
return getByName(TEXT) | ||
} | ||
|
||
@Override | ||
void text(Action<SingleFileReport> action) { | ||
action.execute(text) | ||
} | ||
} |
96 changes: 96 additions & 0 deletions
96
...oovy/ru/vyarus/gradle/plugin/animalsniffer/report/internal/DefaultSingleFileReport.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package ru.vyarus.gradle.plugin.animalsniffer.report.internal | ||
|
||
import groovy.transform.CompileStatic | ||
import org.gradle.api.Task | ||
import org.gradle.api.file.ProjectLayout | ||
import org.gradle.api.internal.IConventionAware | ||
import org.gradle.api.internal.provider.DefaultProvider | ||
import org.gradle.api.provider.Provider | ||
import org.gradle.api.reporting.Report | ||
import org.gradle.api.reporting.SingleFileReport | ||
import org.gradle.api.tasks.Internal | ||
import org.gradle.api.tasks.OutputFile | ||
|
||
import javax.inject.Inject | ||
|
||
/** | ||
* {@link SingleFileReport} implementation (gradle implementation is in internal package and could change any time). | ||
* Supports both old and new apis (pre gradle 7 and above it). | ||
* | ||
* @author Vyacheslav Rusakov | ||
* @since 17.11.2024 | ||
*/ | ||
@SuppressWarnings('AbstractClassWithoutAbstractMethod') | ||
@CompileStatic | ||
abstract class DefaultSingleFileReport implements SingleFileReport { | ||
|
||
private final String name | ||
private final Task task | ||
|
||
@SuppressWarnings('AbstractClassWithPublicConstructor') | ||
@Inject | ||
DefaultSingleFileReport(String name, Task task) { | ||
this.name = name | ||
this.task = task | ||
required.convention(false) | ||
outputLocation.convention(projectLayout.file(new DefaultProvider<File>({ | ||
return ((IConventionAware) this).conventionMapping.getConventionValue(null, 'destination', false) | ||
}))) | ||
} | ||
|
||
@Override | ||
Report configure(Closure cl) { | ||
final Closure closure = (Closure) cl.clone() | ||
closure.resolveStrategy = Closure.DELEGATE_FIRST | ||
closure.delegate = this | ||
closure.call(this) | ||
return this | ||
} | ||
|
||
@OutputFile | ||
File getDestination() { | ||
return outputLocation.asFile.orNull | ||
} | ||
|
||
@Internal | ||
boolean isEnabled() { | ||
return required.get() | ||
} | ||
|
||
@Override | ||
String getDisplayName() { | ||
return "Report generated by task '$task.path' ($name)" | ||
} | ||
|
||
@Override | ||
String getName() { | ||
return name | ||
} | ||
|
||
void setDestination(Provider<File> provider) { | ||
outputLocation.fileProvider(provider) | ||
} | ||
|
||
@Override | ||
void setDestination(File file) { | ||
outputLocation.fileValue(file) | ||
} | ||
|
||
void setEnabled(Provider<Boolean> enabled) { | ||
required.set(enabled) | ||
} | ||
|
||
void setEnabled(boolean enabled) { | ||
required.set(enabled) | ||
} | ||
|
||
@Override | ||
OutputType getOutputType() { | ||
return OutputType.FILE | ||
} | ||
|
||
@Inject | ||
protected ProjectLayout getProjectLayout() { | ||
throw new UnsupportedOperationException() | ||
} | ||
} |
Oops, something went wrong.