Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,16 @@
* Task to generate a local Antora playbook.
*
* @author Phillip Webb
* @author Yanming Zhou
*/
public abstract class GenerateAntoraPlaybook extends DefaultTask {

private static final String ANTORA_SOURCE_DIR = "src/docs/antora";

private static final String GENERATED_DOCS = "build/generated/docs/";

private final Project project;

@OutputFile
public abstract RegularFileProperty getOutputFile();

Expand All @@ -76,9 +79,10 @@ public abstract class GenerateAntoraPlaybook extends DefaultTask {
public abstract Property<Boolean> getExcludeJavadocExtension();

public GenerateAntoraPlaybook() {
this.project = getProject();
setGroup("Documentation");
setDescription("Generates an Antora playbook.yml file for local use");
getOutputFile().convention(getProject().getLayout()
getOutputFile().convention(this.project.getLayout()
.getBuildDirectory()
.file("generated/docs/antora-playbook/antora-playbook.yml"));
getContentSourceConfiguration().convention("antoraContent");
Expand Down Expand Up @@ -127,7 +131,7 @@ private void addExtensions(Map<String, Object> data) {
extensions.xref((xref) -> xref.stub(getXrefStubs().getOrElse(Collections.emptyList())));
extensions.zipContentsCollector((zipContentsCollector) -> {
zipContentsCollector.versionFile("gradle.properties");
String locationName = getProject().getName() + "-${version}-${name}-${classifier}.zip";
String locationName = this.project.getName() + "-${version}-${name}-${classifier}.zip";
Path antoraContent = getRelativeProjectPath()
.resolve(GENERATED_DOCS + "antora-content/" + locationName);
Path antoraDependencies = getRelativeProjectPath()
Expand All @@ -149,12 +153,12 @@ private void addSources(Map<String, Object> data) {
private Map<String, Object> createContentSource() {
Map<String, Object> source = new LinkedHashMap<>();
Path playbookPath = getOutputFile().get().getAsFile().toPath().getParent();
Path antoraSrc = getProjectPath(getProject()).resolve(ANTORA_SOURCE_DIR);
Path antoraSrc = getProjectPath(this.project).resolve(ANTORA_SOURCE_DIR);
StringBuilder url = new StringBuilder(".");
relativizeFromRootProject(playbookPath).normalize().forEach((path) -> url.append(File.separator).append(".."));
source.put("url", url.toString());
source.put("branches", "HEAD");
source.put("version", getProject().getVersion().toString());
source.put("version", this.project.getVersion().toString());
Set<String> startPaths = new LinkedHashSet<>();
addAntoraContentStartPaths(startPaths);
startPaths.add(relativizeFromRootProject(antoraSrc).toString());
Expand All @@ -163,7 +167,7 @@ private Map<String, Object> createContentSource() {
}

private void addAntoraContentStartPaths(Set<String> startPaths) {
Configuration configuration = getProject().getConfigurations().findByName("antoraContent");
Configuration configuration = this.project.getConfigurations().findByName("antoraContent");
if (configuration != null) {
for (ProjectDependency dependency : configuration.getAllDependencies().withType(ProjectDependency.class)) {
Path path = dependency.getDependencyProject().getProjectDir().toPath();
Expand All @@ -175,7 +179,7 @@ private void addAntoraContentStartPaths(Set<String> startPaths) {
private void addDir(Map<String, Object> data) {
Path playbookDir = toRealPath(getOutputFile().get().getAsFile().toPath()).getParent();
Path outputDir = toRealPath(
getProject().getLayout().getBuildDirectory().dir("site").get().getAsFile().toPath());
this.project.getLayout().getBuildDirectory().dir("site").get().getAsFile().toPath());
data.put("output", Map.of("dir", "." + File.separator + playbookDir.relativize(outputDir)));
}

Expand All @@ -202,11 +206,11 @@ private Yaml createYaml() {
}

private Path getRelativeProjectPath() {
return relativizeFromRootProject(getProjectPath(getProject()));
return relativizeFromRootProject(getProjectPath(this.project));
}

private Path relativizeFromRootProject(Path subPath) {
Path rootProjectPath = getProjectPath(getProject().getRootProject());
Path rootProjectPath = getProjectPath(this.project.getRootProject());
return rootProjectPath.relativize(subPath).normalize();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,24 @@
* A {@link Task} for creating a Homebrew formula manifest.
*
* @author Andy Wilkinson
* @author Yanming Zhou
*/
public abstract class HomebrewFormula extends DefaultTask {

private static final Logger logger = LoggerFactory.getLogger(HomebrewFormula.class);

private final Project project;

private final FileSystemOperations fileSystemOperations;

@Inject
public HomebrewFormula(FileSystemOperations fileSystemOperations) {
this.project = getProject();
this.fileSystemOperations = fileSystemOperations;
Project project = getProject();
MapProperty<String, Object> properties = getProperties();
properties.put("hash", getArchive().map((archive) -> sha256(archive.getAsFile())));
getProperties().put("repo", ArtifactRelease.forProject(project).getDownloadRepo());
getProperties().put("version", project.getVersion().toString());
getProperties().put("repo", ArtifactRelease.forProject(this.project).getDownloadRepo());
getProperties().put("version", this.project.getVersion().toString());
}

private String sha256(File file) {
Expand Down Expand Up @@ -90,7 +93,7 @@ private String sha256(File file) {

@TaskAction
void createFormula() {
BuildType buildType = BuildProperties.get(getProject()).buildType();
BuildType buildType = BuildProperties.get(this.project).buildType();
if (buildType != BuildType.OPEN_SOURCE) {
logger.debug("Skipping Homebrew formula for non open source build type");
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
*
* @author Andy Wilkinson
* @author Phillip Webb
* @author Yanming Zhou
*/
public class MavenPluginPlugin implements Plugin<Project> {

Expand Down Expand Up @@ -334,8 +335,14 @@ private void addExtractVersionPropertiesTask(Project project) {

public abstract static class FormatHelpMojoSource extends DefaultTask {

private final Project project;

private Task generator;

public FormatHelpMojoSource() {
this.project = getProject();
}

void setGenerator(Task generator) {
this.generator = generator;
getInputs().files(this.generator)
Expand All @@ -350,7 +357,7 @@ void setGenerator(Task generator) {
void syncAndFormat() {
FileFormatter formatter = new FileFormatter();
for (File output : this.generator.getOutputs().getFiles()) {
formatter.formatFiles(getProject().fileTree(output), StandardCharsets.UTF_8)
formatter.formatFiles(this.project.fileTree(output), StandardCharsets.UTF_8)
.forEach((edit) -> save(output, edit));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ task syncIntegrationTestSources(type: Sync) {
}

processResources {
def project = owner.project
eachFile {
filter { it.replace('${spring-boot.version}', project.version) }
}
Expand Down