dependencyResolutionManagement.repositoriesMode= "
+ + "FAIL_ON_PROJECT_REPOS
is present",
+ "Gradle docs",
+ true,
+ () -> BrowserUtil.browse(
+ "https://docs.gradle.org/8.5/userguide/dependency_management.html"
+ + "#sub:centralized-repository-declaration")));
+
+ this.optChbxCleanUpTemporaryFiles.ifPresent(chbx -> chbx.addItemListener(e ->
+ this.changeValueForCheckbox(e, GradleRecipesExecutorConfig::setCleanUpTemporaryFiles)));
+ this.chbxTryPatchSettings.addItemListener(e ->
+ this.changeValueForCheckbox(e, GradleRecipesExecutorConfig::setTryPatchSettings));
+ }
+
+ @Override
+ protected void updateFrom(final GradleRecipesExecutorConfig data)
+ {
+ this.optChbxCleanUpTemporaryFiles.ifPresent(chbx -> chbx.setSelected(data.isCleanUpTemporaryFiles()));
+ this.chbxTryPatchSettings.setSelected(data.isTryPatchSettings());
+ }
+
+ protected JPanel addComponentWithHelp(final JComponent component, final ContextHelpLabel helpLabel)
+ {
+ final JPanel panel = new JPanel();
+ panel.setLayout(new HorizontalLayout(5));
+ panel.add(component);
+ panel.add(helpLabel);
+
+ this.add(panel);
+ return panel;
+ }
+ }
+}
diff --git a/src/main/java/software/xdev/openrewriter/executor/gradle/GradleRecipesExecutorConfig.java b/src/main/java/software/xdev/openrewriter/executor/gradle/GradleRecipesExecutorConfig.java
new file mode 100644
index 0000000..b2cd667
--- /dev/null
+++ b/src/main/java/software/xdev/openrewriter/executor/gradle/GradleRecipesExecutorConfig.java
@@ -0,0 +1,30 @@
+package software.xdev.openrewriter.executor.gradle;
+
+import software.xdev.openrewriter.executor.RecipesExecutorConfig;
+
+
+public class GradleRecipesExecutorConfig implements RecipesExecutorConfig
+{
+ private boolean cleanUpTemporaryFiles = true;
+ private boolean tryPatchSettings;
+
+ public boolean isCleanUpTemporaryFiles()
+ {
+ return this.cleanUpTemporaryFiles;
+ }
+
+ public void setCleanUpTemporaryFiles(final boolean cleanUpTemporaryFiles)
+ {
+ this.cleanUpTemporaryFiles = cleanUpTemporaryFiles;
+ }
+
+ public boolean isTryPatchSettings()
+ {
+ return this.tryPatchSettings;
+ }
+
+ public void setTryPatchSettings(final boolean tryPatchSettings)
+ {
+ this.tryPatchSettings = tryPatchSettings;
+ }
+}
diff --git a/src/main/java/software/xdev/openrewriter/executor/gradle/rcb/GradleDirectoryExecutionTargetRCB.java b/src/main/java/software/xdev/openrewriter/executor/gradle/rcb/GradleDirectoryExecutionTargetRCB.java
new file mode 100644
index 0000000..79fbb21
--- /dev/null
+++ b/src/main/java/software/xdev/openrewriter/executor/gradle/rcb/GradleDirectoryExecutionTargetRCB.java
@@ -0,0 +1,23 @@
+package software.xdev.openrewriter.executor.gradle.rcb;
+
+import com.intellij.openapi.project.Project;
+
+import software.xdev.openrewriter.executor.gradle.GradleRecipesExecutor;
+import software.xdev.openrewriter.executor.request.ExecutionRequest;
+import software.xdev.openrewriter.executor.request.target.directory.DirectoryExecutionTarget;
+
+
+public class GradleDirectoryExecutionTargetRCB implements GradleRequestCommandBuilder
+{
+ @Override
+ public void apply(
+ final Project project,
+ final ExecutionRequest request,
+ final GradleRecipesExecutor.GradleRunArguments gradleRunArguments)
+ {
+ if(request.getTarget() instanceof final DirectoryExecutionTarget det)
+ {
+ gradleRunArguments.setWorkDir(det.getPath().toString());
+ }
+ }
+}
diff --git a/src/main/java/software/xdev/openrewriter/executor/gradle/rcb/GradleModuleExecutionTargetRCB.java b/src/main/java/software/xdev/openrewriter/executor/gradle/rcb/GradleModuleExecutionTargetRCB.java
new file mode 100644
index 0000000..a6962bd
--- /dev/null
+++ b/src/main/java/software/xdev/openrewriter/executor/gradle/rcb/GradleModuleExecutionTargetRCB.java
@@ -0,0 +1,27 @@
+package software.xdev.openrewriter.executor.gradle.rcb;
+
+import java.util.Objects;
+
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.project.ProjectUtil;
+
+import software.xdev.openrewriter.executor.gradle.GradleRecipesExecutor;
+import software.xdev.openrewriter.executor.request.ExecutionRequest;
+import software.xdev.openrewriter.executor.request.target.module.ModuleExecutionTarget;
+
+
+public class GradleModuleExecutionTargetRCB implements GradleRequestCommandBuilder
+{
+ @Override
+ public void apply(
+ final Project project,
+ final ExecutionRequest request,
+ final GradleRecipesExecutor.GradleRunArguments gradleRunArguments)
+ {
+ if(request.getTarget() instanceof final ModuleExecutionTarget met)
+ {
+ gradleRunArguments.setWorkDir(
+ Objects.requireNonNull(ProjectUtil.guessModuleDir(met.getModule())).getPath());
+ }
+ }
+}
diff --git a/src/main/java/software/xdev/openrewriter/executor/gradle/rcb/GradleRequestCommandBuilder.java b/src/main/java/software/xdev/openrewriter/executor/gradle/rcb/GradleRequestCommandBuilder.java
new file mode 100644
index 0000000..478f6c4
--- /dev/null
+++ b/src/main/java/software/xdev/openrewriter/executor/gradle/rcb/GradleRequestCommandBuilder.java
@@ -0,0 +1,16 @@
+package software.xdev.openrewriter.executor.gradle.rcb;
+
+import com.intellij.openapi.project.Project;
+
+import software.xdev.openrewriter.executor.RequestCommandBuilder;
+import software.xdev.openrewriter.executor.gradle.GradleRecipesExecutor;
+import software.xdev.openrewriter.executor.request.ExecutionRequest;
+
+
+public interface GradleRequestCommandBuilder extends RequestCommandBuilder
+{
+ void apply(
+ final Project project,
+ final ExecutionRequest request,
+ final GradleRecipesExecutor.GradleRunArguments gradleRunArguments);
+}
diff --git a/src/main/java/software/xdev/openrewriter/executor/gradle/rcb/GradleSimpleArtifactRecipesDataRCB.java b/src/main/java/software/xdev/openrewriter/executor/gradle/rcb/GradleSimpleArtifactRecipesDataRCB.java
new file mode 100644
index 0000000..dcf06a8
--- /dev/null
+++ b/src/main/java/software/xdev/openrewriter/executor/gradle/rcb/GradleSimpleArtifactRecipesDataRCB.java
@@ -0,0 +1,36 @@
+package software.xdev.openrewriter.executor.gradle.rcb;
+
+import java.util.stream.Collectors;
+
+import com.intellij.openapi.project.Project;
+
+import software.xdev.openrewriter.executor.gradle.GradleRecipesExecutor;
+import software.xdev.openrewriter.executor.request.ExecutionRequest;
+import software.xdev.openrewriter.executor.request.recipedata.simpleartifact.Artifact;
+import software.xdev.openrewriter.executor.request.recipedata.simpleartifact.Recipe;
+import software.xdev.openrewriter.executor.request.recipedata.simpleartifact.SimpleArtifactRecipesData;
+
+
+public class GradleSimpleArtifactRecipesDataRCB implements GradleRequestCommandBuilder
+{
+ @Override
+ public void apply(
+ final Project project,
+ final ExecutionRequest request,
+ final GradleRecipesExecutor.GradleRunArguments gradleRunArguments)
+ {
+ if(request.getRecipesData() instanceof final SimpleArtifactRecipesData r)
+ {
+ r.getArtifacts().stream()
+ // https://docs.gradle.org/current/userguide/single_versions.html
+ .map(a -> a.toFullMavenArtifact(version -> Artifact.DEFAULT_VERSION.equals(version)
+ ? "latest.release"
+ : version))
+ .forEach(gradleRunArguments.getDependenciesForRewrite()::add);
+
+ gradleRunArguments.setGradleCommandLine(gradleRunArguments.getGradleCommandLine()
+ + " -Drewrite.activeRecipes="
+ + r.getRecipes().stream().map(Recipe::getId).collect(Collectors.joining(",")));
+ }
+ }
+}
diff --git a/src/main/java/software/xdev/openrewriter/executor/maven/MavenRecipesExecutor.java b/src/main/java/software/xdev/openrewriter/executor/maven/MavenRecipesExecutor.java
new file mode 100644
index 0000000..d7a45bd
--- /dev/null
+++ b/src/main/java/software/xdev/openrewriter/executor/maven/MavenRecipesExecutor.java
@@ -0,0 +1,101 @@
+package software.xdev.openrewriter.executor.maven;
+
+import java.util.Objects;
+import java.util.Optional;
+
+import javax.swing.Icon;
+
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.idea.maven.execution.MavenRunConfigurationType;
+import org.jetbrains.idea.maven.execution.MavenRunnerParameters;
+import org.jetbrains.idea.maven.execution.MavenRunnerSettings;
+import org.jetbrains.idea.maven.project.MavenGeneralSettings;
+import org.jetbrains.idea.maven.project.MavenProjectsManager;
+
+import com.intellij.openapi.module.Module;
+import com.intellij.openapi.project.Project;
+
+import icons.MavenIcons;
+import software.xdev.openrewriter.executor.RecipesExecutor;
+import software.xdev.openrewriter.executor.RequestCommandBuilder;
+import software.xdev.openrewriter.executor.maven.rcb.MavenRequestCommandBuilder;
+import software.xdev.openrewriter.executor.request.ExecutionRequest;
+import software.xdev.openrewriter.ui.toolwindow.execute.panels.ExecuteRecipeConfigPanel;
+
+
+public class MavenRecipesExecutor implements RecipesExecutorAn artifact is described like this: [groupId:]artifactId[:version]
Attribute | " + + "Default value | " + + "
---|---|
groupId | "
+ + "" + Artifact.DEFAULT_GROUP_ID + " | "
+ + "
version | "
+ + "" + Artifact.DEFAULT_VERSION + " | "
+ + "
Examples:
" + + "rewrite-migrate-java
" + Artifact.DEFAULT_GROUP_ID + ":rewrite-migrate-java
" + Artifact.DEFAULT_GROUP_ID + ":rewrite-migrate-java:" + Artifact.DEFAULT_VERSION
+ + "
The value is derived from recipeArtifactCoordinates
.
A recipeID is described like this:
"
+ + "org.openrewrite.java.RemoveUnusedImports
The value is derived from activeRecipes
.