-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
249 additions
and
68 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
12 changes: 12 additions & 0 deletions
12
src/main/java/org/siouan/frontendgradleplugin/core/Executor.java
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,12 @@ | ||
package org.siouan.frontendgradleplugin.core; | ||
|
||
/** | ||
* Enumeration of types of execution supported by the plugin. | ||
* | ||
* @since 1.2.0 | ||
*/ | ||
public enum Executor { | ||
NODE, | ||
NPM, | ||
YARN; | ||
} |
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
43 changes: 43 additions & 0 deletions
43
src/main/java/org/siouan/frontendgradleplugin/tasks/RunNodeTask.java
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,43 @@ | ||
package org.siouan.frontendgradleplugin.tasks; | ||
|
||
import org.gradle.api.provider.Property; | ||
import org.gradle.api.tasks.Input; | ||
import org.siouan.frontendgradleplugin.FrontendExtension; | ||
import org.siouan.frontendgradleplugin.core.ExecutableNotFoundException; | ||
import org.siouan.frontendgradleplugin.core.Executor; | ||
|
||
/** | ||
* Task provided as a type to let developers implement custom task based on it. The task does not expose Node related | ||
* options to avoid duplicating the plugin configuration. Using this task as a type to register a custom task requires | ||
* only to define the {@code script} attribute, and to make the custom task depends on the {@code installNode} or {@code | ||
* installFrontend} tasks. Choosing the related parent task will depend on the user needs. | ||
* <p> | ||
* A typical usage of this task in a 'build.gradle' file would be: | ||
* <pre> | ||
* tasks.register('mytask', org.siouan.frontendgradleplugin.tasks.RunNodeTask) { | ||
* dependsOn tasks.named('installFrontend') | ||
* script = 'myscript' | ||
* } | ||
* </pre> | ||
*/ | ||
public class RunNodeTask extends AbstractRunScriptTask { | ||
|
||
@Input | ||
public Property<String> getScript() { | ||
return script; | ||
} | ||
|
||
@Override | ||
protected Executor getExecutionType() { | ||
return Executor.NODE; | ||
} | ||
|
||
@Override | ||
public void execute() throws ExecutableNotFoundException { | ||
final FrontendExtension extension = getProject().getExtensions().findByType(FrontendExtension.class); | ||
yarnEnabled.set(extension.getYarnEnabled()); | ||
nodeInstallDirectory.set(extension.getNodeInstallDirectory()); | ||
yarnInstallDirectory.set(extension.getYarnInstallDirectory()); | ||
super.execute(); | ||
} | ||
} |
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
Oops, something went wrong.