From bf25020e5d8e572e4533e4198f5b68abb12dd6e0 Mon Sep 17 00:00:00 2001 From: nik Date: Mon, 13 May 2013 10:44:33 +0400 Subject: [PATCH] external artifact builder: added API which allows to patch ant task parameters for pre/post processing tasks --- .../build/AntArtifactBuildTaskProvider.java | 8 ++++- .../jps/ant/build/AntBuildTaskListener.java | 30 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/build/AntBuildTaskListener.java diff --git a/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/build/AntArtifactBuildTaskProvider.java b/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/build/AntArtifactBuildTaskProvider.java index 19b9eb8fb4a3..f86377fb4153 100644 --- a/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/build/AntArtifactBuildTaskProvider.java +++ b/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/build/AntArtifactBuildTaskProvider.java @@ -46,6 +46,7 @@ import org.jetbrains.jps.model.library.JpsOrderRootType; import org.jetbrains.jps.model.library.JpsTypedLibrary; import org.jetbrains.jps.model.library.sdk.JpsSdk; import org.jetbrains.jps.model.library.sdk.JpsSdkReference; +import org.jetbrains.jps.service.JpsServiceManager; import org.jetbrains.jps.util.JpsPathUtil; import java.io.File; @@ -164,7 +165,12 @@ public class AntArtifactBuildTaskProvider extends ArtifactBuildTaskProvider { programParams.add(targetName); } - List commandLine = ExternalProcessUtil.buildJavaCommandLine(JpsJavaSdkType.getJavaExecutable(jdk), AntMain2.class.getName(), + Iterable listeners = JpsServiceManager.getInstance().getExtensions(AntBuildTaskListener.class); + for (AntBuildTaskListener listener : listeners) { + listener.beforeAntBuildTaskStarted(myExtension, vmParams, programParams); + } + + List commandLine = ExternalProcessUtil.buildJavaCommandLine(JpsJavaSdkType.getJavaExecutable(jdk), AntMain2.class.getName(), Collections.emptyList(), classpath, vmParams, programParams, false); try { Process process = new ProcessBuilder(commandLine).directory(new File(buildFilePath).getParentFile()).start(); diff --git a/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/build/AntBuildTaskListener.java b/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/build/AntBuildTaskListener.java new file mode 100644 index 000000000000..24a5dfc56afa --- /dev/null +++ b/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/build/AntBuildTaskListener.java @@ -0,0 +1,30 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.jps.ant.build; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jps.ant.model.artifacts.JpsAntArtifactExtension; + +import java.util.List; + +/** + * Register implementation of this class in META-INF/services. It will be called before starting an Ant pre/post processing task + * + * @author nik + */ +public abstract class AntBuildTaskListener { + public abstract void beforeAntBuildTaskStarted(@NotNull JpsAntArtifactExtension extension, @NotNull List vmParams, @NotNull List programParams); +}