Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt plugin to Gradle File Permission API changes #188

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 6 additions & 2 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
`kotlin-dsl`
id("org.gradle.kotlin-dsl.ktlint-convention") version "0.4.1"
id("org.gradle.kotlin-dsl.ktlint-convention") version "0.6.0"
}

repositories {
Expand All @@ -10,8 +10,12 @@ repositories {

dependencies {
implementation(kotlin("gradle-plugin"))
implementation("org.asciidoctor:asciidoctor-gradle-plugin:1.5.9.1")
implementation("org.ajoberstar:gradle-git-publish:0.3.3")

implementation("org.asciidoctor:asciidoctor-gradle-plugin:1.6.1")
constraints {
implementation("org.ysb33r.gradle:grolifant:0.12.1")
}
}

kotlinDslPluginOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ class UserGuidePlugin : Plugin<Project> {
fun Project.configureAsciidoctorTask() {
val asciidoctor by tasks.existing(AsciidoctorTask::class) {
sourceDir = file("src/docs/asciidoc")
sources(delegateClosureOf<PatternSet> {
include("index.adoc")
})
sources(
delegateClosureOf<PatternSet> {
include("index.adoc")
}
)

attributes(
mapOf(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package org.gradle.playframework.plugins;

import org.gradle.api.Action;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.*;
import org.gradle.api.artifacts.ArtifactCollection;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.component.ComponentIdentifier;
Expand Down Expand Up @@ -122,13 +119,32 @@ private void createDistributionContentTasks(Project project, Distribution distri

distSpec.into("bin", copySpec -> {
copySpec.from(createStartScriptsTask);
copySpec.setFileMode(0755);
setFileMode(copySpec);
});

distSpec.into("conf", copySpec -> copySpec.from("conf").exclude("routes"));
distSpec.from("README");
}

private void setFileMode(CopySpec copySpec) {
try {
if (GradleVersion.current().compareTo(GradleVersion.version("8.3")) >= 0) {
copySpec.getClass().getMethod("filePermissions", Action.class)
.invoke(copySpec, (Action<?>) filePermission -> {
try {
filePermission.getClass().getMethod("unix", String.class).invoke(filePermission, "0755");
} catch (Exception e) {
throw new GradleException("Failed to set unix file permission", e);
}
});
} else {
copySpec.getClass().getMethod("setFileMode", Integer.class).invoke(copySpec, 0755);
}
} catch (Exception e) {
throw new GradleException("Failed to set file permissions", e);
}
}

private String getMainClass(PlayPlatform playPlatform) {
switch (PlayMajorVersion.forPlatform(playPlatform)) {
case PLAY_2_3_X:
Expand Down Expand Up @@ -238,7 +254,7 @@ public void execute(FileCopyDetails fileCopyDetails) {
public String apply(File input) {
calculateRenames();
String rename = renames.get(input);
if (rename!=null) {
if (rename != null) {
return rename;
}
return input.getName();
Expand Down
Loading