Search in sources :

Example 1 with MavenBeforeRunTask

use of org.jetbrains.idea.maven.tasks.MavenBeforeRunTask in project azure-tools-for-java by Microsoft.

the class BeforeRunTaskUtils method createMavenPackageTask.

@NotNull
public static BeforeRunTask<?> createMavenPackageTask(@Nonnull MavenProject project, @NotNull RunConfiguration config) {
    final String pomXmlPath = MavenUtils.getMavenModulePath(project);
    final MavenBeforeRunTask task = new MavenBeforeRunTask();
    task.setEnabled(true);
    task.setProjectPath(pomXmlPath);
    task.setGoal(MAVEN_TASK_PACKAGE);
    return task;
}
Also used : MavenBeforeRunTask(org.jetbrains.idea.maven.tasks.MavenBeforeRunTask) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with MavenBeforeRunTask

use of org.jetbrains.idea.maven.tasks.MavenBeforeRunTask in project azure-tools-for-java by Microsoft.

the class MavenRunTaskUtil method shouldAddMavenPackageTask.

/**
 * Legacy code, will be replaced by BeforeRunTaskUtils
 * @deprecated
 */
@Deprecated
private static boolean shouldAddMavenPackageTask(List<BeforeRunTask> tasks, Project project) {
    boolean shouldAdd = true;
    for (BeforeRunTask task : tasks) {
        if (task.getProviderId().equals(MavenBeforeRunTasksProvider.ID)) {
            MavenBeforeRunTask mavenTask = (MavenBeforeRunTask) task;
            if (mavenTask.getGoal().contains(MAVEN_TASK_PACKAGE) && Comparing.equal(mavenTask.getProjectPath(), project.getBasePath() + File.separator + MavenConstants.POM_XML)) {
                mavenTask.setEnabled(true);
                shouldAdd = false;
                break;
            }
        }
    }
    return shouldAdd;
}
Also used : MavenBeforeRunTask(org.jetbrains.idea.maven.tasks.MavenBeforeRunTask) BeforeRunTask(com.intellij.execution.BeforeRunTask) MavenBeforeRunTask(org.jetbrains.idea.maven.tasks.MavenBeforeRunTask)

Example 3 with MavenBeforeRunTask

use of org.jetbrains.idea.maven.tasks.MavenBeforeRunTask in project intellij-community by JetBrains.

the class ToggleBeforeRunTaskAction method doIsSelected.

@Override
protected boolean doIsSelected(AnActionEvent e) {
    final DataContext context = e.getDataContext();
    final Pair<MavenProject, String> desc = getTaskDesc(context);
    if (desc != null) {
        final RunManagerEx runManager = getRunManager(context);
        if (runManager == null)
            return false;
        for (MavenBeforeRunTask each : runManager.getBeforeRunTasks(MavenBeforeRunTasksProvider.ID)) {
            if (each.isFor(desc.first, desc.second))
                return true;
        }
    }
    return false;
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) MavenProject(org.jetbrains.idea.maven.project.MavenProject) RunManagerEx(com.intellij.execution.RunManagerEx) MavenBeforeRunTask(org.jetbrains.idea.maven.tasks.MavenBeforeRunTask)

Example 4 with MavenBeforeRunTask

use of org.jetbrains.idea.maven.tasks.MavenBeforeRunTask in project google-cloud-intellij by GoogleCloudPlatform.

the class MavenBuildDeploymentSourceType method createBuildTask.

@Nullable
@Override
protected BeforeRunTask createBuildTask(@NotNull Module module) {
    String mavenModulePath = getMavenModulePath(module);
    if (mavenModulePath != null) {
        MavenBeforeRunTask task = new MavenBeforeRunTask();
        task.setProjectPath(mavenModulePath);
        task.setGoal(MAVEN_TASK_PACKAGE);
        task.setEnabled(true);
        return task;
    } else {
        return null;
    }
}
Also used : MavenBeforeRunTask(org.jetbrains.idea.maven.tasks.MavenBeforeRunTask) Nullable(org.jetbrains.annotations.Nullable)

Example 5 with MavenBeforeRunTask

use of org.jetbrains.idea.maven.tasks.MavenBeforeRunTask in project azure-tools-for-java by Microsoft.

the class MavenRunTaskUtil method addMavenPackageBeforeRunTask.

/**
 * Add Maven package goal into the run configuration's before run task.
 */
public static void addMavenPackageBeforeRunTask(RunConfiguration runConfiguration) {
    final RunManagerEx manager = RunManagerEx.getInstanceEx(runConfiguration.getProject());
    if (isMavenProject(runConfiguration.getProject())) {
        List<BeforeRunTask> tasks = new ArrayList<>(manager.getBeforeRunTasks(runConfiguration));
        if (MavenRunTaskUtil.shouldAddMavenPackageTask(tasks, runConfiguration.getProject())) {
            MavenBeforeRunTask task = new MavenBeforeRunTask();
            task.setEnabled(true);
            task.setProjectPath(runConfiguration.getProject().getBasePath() + File.separator + MavenConstants.POM_XML);
            task.setGoal(MAVEN_TASK_PACKAGE);
            tasks.add(task);
            manager.setBeforeRunTasks(runConfiguration, tasks);
        }
    }
}
Also used : MavenBeforeRunTask(org.jetbrains.idea.maven.tasks.MavenBeforeRunTask) BeforeRunTask(com.intellij.execution.BeforeRunTask) RunManagerEx(com.intellij.execution.RunManagerEx) ArrayList(java.util.ArrayList) MavenBeforeRunTask(org.jetbrains.idea.maven.tasks.MavenBeforeRunTask)

Aggregations

MavenBeforeRunTask (org.jetbrains.idea.maven.tasks.MavenBeforeRunTask)5 BeforeRunTask (com.intellij.execution.BeforeRunTask)2 RunManagerEx (com.intellij.execution.RunManagerEx)2 DataContext (com.intellij.openapi.actionSystem.DataContext)1 ArrayList (java.util.ArrayList)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1 MavenProject (org.jetbrains.idea.maven.project.MavenProject)1