Search in sources :

Example 1 with BuildListener

use of org.apache.tools.ant.BuildListener in project Gargoyle by callakrsos.

the class AntRunConfigView method initialize.

@FXML
public void initialize() {
    c = new AntJavaCompiler(this.buildFile.getParentFile(), this.buildFile) {

        @Override
        protected BuildListener getBuildListener() {
            return progressListener;
        }
    };
    c.parse();
    this.txtBuildFileLocation.setText(this.buildFile.getAbsolutePath());
    this.txtProjectName.setText(c.getProjectName());
    //		tcTargetName.setCellFactory(value);
    tcChkTarget.setCellFactory(CheckBoxTableCell.forTableColumn(tcChkTarget));
    tcChkTarget.setCellValueFactory(param -> param.getValue().chkProperty());
    tcTargetName.setCellFactory(TextFieldTableCell.forTableColumn());
    tcTargetName.setCellValueFactory(param -> param.getValue().targetNameProperty());
    tcTargetDesc.setCellFactory(TextFieldTableCell.forTableColumn());
    tcTargetDesc.setCellValueFactory(param -> param.getValue().targetDescProperty());
    List<AntRunConfigItem> collect = c.getTargets().entrySet().stream().map(ent -> {
        String key = ent.getKey();
        if (ValueUtil.isEmpty(key))
            return null;
        String desc = ent.getValue().getDescription() == null ? "" : ent.getValue().getDescription();
        AntRunConfigItem item = new AntRunConfigItem(key, desc);
        item.chkProperty().addListener(new ChangeListenerImpl(item));
        boolean equals = key.equals(c.getDefaultTarget());
        item.setChk(equals);
        if (equals)
            item.setTargetDesc("[default]  ".concat(desc));
        return item;
    }).filter(v -> v != null).collect(Collectors.toList());
    tbTargets.getItems().addAll(collect);
    tbTargets.setEditable(true);
    tcChkTarget.setEditable(true);
    tcTargetName.setEditable(false);
    tcTargetDesc.setEditable(false);
//		Platform.runLater(()->{
//
//		});
}
Also used : Button(javafx.scene.control.Button) TextArea(javafx.scene.control.TextArea) LoggerFactory(org.slf4j.LoggerFactory) AntJavaCompiler(com.kyj.fx.voeditor.visual.framework.jdt.compiler.AntJavaCompiler) FXCollections(javafx.collections.FXCollections) TextFieldTableCell(javafx.scene.control.cell.TextFieldTableCell) TableColumn(javafx.scene.control.TableColumn) HashSet(java.util.HashSet) Task(javafx.concurrent.Task) TabPane(javafx.scene.control.TabPane) FileUtil(com.kyj.fx.voeditor.visual.util.FileUtil) TableView(javafx.scene.control.TableView) OutputStream(java.io.OutputStream) ObservableSet(javafx.collections.ObservableSet) TextField(javafx.scene.control.TextField) Logger(org.slf4j.Logger) BuildListener(org.apache.tools.ant.BuildListener) BuildEvent(org.apache.tools.ant.BuildEvent) ByteArrayOutputStream(org.apache.commons.io.output.ByteArrayOutputStream) FXMLController(com.kyj.fx.voeditor.visual.framework.annotation.FXMLController) IOException(java.io.IOException) ValueUtil(com.kyj.fx.voeditor.visual.util.ValueUtil) Collectors(java.util.stream.Collectors) File(java.io.File) FxPostInitialize(com.kyj.fx.voeditor.visual.framework.annotation.FxPostInitialize) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) FxUtil(com.kyj.fx.voeditor.visual.util.FxUtil) List(java.util.List) SystemConsole(com.kyj.fx.voeditor.visual.component.console.SystemConsole) Stage(javafx.stage.Stage) Tab(javafx.scene.control.Tab) CheckBoxTableCell(javafx.scene.control.cell.CheckBoxTableCell) ObservableValue(javafx.beans.value.ObservableValue) AntRunConfigItem(com.kyj.fx.voeditor.visual.component.config.model.AntRunConfigItem) BorderPane(javafx.scene.layout.BorderPane) ChangeListener(javafx.beans.value.ChangeListener) InputStream(java.io.InputStream) AntJavaCompiler(com.kyj.fx.voeditor.visual.framework.jdt.compiler.AntJavaCompiler) BuildListener(org.apache.tools.ant.BuildListener) AntRunConfigItem(com.kyj.fx.voeditor.visual.component.config.model.AntRunConfigItem) FXML(javafx.fxml.FXML)

Example 2 with BuildListener

use of org.apache.tools.ant.BuildListener in project Gargoyle by callakrsos.

the class AntJavaCompiler method parse.

/**
	 *
	 * build.xml파일을 파싱처리하여
	 * 빌드처리 준비상태로 처리한다.
	 * 이후 run 함수를 호출하여 빌드를 실행할 수 있다.
	 *
	 * @작성자 : KYJ
	 * @작성일 : 2017. 3. 7.
	 */
