Skip to content

Commit

Permalink
Merge branch '1.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
v1nc3n4 committed Mar 13, 2020
2 parents 2c2f2c0 + a38b8ae commit 660fa94
Show file tree
Hide file tree
Showing 24 changed files with 464 additions and 244 deletions.
13 changes: 12 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,18 @@ matrix:

- os: osx
osx_image: xcode9.4
jdk: oraclejdk11
jdk: openjdk11
env:
# This is a convenience variable for shortening download commands
- GRAVIS="https://raw.githubusercontent.com/DanySK/Gravis-CI/master/"
# List any JDK you want to build your software with.
# You can see the list of supported environments by installing Jabba and using ls-remote:
# https://github.com/shyiko/jabba#usage
- JDK="openjdk@1.11"
before_install:
# Download the script, and download, install, configue the JDK, and export the configuration to the current shell
- curl "${GRAVIS}.install-jdk-travis.sh" --output ~/.install-jdk-travis.sh
- source ~/.install-jdk-travis.sh

- os: windows
# Java is not yet supported on Windows, so the build would block.
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ repository. The configuration actually allows to build and test the plugin on th
- Windows Server 2016 version 1803 / AdoptOpenJDK OpenJ9 1.8.0-232 64 bits

Ubuntu Xenial is the reference environment, used to analyze the source code with SonarCloud. By now, the plugin has been
developed on Windows 10 Home with OracleJDK 1.8.0_202 64 bits and [JetBrains IntelliJ IDEA][intellij].
developed on Windows 10 Home with OracleJDK 1.8.0_202 64 bits and [JetBrains IntelliJ IDEA][intellij-idea].

*Note: continuous integration of Java projects on Windows is not supported by Travis yet.*
*Note: continuous integration of Java projects on Windows is at an early stage for the moment.*

[apache-commons-compress]: <https://commons.apache.org/proper/commons-compress/> (Apache Commons Compress)
[intellij]: <https://www.jetbrains.com/idea/> (IntelliJ IDEA)
[intellij-idea]: <https://www.jetbrains.com/idea/> (IntelliJ IDEA)
[issues]: <https://github.com/Siouan/frontend-gradle-plugin/issues> (Issues)
[travis]: <https://travis-ci.com/> (Travis CI)
248 changes: 197 additions & 51 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ dependencies {
}

group 'org.siouan'
version '1.3.0'
version '1.3.1'
description 'Integrate your frontend Node/NPM/Yarn build into Gradle.'

sourceCompatibility = JavaVersion.VERSION_1_8
Expand Down
Binary file added intellij-idea-128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added jetbrains-128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sonar.projectKey=Siouan_frontend-gradle-plugin
sonar.projectName=frontend-gradle-plugin
sonar.projectVersion=1.3.0
sonar.projectVersion=1.3.1

sonar.links.homepage=https://github.com/Siouan/frontend-gradle-plugin
sonar.links.ci=https://travis-ci.com/Siouan/frontend-gradle-plugin
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package org.siouan.frontendgradleplugin;

import java.io.File;

import org.gradle.api.Project;
import org.gradle.api.file.DirectoryProperty;
import org.gradle.api.provider.Property;

/**
Expand All @@ -23,7 +22,7 @@ public class FrontendExtension {
/**
* Directory where the Node distribution shall be installed.
*/
private final Property<File> nodeInstallDirectory;
private final DirectoryProperty nodeInstallDirectory;

/**
* URL to download the Node distribution.
Expand All @@ -38,7 +37,7 @@ public class FrontendExtension {
/**
* Directory where the distribution shall be installed.
*/
private final Property<File> yarnInstallDirectory;
private final DirectoryProperty yarnInstallDirectory;

