external artifact builder: added API which allows to patch ant task parameters for pre/post processing tasks

This commit is contained in:
nik
2013-05-13 10:44:33 +04:00
parent 26c2343f0e
commit bf25020e5d
2 changed files with 37 additions and 1 deletions
@@ -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<String> commandLine = ExternalProcessUtil.buildJavaCommandLine(JpsJavaSdkType.getJavaExecutable(jdk), AntMain2.class.getName(),
Iterable<AntBuildTaskListener> listeners = JpsServiceManager.getInstance().getExtensions(AntBuildTaskListener.class);
for (AntBuildTaskListener listener : listeners) {
listener.beforeAntBuildTaskStarted(myExtension, vmParams, programParams);
}
List <String> commandLine = ExternalProcessUtil.buildJavaCommandLine(JpsJavaSdkType.getJavaExecutable(jdk), AntMain2.class.getName(),
Collections.<String>emptyList(), classpath, vmParams, programParams, false);
try {
Process process = new ProcessBuilder(commandLine).directory(new File(buildFilePath).getParentFile()).start();
@@ -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<String> vmParams, @NotNull List<String> programParams);
}