public void parse() {
    p = new Project();
    p.setUserProperty("ant.file", buildFile.getAbsolutePath());
    p.setUserProperty("encoding", encoding.displayName());
    p.init();
    helper = ProjectHelper.getProjectHelper();
    p.addReference("ant.projectHelper", helper);
    if (baseDir != null && baseDir.exists())
        p.setBaseDir(baseDir);
    else
        p.setBaseDir(buildFile.getParentFile());
    //setting console
    DefaultLogger consoleLogger = getLogger();
    consoleLogger.setOutputPrintStream(new PrintStream(out));
    consoleLogger.setErrorPrintStream(new PrintStream(err));
    consoleLogger.setMessageOutputLevel(Project.MSG_VERBOSE);
    p.addBuildListener(consoleLogger);
    //parse build.xml
    helper.parse(p, buildFile);
    LOGGER.debug("  ##### base dir : " + p.getBaseDir());
    LOGGER.debug("  ##### default target : " + p.getDefaultTarget());
    //append build debugger.
    BuildListener buildListener = getBuildListener();
    if (buildListener != null)
        p.addBuildListener(buildListener);
    wasParse = true;
}
Also used : Project(org.apache.tools.ant.Project) PrintStream(java.io.PrintStream) BuildListener(org.apache.tools.ant.BuildListener) DefaultLogger(org.apache.tools.ant.DefaultLogger)

Example 3 with BuildListener

use of org.apache.tools.ant.BuildListener in project ceylon-compiler by ceylon.

the class Util method getCeylonClassLoaderCachedInProject.

public static CeylonClassLoader getCeylonClassLoaderCachedInProject(final Project project) throws ClassLoaderSetupException {
    Object classLoader = project.getReference(CEYLON_CLASSLOADER_REFERENCE);
    if (classLoader != null) {
        CeylonClassLoader oldLoader = (CeylonClassLoader) classLoader;
        // make sure it's still valid
        try {
            List<File> classPath = CeylonClassLoader.getClassPath();
            if (oldLoader.hasSignature(CeylonClassLoader.getClassPathSignature(classPath))) {
                // compatible
                return oldLoader;
            } else {
                project.log("Needs a new class loader: cp changed!", Project.MSG_VERBOSE);
                CeylonClassLoader loader = CeylonClassLoader.newInstance(classPath);
                project.addReference(CEYLON_CLASSLOADER_REFERENCE, loader);
                return loader;
            }
        } catch (FileNotFoundException x) {
            throw new ClassLoaderSetupException(x);
        } catch (URISyntaxException x) {
            throw new ClassLoaderSetupException(x);
        } catch (MalformedURLException x) {
            throw new ClassLoaderSetupException(x);
        }
    }
    CeylonClassLoader loader = Launcher.getClassLoader();
    project.addReference(CEYLON_CLASSLOADER_REFERENCE, loader);
    // only add the build listed once, even if we change the class loader later
    project.addBuildListener(new BuildListener() {

        @Override
        public void buildFinished(BuildEvent arg0) {
            project.log("Build done, cleaning up Ceylon class loader", Project.MSG_VERBOSE);
            // make sure we get the latest one
            Object reference = project.getReference(CEYLON_CLASSLOADER_REFERENCE);
            project.getReferences().remove(CEYLON_CLASSLOADER_REFERENCE);
            if (reference instanceof CeylonClassLoader) {
                ((CeylonClassLoader) reference).clearCache();
            }
        }

        @Override
        public void buildStarted(BuildEvent arg0) {
        }

        @Override
        public void messageLogged(BuildEvent arg0) {
        }

        @Override
        public void targetFinished(BuildEvent arg0) {
        }

        @Override
        public void targetStarted(BuildEvent arg0) {
        }

        @Override
        public void taskFinished(BuildEvent arg0) {
        }

        @Override
        public void taskStarted(BuildEvent arg0) {
        }
    });
    return loader;
}
Also used : BuildListener(org.apache.tools.ant.BuildListener) MalformedURLException(java.net.MalformedURLException) BuildEvent(org.apache.tools.ant.BuildEvent) CeylonClassLoader(com.redhat.ceylon.launcher.CeylonClassLoader) FileNotFoundException(java.io.FileNotFoundException) URISyntaxException(java.net.URISyntaxException) ClassLoaderSetupException(com.redhat.ceylon.launcher.ClassLoaderSetupException) File(java.io.File)

Aggregations

BuildListener (org.apache.tools.ant.BuildListener)3 File (java.io.File)2 BuildEvent (org.apache.tools.ant.BuildEvent)2 AntRunConfigItem (com.kyj.fx.voeditor.visual.component.config.model.AntRunConfigItem)1 SystemConsole (com.kyj.fx.voeditor.visual.component.console.SystemConsole)1 FXMLController (com.kyj.fx.voeditor.visual.framework.annotation.FXMLController)1 FxPostInitialize (com.kyj.fx.voeditor.visual.framework.annotation.FxPostInitialize)1 AntJavaCompiler (com.kyj.fx.voeditor.visual.framework.jdt.compiler.AntJavaCompiler)1 FileUtil (com.kyj.fx.voeditor.visual.util.FileUtil)1 FxUtil (com.kyj.fx.voeditor.visual.util.FxUtil)1 ValueUtil (com.kyj.fx.voeditor.visual.util.ValueUtil)1 CeylonClassLoader (com.redhat.ceylon.launcher.CeylonClassLoader)1 ClassLoaderSetupException (com.redhat.ceylon.launcher.ClassLoaderSetupException)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 PrintStream (java.io.PrintStream)1 MalformedURLException (java.net.MalformedURLException)1 URISyntaxException (java.net.URISyntaxException)1