/**
* URL to download the distribution.
Expand Down Expand Up @@ -68,10 +67,10 @@ public class FrontendExtension {
public FrontendExtension(final Project project) {
yarnEnabled = project.getObjects().property(Boolean.class);
nodeVersion = project.getObjects().property(String.class);
nodeInstallDirectory = project.getObjects().property(File.class);
nodeInstallDirectory = project.getObjects().directoryProperty();
nodeDistributionUrl = project.getObjects().property(String.class);
yarnVersion = project.getObjects().property(String.class);
yarnInstallDirectory = project.getObjects().property(File.class);
yarnInstallDirectory = project.getObjects().directoryProperty();
yarnDistributionUrl = project.getObjects().property(String.class);
installScript = project.getObjects().property(String.class);
cleanScript = project.getObjects().property(String.class);
Expand All @@ -87,7 +86,7 @@ public Property<String> getNodeVersion() {
return nodeVersion;
}

public Property<File> getNodeInstallDirectory() {
public DirectoryProperty getNodeInstallDirectory() {
return nodeInstallDirectory;
}

Expand All @@ -99,7 +98,7 @@ public Property<String> getYarnVersion() {
return yarnVersion;
}

public Property<File> getYarnInstallDirectory() {
public DirectoryProperty getYarnInstallDirectory() {
return yarnInstallDirectory;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.siouan.frontendgradleplugin;

import java.io.File;
import java.util.function.BiPredicate;

import org.gradle.api.Plugin;
Expand Down Expand Up @@ -97,9 +96,11 @@ public void apply(final Project project) {

final FrontendExtension extension = project.getExtensions()
.create(EXTENSION_NAME, FrontendExtension.class, project);
extension.getNodeInstallDirectory().convention(new File(project.getProjectDir(), DEFAULT_NODE_INSTALL_DIRNAME));
extension.getNodeInstallDirectory()
.convention(project.getLayout().getProjectDirectory().dir(DEFAULT_NODE_INSTALL_DIRNAME));
extension.getYarnEnabled().convention(false);
extension.getYarnInstallDirectory().convention(new File(project.getProjectDir(), DEFAULT_YARN_INSTALL_DIRNAME));
extension.getYarnInstallDirectory()
.convention(project.getLayout().getProjectDirectory().dir(DEFAULT_YARN_INSTALL_DIRNAME));
extension.getInstallScript().convention(DEFAULT_INSTALL_SCRIPT);

final TaskContainer projectTasks = project.getTasks();
Expand All @@ -112,12 +113,11 @@ public void apply(final Project project) {
projectTasks.register(CHECK_TASK_NAME, CheckTask.class, task -> configureCheckTask(task, extension));
projectTasks.register(ASSEMBLE_TASK_NAME, AssembleTask.class, task -> configureAssembleTask(task, extension));

configureDependency(projectTasks, INSTALL_TASK_NAME, InstallTask.class, NODE_INSTALL_TASK_NAME,
NodeInstallTask.class);
configureDependency(projectTasks, INSTALL_TASK_NAME, InstallTask.class, YARN_INSTALL_TASK_NAME,
YarnInstallTask.class, (installTask, yarnInstallTask) -> {
installTask.dependsOn(NODE_INSTALL_TASK_NAME);
return yarnInstallTask.isEnabled();
});
configureDependency(projectTasks, CLEAN_TASK_NAME, CleanTask.class, INSTALL_TASK_NAME, InstallTask.class,
YarnInstallTask.class);
configureDependency(projectTasks, CLEAN_TASK_NAME, CleanTask.class, INSTALL_TASK_NAME, InstallTask.class,
(cleanTask, installTask) -> cleanTask.getCleanScript().isPresent());
configureDependency(projectTasks, ASSEMBLE_TASK_NAME, AssembleTask.class, INSTALL_TASK_NAME, InstallTask.class,
(assembleTask, installTask) -> assembleTask.getAssembleScript().isPresent());
Expand Down Expand Up @@ -151,10 +151,10 @@ private void configureNodeInstallTask(final NodeInstallTask task, final Frontend
* @param task Task.
* @param extension Plugin extension.
*/
private void configureYarnInstallTask(final YarnInstallTask task, FrontendExtension extension) {
private void configureYarnInstallTask(final YarnInstallTask task, final FrontendExtension extension) {
task.setGroup(TASK_GROUP);
task.setDescription("Downloads and installs a Yarn distribution.");
task.setEnabled(extension.getYarnEnabled().get());
task.setOnlyIf(t -> extension.getYarnEnabled().get());
task.getYarnVersion().set(extension.getYarnVersion());
task.getYarnDistributionUrl().set(extension.getYarnDistributionUrl());
task.getYarnInstallDirectory().set(extension.getYarnInstallDirectory());
Expand All @@ -166,7 +166,7 @@ private void configureYarnInstallTask(final YarnInstallTask task, FrontendExtens
* @param task Task.
* @param extension Plugin extension.
*/
private void configureInstallTask(final InstallTask task, FrontendExtension extension) {
private void configureInstallTask(final InstallTask task, final FrontendExtension extension) {
task.setGroup(TASK_GROUP);
task.setDescription("Installs/updates frontend dependencies.");
task.getYarnEnabled().set(extension.getYarnEnabled());
Expand All @@ -181,7 +181,7 @@ private void configureInstallTask(final InstallTask task, FrontendExtension exte
* @param task Task.
* @param extension Plugin extension.
*/
private void configureCleanTask(final CleanTask task, FrontendExtension extension) {
private void configureCleanTask(final CleanTask task, final FrontendExtension extension) {
task.setGroup(TASK_GROUP);
task.setDescription("Cleans frontend resources outside the build directory by running a specific script.");
task.getYarnEnabled().set(extension.getYarnEnabled());
Expand All @@ -196,7 +196,7 @@ private void configureCleanTask(final CleanTask task, FrontendExtension extensio
* @param task Task.
* @param extension Plugin extension.
*/
private void configureCheckTask(final CheckTask task, FrontendExtension extension) {
private void configureCheckTask(final CheckTask task, final FrontendExtension extension) {
task.setGroup(TASK_GROUP);
task.setDescription("Checks frontend by running a specific script.");
task.getYarnEnabled().set(extension.getYarnEnabled());
Expand All @@ -211,7 +211,7 @@ private void configureCheckTask(final CheckTask task, FrontendExtension extensio
* @param task Task.
* @param extension Plugin extension.
*/
private void configureAssembleTask(final AssembleTask task, FrontendExtension extension) {
private void configureAssembleTask(final AssembleTask task, final FrontendExtension extension) {
task.setGroup(TASK_GROUP);
task.setDescription("Assembles the frontend by running a specific script.");
task.getYarnEnabled().set(extension.getYarnEnabled());
Expand All @@ -221,7 +221,25 @@ private void configureAssembleTask(final AssembleTask task, FrontendExtension ex
}

/**
* Configures a dynamic dependency between 2 tasks, based on a condition evaluation.
* Configures a static dependency between 2 tasks.
*
* @param taskContainer Task container.
* @param taskName Name of the task that may depend on another task.
* @param taskClass Task class.
* @param dependsOnTaskName Name of the depending task.
* @param dependsOnTaskClass Depending task class.
* @param <T> Type of the dependent task.
* @param <D> Type of the depending task.
*/
private <T extends Task, D extends Task> void configureDependency(final TaskContainer taskContainer,
final String taskName, final Class<T> taskClass, final String dependsOnTaskName,
final Class<D> dependsOnTaskClass) {
taskContainer.named(taskName, taskClass,
task -> task.dependsOn(taskContainer.named(dependsOnTaskName, dependsOnTaskClass).getName()));
}

/**
* Configures a dynamic dependency between 2 tasks, based on the evaluation of a condition.
*
* @param taskContainer Task container.
* @param taskName Name of the task that may depend on another task.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public class DistributionInstallerSettings {
*
* @param task Related Gradle task.
* @param osName O/S name.
* @param temporaryDirectory Directory where the distribution being downloaded will be temporarily stored.
* @param urlResolver Resolver of the download URL.
* @param downloader Downloader.
* @param validator Distribution validator.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.siouan.frontendgradleplugin.tasks;

import java.io.File;

import org.gradle.api.file.DirectoryProperty;
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.Internal;
Expand All @@ -23,13 +22,13 @@ public Property<Boolean> getYarnEnabled() {

@Internal
@Optional
public Property<File> getNodeInstallDirectory() {
public DirectoryProperty getNodeInstallDirectory() {
return nodeInstallDirectory;
}

@Internal
@Optional
public Property<File> getYarnInstallDirectory() {
public DirectoryProperty getYarnInstallDirectory() {
return yarnInstallDirectory;
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package org.siouan.frontendgradleplugin.tasks;

import java.io.File;

import org.gradle.api.DefaultTask;
import org.gradle.api.file.DirectoryProperty;
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.TaskAction;
import org.siouan.frontendgradleplugin.core.ExecutableNotFoundException;
Expand All @@ -25,12 +24,12 @@ public abstract class AbstractRunScriptTask extends DefaultTask {
/**
* Directory where the Node distribution is installed.
*/
final Property<File> nodeInstallDirectory;
final DirectoryProperty nodeInstallDirectory;

/**
* Directory where the Yarn distribution is installed.
*/
final Property<File> yarnInstallDirectory;
final DirectoryProperty yarnInstallDirectory;

/**
* The script to run with NPM/Yarn.
Expand All @@ -45,8 +44,8 @@ public abstract class AbstractRunScriptTask extends DefaultTask {

AbstractRunScriptTask(boolean failOnMissingScriptEnabled) {
yarnEnabled = getProject().getObjects().property(Boolean.class);
nodeInstallDirectory = getProject().getObjects().property(File.class);
yarnInstallDirectory = getProject().getObjects().property(File.class);
nodeInstallDirectory = getProject().getObjects().directoryProperty();
yarnInstallDirectory = getProject().getObjects().directoryProperty();
script = getProject().getObjects().property(String.class);
this.failOnMissingScriptEnabled = failOnMissingScriptEnabled;
}
Expand All @@ -65,8 +64,8 @@ protected Executor getExecutionType() {
@TaskAction
public void execute() throws MissingScriptException, ExecutableNotFoundException {
if (script.isPresent()) {
new RunScriptJob(this, getExecutionType(), nodeInstallDirectory.get(), yarnInstallDirectory.get(),
script.get(), Utils.getSystemOsName()).run();
new RunScriptJob(this, getExecutionType(), nodeInstallDirectory.getAsFile().get(),
yarnInstallDirectory.getAsFile().get(), script.get(), Utils.getSystemOsName()).run();
} else if (failOnMissingScriptEnabled) {
throw new MissingScriptException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.security.NoSuchAlgorithmException;

import org.gradle.api.DefaultTask;
import org.gradle.api.file.DirectoryProperty;
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.Optional;
Expand Down Expand Up @@ -33,7 +34,7 @@ public class NodeInstallTask extends DefaultTask {
/**
* Directory where the Node distribution shall be installed.
*/
private final Property<File> nodeInstallDirectory;
private final DirectoryProperty nodeInstallDirectory;

/**
* URL to download the Node distribution.
Expand All @@ -42,7 +43,7 @@ public class NodeInstallTask extends DefaultTask {

public NodeInstallTask() {
nodeVersion = getProject().getObjects().property(String.class);
nodeInstallDirectory = getProject().getObjects().property(File.class);
nodeInstallDirectory = getProject().getObjects().directoryProperty();
nodeDistributionUrl = getProject().getObjects().property(String.class);
}

Expand All @@ -59,7 +60,7 @@ public Property<String> getNodeDistributionUrl() {

@OutputDirectory
@Optional
public Property<File> getNodeInstallDirectory() {
public DirectoryProperty getNodeInstallDirectory() {
return nodeInstallDirectory;
}

Expand All @@ -74,7 +75,7 @@ public Property<File> getNodeInstallDirectory() {
public void execute() throws DistributionInstallerException, NoSuchAlgorithmException {
final String version = nodeVersion.get();
final String distributionUrl = nodeDistributionUrl.getOrNull();
final File installDirectory = nodeInstallDirectory.get();
final File installDirectory = nodeInstallDirectory.getAsFile().get();
final DistributionInstallerSettings settings = new DistributionInstallerSettings(this, Utils.getSystemOsName(),
getTemporaryDir().toPath(), new NodeDistributionUrlResolver(version, distributionUrl), new DownloaderImpl(getTemporaryDir().toPath()),
new NodeDistributionValidator(this, new DownloaderImpl(getTemporaryDir().toPath()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.File;

import org.gradle.api.DefaultTask;
import org.gradle.api.file.DirectoryProperty;
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.Optional;
Expand All @@ -29,7 +30,7 @@ public class YarnInstallTask extends DefaultTask {
/**
* Directory where the distribution shall be installed.
*/
private final Property<File> yarnInstallDirectory;
private final DirectoryProperty yarnInstallDirectory;

/**
* URL to download the distribution.
Expand All @@ -38,7 +39,7 @@ public class YarnInstallTask extends DefaultTask {

public YarnInstallTask() {
yarnVersion = getProject().getObjects().property(String.class);
yarnInstallDirectory = getProject().getObjects().property(File.class);
yarnInstallDirectory = getProject().getObjects().directoryProperty();
yarnDistributionUrl = getProject().getObjects().property(String.class);
}

Expand All @@ -55,7 +56,7 @@ public Property<String> getYarnDistributionUrl() {

@OutputDirectory
@Optional
public Property<File> getYarnInstallDirectory() {
public DirectoryProperty getYarnInstallDirectory() {
return yarnInstallDirectory;
}

Expand All @@ -69,7 +70,7 @@ public void execute() throws DistributionInstallerException {
final DistributionInstallerSettings settings = new DistributionInstallerSettings(this, Utils.getSystemOsName(),
getTemporaryDir().toPath(), new YarnDistributionUrlResolver(yarnVersion.get(), yarnDistributionUrl.getOrNull()),
new DownloaderImpl(getTemporaryDir().toPath()), null, new ArchiverFactoryImpl(),
yarnInstallDirectory.map(File::toPath).getOrNull());
yarnInstallDirectory.getAsFile().map(File::toPath).getOrNull());
new DistributionInstaller(settings).install();
}
}
Loading

0 comments on commit 660fa94

Please sign in to comment.