Search in sources :

Example 1 with AntRunner

use of org.eclipse.ant.core.AntRunner in project generator by mybatis.

the class GeneratorLaunchConfigurationDelegate method launch.

@Override
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
    AntRunner antRunner = new AntRunner();
    String buildFile;
    try {
        buildFile = generateAntScript(configuration);
    } catch (IOException e) {
        Status status = new Status(Status.ERROR, Activator.PLUGIN_ID, Messages.LAUNCH_ERROR_ERROR_GENERATING_ANT_FILE, e);
        throw new CoreException(status);
    }
    antRunner.setBuildFileLocation(buildFile);
    //$NON-NLS-1$
    antRunner.addBuildLogger("org.mybatis.generator.eclipse.ui.ant.GeneratorBuildLogger");
    modifyAntClasspathIfNecessary(configuration, antRunner);
    if (ILaunchManager.DEBUG_MODE.equals(mode)) {
        antRunner.setMessageOutputLevel(Project.MSG_DEBUG);
        //$NON-NLS-1$
        antRunner.setArguments("-debug");
    } else {
        antRunner.setMessageOutputLevel(Project.MSG_WARN);
    }
    antRunner.run(monitor);
    if (LauncherUtils.getBooleanOrFalse(configuration, GeneratorLaunchConstants.ATTR_SQL_SCRIPT_SECURE_CREDENTIALS)) {
        File file = new File(buildFile);
        file.delete();
    }
}
Also used : Status(org.eclipse.core.runtime.Status) AntRunner(org.eclipse.ant.core.AntRunner) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException) File(java.io.File)

Example 2 with AntRunner

use of org.eclipse.ant.core.AntRunner in project jop by jop-devel.

the class JOPizer method buildToolChain.

private void buildToolChain(IProgressMonitor monitor) throws CoreException {
    IPreferenceStore prefs = JOPUIPlugin.getDefault().getPreferenceStore();
    String jopHome = prefs.getString(IJOPLaunchConfigurationConstants.ATTR_JOP_HOME);
    AntRunner antRunner = new AntRunner();
    antRunner.setBuildFileLocation(jopHome + IPath.SEPARATOR + "build.xml");
    antRunner.setExecutionTargets(new String[] { "directories", "tools", "classes" });
    try {
        antRunner.run(monitor);
    } catch (CoreException e) {
        // TODO only for demo since i don't have quartus etc installed
        e.printStackTrace();
    }
}
Also used : AntRunner(org.eclipse.ant.core.AntRunner) CoreException(org.eclipse.core.runtime.CoreException) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 3 with AntRunner

use of org.eclipse.ant.core.AntRunner in project jop by jop-devel.

the class JOPLaunchConfigurationDelegate method launch.

@Override
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
    System.err.println("JOPLaunchConfigurationDelegate");
    if (CommonTab.isLaunchInBackground(configuration)) {
        System.err.println("Launch in background");
    }
    // FIXME do some serious error handling here, alright
    IJavaProject javaProject = getJavaProject(configuration);
    IProject project = javaProject.getProject();
    /* Can I guarantee this is a Java project?
         *   JOP runs only Java, so..?
         */
    // Find the build file (relative path)
    IFile buildFile = findAntBuildFile(project);
    IPath buildFileLocation = buildFile.getLocation();
    System.out.printf("[Build file] OS-string: %s%n", buildFileLocation.toOSString());
    AntRunner antRunner = new AntRunner();
    antRunner.setBuildFileLocation(buildFileLocation.toOSString());
    antRunner.addBuildLogger("org.apache.tools.ant.DefaultLogger");
    // TODO Remove when not debugging
    antRunner.setMessageOutputLevel(org.apache.tools.ant.Project.MSG_VERBOSE);
    setAntProperties(configuration, antRunner);
    try {
        antRunner.run(monitor);
    } catch (CoreException e) {
        // Build exception occured
        e.printStackTrace();
    }
    if (!AntRunner.isBuildRunning()) {
        // Launch the Java build
        super.launch(configuration, mode, launch, monitor);
    }
}
Also used : AntRunner(org.eclipse.ant.core.AntRunner) IJavaProject(org.eclipse.jdt.core.IJavaProject) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) CoreException(org.eclipse.core.runtime.CoreException) IProject(org.eclipse.core.resources.IProject)

Aggregations

AntRunner (org.eclipse.ant.core.AntRunner)3 CoreException (org.eclipse.core.runtime.CoreException)3 File (java.io.File)1 IOException (java.io.IOException)1 IFile (org.eclipse.core.resources.IFile)1 IProject (org.eclipse.core.resources.IProject)1 IPath (org.eclipse.core.runtime.IPath)1 Status (org.eclipse.core.runtime.Status)1 IJavaProject (org.eclipse.jdt.core.IJavaProject)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1