/** * Populate destination make target with data from source make target. * * @param source - source make target. * @param destination - destination make target. * @throws CoreException if there is a problem populating the target. * <p>See MakeTarget */ private static void copyTargetData(IMakeTarget source, IMakeTarget destination) throws CoreException { // IMakeTarget attributes // destination.project and destination.targetBuilderID are not changed destination.setRunAllBuilders(source.runAllBuilders()); destination.setAppendProjectEnvironment(source.appendProjectEnvironment()); destination.setBuildAttribute( IMakeTarget.BUILD_TARGET, source.getBuildAttribute(IMakeTarget.BUILD_TARGET, "")); // $NON-NLS-1$ // IMakeCommonBuildInfo attributes // Ignore IMakeCommonBuildInfo.BUILD_LOCATION in order not to pick // location of another project (or another folder) if (!source.isDefaultBuildCmd()) { destination.setBuildAttribute( IMakeCommonBuildInfo.BUILD_COMMAND, source.getBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, DEFAULT_BUILD_COMMAND)); destination.setBuildAttribute( IMakeCommonBuildInfo.BUILD_ARGUMENTS, source.getBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, "")); // $NON-NLS-1$ } destination.setStopOnError(source.isStopOnError()); destination.setUseDefaultBuildCmd(source.isDefaultBuildCmd()); destination.setEnvironment(source.getEnvironment()); destination.setAppendEnvironment(source.appendEnvironment()); // setErrorParsers() is not supported in MakeTarget yet }
/** * Creating a copy of IMakeTarget in a different project. * * @param name - name of new target. * @param makeTarget - make target. * @param project - project where to assign the make target. * @return newly created make target. * @throws CoreException if there is a problem with creating or copying the target. */ private static IMakeTarget cloneTarget(String name, IMakeTarget makeTarget, IProject project) throws CoreException { IMakeTargetManager makeTargetManager = MakeCorePlugin.getDefault().getTargetManager(); String[] ids = makeTargetManager.getTargetBuilders(project); String builderId = ids[0]; IMakeTarget newMakeTarget = makeTargetManager.createTarget(project, name, builderId); copyTargetData(makeTarget, newMakeTarget); if (makeTarget .getName() .equals(makeTarget.getBuildAttribute(IMakeTarget.BUILD_TARGET, ""))) { // $NON-NLS-1$ newMakeTarget.setBuildAttribute(IMakeTarget.BUILD_TARGET, name); } return newMakeTarget; }