From 27ff91920951c2068b648e3722d89b4ac8aa02f1 Mon Sep 17 00:00:00 2001 From: Sergii Kabashniuk Date: Tue, 5 Sep 2017 17:18:48 +0300 Subject: [PATCH] Remove unsupported ant extension (#6140) --- .../che-plugin-java-ant-tools/pom.xml | 55 ---- .../che/ide/ant/tools/AntBuildListener.java | 144 ---------- .../eclipse/che/ide/ant/tools/AntMessage.java | 84 ------ .../eclipse/che/ide/ant/tools/AntUtils.java | 259 ----------------- .../tools/buildfile/BuildFileGenerator.java | 264 ------------------ .../buildfile/BuildFileGeneratorTest.java | 40 --- .../src/test/resources/test-build.xml | 27 -- .../che-plugin-java-ext-ant/pom.xml | 100 ------- .../extension/ant/client/AntExtension.java | 102 ------- .../ant/client/inject/AntGinModule.java | 39 --- .../ant/client/projecttree/AntFolderNode.java | 60 ---- .../client/projecttree/AntNodeFactory.java | 59 ---- .../client/projecttree/AntProjectNode.java | 66 ----- .../projecttree/AntProjectTreeStructure.java | 72 ----- .../AntProjectTreeStructureProvider.java | 67 ----- .../ant/client/wizard/AntPagePresenter.java | 112 -------- .../ant/client/wizard/AntPageView.java | 21 -- .../ant/client/wizard/AntPageViewImpl.java | 41 --- .../ant/client/wizard/AntPageViewImpl.ui.xml | 18 -- .../wizard/AntProjectWizardRegistrar.java | 56 ---- .../ant/server/inject/AntModule.java | 41 --- .../project/type/AntProjectGenerator.java | 51 ---- .../server/project/type/AntProjectType.java | 45 --- .../project/type/AntValueProviderFactory.java | 124 -------- .../extension/ant/shared/AntAttributes.java | 27 -- .../eclipse/che/ide/extension/ant/Ant.gwt.xml | 25 -- .../src/test/resources/test-build.xml | 27 -- 27 files changed, 2026 deletions(-) delete mode 100644 plugins/plugin-java/che-plugin-java-ant-tools/pom.xml delete mode 100644 plugins/plugin-java/che-plugin-java-ant-tools/src/main/java/org/eclipse/che/ide/ant/tools/AntBuildListener.java delete mode 100644 plugins/plugin-java/che-plugin-java-ant-tools/src/main/java/org/eclipse/che/ide/ant/tools/AntMessage.java delete mode 100644 plugins/plugin-java/che-plugin-java-ant-tools/src/main/java/org/eclipse/che/ide/ant/tools/AntUtils.java delete mode 100644 plugins/plugin-java/che-plugin-java-ant-tools/src/main/java/org/eclipse/che/ide/ant/tools/buildfile/BuildFileGenerator.java delete mode 100644 plugins/plugin-java/che-plugin-java-ant-tools/src/test/java/org/eclipse/che/ide/ant/tools/buildfile/BuildFileGeneratorTest.java delete mode 100644 plugins/plugin-java/che-plugin-java-ant-tools/src/test/resources/test-build.xml delete mode 100644 plugins/plugin-java/che-plugin-java-ext-ant/pom.xml delete mode 100644 plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/AntExtension.java delete mode 100644 plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/inject/AntGinModule.java delete mode 100644 plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/projecttree/AntFolderNode.java delete mode 100644 plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/projecttree/AntNodeFactory.java delete mode 100644 plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/projecttree/AntProjectNode.java delete mode 100644 plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/projecttree/AntProjectTreeStructure.java delete mode 100644 plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/projecttree/AntProjectTreeStructureProvider.java delete mode 100644 plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/wizard/AntPagePresenter.java delete mode 100644 plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/wizard/AntPageView.java delete mode 100644 plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/wizard/AntPageViewImpl.java delete mode 100644 plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/wizard/AntPageViewImpl.ui.xml delete mode 100644 plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/wizard/AntProjectWizardRegistrar.java delete mode 100644 plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/server/inject/AntModule.java delete mode 100644 plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/server/project/type/AntProjectGenerator.java delete mode 100644 plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/server/project/type/AntProjectType.java delete mode 100644 plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/server/project/type/AntValueProviderFactory.java delete mode 100644 plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/shared/AntAttributes.java delete mode 100644 plugins/plugin-java/che-plugin-java-ext-ant/src/main/resources/org/eclipse/che/ide/extension/ant/Ant.gwt.xml delete mode 100644 plugins/plugin-java/che-plugin-java-ext-ant/src/test/resources/test-build.xml diff --git a/plugins/plugin-java/che-plugin-java-ant-tools/pom.xml b/plugins/plugin-java/che-plugin-java-ant-tools/pom.xml deleted file mode 100644 index 88eec4f69f4..00000000000 --- a/plugins/plugin-java/che-plugin-java-ant-tools/pom.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - 4.0.0 - - che-plugin-java-parent - org.eclipse.che.plugin - 4.0.0-SNAPSHOT - - che-plugin-java-ant-tools - jar - Che Plugin :: Java :: Ant Tools - - - org.apache.ant - ant - ${org.apache.ant.version} - - - org.eclipse.che.core - che-core-api-core - ${project.version} - - - junit - junit - ${junit.version} - test - - - - - - com.mycila - license-maven-plugin - - - **/test-build.xml - - - - - - diff --git a/plugins/plugin-java/che-plugin-java-ant-tools/src/main/java/org/eclipse/che/ide/ant/tools/AntBuildListener.java b/plugins/plugin-java/che-plugin-java-ant-tools/src/main/java/org/eclipse/che/ide/ant/tools/AntBuildListener.java deleted file mode 100644 index 065ef753992..00000000000 --- a/plugins/plugin-java/che-plugin-java-ant-tools/src/main/java/org/eclipse/che/ide/ant/tools/AntBuildListener.java +++ /dev/null @@ -1,144 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2015 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.ide.ant.tools; - -import org.apache.tools.ant.BuildEvent; -import org.apache.tools.ant.BuildListener; -import org.apache.tools.ant.Target; -import org.apache.tools.ant.Task; - -import java.io.IOException; -import java.io.ObjectOutputStream; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.net.Socket; - -/** @author andrew00x */ -public class AntBuildListener implements BuildListener { - private boolean autoFlush = true; - - private Socket socket; - private ObjectOutputStream out; - private boolean connect; - - public AntBuildListener() { - } - - private void connect() { - try { - socket = new Socket("127.0.0.1", getPort()); - out = new ObjectOutputStream(socket.getOutputStream()); - connect = true; - } catch (IOException e) { - throw new IllegalStateException(e); - } - } - - private void disconnect() { - if (!connect) { - return; - } - if (out != null) { - try { - out.close(); - } catch (IOException ignored) { - } - } - if (socket != null) { - try { - socket.close(); - } catch (IOException ignored) { - } - } - connect = false; - } - - @Override - public void buildStarted(BuildEvent event) { - connect(); - send(new AntMessage(AntMessage.BUILD_STARTED, null, null, event.getMessage())); - } - - @Override - public void buildFinished(BuildEvent event) { - final AntMessage message; - final Throwable throwable = event.getException(); - if (throwable == null) { - message = new AntMessage(AntMessage.BUILD_SUCCESSFUL, null, null, event.getMessage()); - } else { - StringWriter writer = new StringWriter(); - throwable.printStackTrace(new PrintWriter(writer)); - message = new AntMessage(AntMessage.BUILD_ERROR, null, null, writer.toString()); - } - send(message); - send(null); - disconnect(); - } - - @Override - public void targetStarted(BuildEvent event) { - } - - @Override - public void targetFinished(BuildEvent event) { - } - - @Override - public void taskStarted(BuildEvent event) { - } - - @Override - public void taskFinished(BuildEvent event) { - } - - @Override - public void messageLogged(BuildEvent event) { - final Target target = event.getTarget(); - final Task task = event.getTask(); - final String text = event.getMessage(); - send(new AntMessage(AntMessage.BUILD_LOG, - target == null ? null : target.getName(), - task == null ? null : task.getTaskName(), - text) - ); - } - - private void send(AntMessage message) { - try { - out.writeObject(message); - if (autoFlush) { - out.flush(); - } - } catch (IOException e) { - throw new IllegalStateException(e); - } - } - - private int getPort() { - final String commandLine = System.getProperty("sun.java.command"); - final String myProperty = "-D" + getClass().getName() + ".port"; - String myPort = null; - int start = commandLine.indexOf(myProperty); - if (start > 0) { - start = commandLine.indexOf('=', start); - int end = commandLine.indexOf(' ', start); - if (end < 0) { - end = commandLine.length(); - } - myPort = commandLine.substring(start + 1, end); - } - try { - return Integer.parseInt(myPort); - } catch (NumberFormatException e) { - throw new IllegalStateException("Unable connect to the builder, connection port is not set."); - } - } -} diff --git a/plugins/plugin-java/che-plugin-java-ant-tools/src/main/java/org/eclipse/che/ide/ant/tools/AntMessage.java b/plugins/plugin-java/che-plugin-java-ant-tools/src/main/java/org/eclipse/che/ide/ant/tools/AntMessage.java deleted file mode 100644 index 4dbb37ca3b1..00000000000 --- a/plugins/plugin-java/che-plugin-java-ant-tools/src/main/java/org/eclipse/che/ide/ant/tools/AntMessage.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2015 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.ide.ant.tools; - -import java.io.Serializable; - -/** @author andrew00x */ -public class AntMessage implements Serializable { - public static final int BUILD_ERROR = -1; - public static final int BUILD_STARTED = 1; - public static final int BUILD_SUCCESSFUL = 1 << 1; - public static final int BUILD_LOG = 1 << 2; - - private static final long serialVersionUID = 6112041830147092037L; - - private int type; - private String target; - private String task; - private String text; - - public AntMessage(int type, String target, String task, String text) { - this.type = type; - this.target = target; - this.task = task; - this.text = text; - } - - public AntMessage(int type) { - this(type, null, null, null); - } - - public AntMessage() { - } - - public int getType() { - return type; - } - - public void setType(int type) { - this.type = type; - } - - public String getTarget() { - return target; - } - - public void setTarget(String target) { - this.target = target; - } - - public String getTask() { - return task; - } - - public void setTask(String task) { - this.task = task; - } - - public String getText() { - return text; - } - - public void setText(String message) { - this.text = message; - } - - @Override - public String toString() { - return "AntMessage{" + - "type=" + type + - ", target='" + target + '\'' + - ", task='" + task + '\'' + - ", text='" + text + '\'' + - '}'; - } -} diff --git a/plugins/plugin-java/che-plugin-java-ant-tools/src/main/java/org/eclipse/che/ide/ant/tools/AntUtils.java b/plugins/plugin-java/che-plugin-java-ant-tools/src/main/java/org/eclipse/che/ide/ant/tools/AntUtils.java deleted file mode 100644 index b190c52f0a4..00000000000 --- a/plugins/plugin-java/che-plugin-java-ant-tools/src/main/java/org/eclipse/che/ide/ant/tools/AntUtils.java +++ /dev/null @@ -1,259 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2015 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.ide.ant.tools; - -import org.eclipse.che.api.core.util.CommandLine; -import org.eclipse.che.api.core.util.LineConsumer; -import org.eclipse.che.api.core.util.ProcessUtil; -import org.eclipse.che.api.vfs.server.VirtualFile; -import org.eclipse.che.vfs.impl.fs.VirtualFileImpl; - -import org.apache.tools.ant.Project; -import org.apache.tools.ant.helper.ProjectHelper2; - -import java.io.FileFilter; -import java.io.IOException; -import java.io.Writer; -import java.nio.charset.Charset; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.List; -import java.util.Map; - -/** @author andrew00x */ -// TODO: avoid usage org.apache.tools.ant.Project for representation Ant project. -public class AntUtils { - private static final Path BUILD_FILE_PATH = Paths.get(System.getProperty("java.io.tmpdir"), "codenvy_ant_properties.xml"); - private static final String BUILD_FILE_CONTENT = "\n" + - " \n" + - " Ant version: ${ant.version}\n" + - " Ant home: ${ant.home}\n" + - " Java version: ${java.version}, vendor: ${java.vendor}\n" + - " Java home: ${java.home}\n" + - " OS name: \"${os.name}\", version: \"${os.version}\", " + - "arch: \"${os.arch}\"\n" + - " \n" + - "\n"; - - /** Not instantiable. */ - private AntUtils() { - } - - public static String getAntExecCommand() { - final java.io.File antHome = getAntHome(); - if (antHome != null) { - final String ant = "bin" + java.io.File.separatorChar + "ant"; - return new java.io.File(antHome, ant).getAbsolutePath(); // If ant home directory set use it - } else { - return "ant"; // otherwise 'ant' should be in PATH variable - } - } - - public static java.io.File getAntHome() { - final String antHomeEnv = System.getenv("ANT_HOME"); - if (antHomeEnv == null) { - return null; - } - java.io.File antHome = new java.io.File(antHomeEnv); - return antHome.exists() ? antHome : null; - } - - private static java.io.File getJavaHome() { - final String javaHomeEnv = System.getenv("JAVA_HOME"); - if (javaHomeEnv == null) { - return null; - } - java.io.File javaHome = new java.io.File(javaHomeEnv); - return javaHome.exists() ? javaHome : null; - } - - private static java.io.File getJavaHome2() { - String javaHomeSys = System.getProperty("java.home"); - if (javaHomeSys == null) { - return null; - } - java.io.File javaHome = new java.io.File(javaHomeSys); - if (!javaHome.exists()) { - return null; - } - final String toolsJar = "lib" + java.io.File.separatorChar + "tools.jar"; - if (new java.io.File(javaHome, toolsJar).exists()) { - return javaHome; - } - if (javaHomeSys.endsWith("jre")) { - javaHomeSys = javaHomeSys.substring(0, javaHomeSys.length() - 4); // remove "/jre" - } - javaHome = new java.io.File(javaHomeSys); - if (!javaHome.exists()) { - return null; - } - if (new java.io.File(javaHome, toolsJar).exists()) { - return javaHome; - } - return null; - } - - /** - * Creates FileFilter that helps filter system. - * Ant may add two tools.jar in classpath. It uses two JavaHome locations. One from java system property and one from OS environment - * variable. Ant sources: org.apache.tools.ant.launch.Locator.getToolsJar. - */ - public static FileFilter newSystemFileFilter() { - final java.io.File antHome = AntUtils.getAntHome(); - final java.io.File javaHome = getJavaHome(); - final java.io.File javaHome2 = getJavaHome2(); - final Path antHomePath = antHome == null ? null : antHome.toPath(); - final Path javaHomePath = javaHome == null ? null : javaHome.toPath(); - final Path javaHomePath2 = javaHome2 == null ? null : javaHome2.toPath(); - return new FileFilter() { - @Override - public boolean accept(java.io.File file) { - final Path path = file.toPath(); - // Skip ant and system jars - return !(javaHomePath != null && path.startsWith(javaHomePath) - || javaHomePath2 != null && path.startsWith(javaHomePath2) - || antHomePath != null && path.startsWith(antHomePath)); - } - }; - } - - public static Map getAntEnvironmentInformation() throws IOException { - final Map versionInfo = new HashMap<>(); - final LineConsumer cmdOutput = new LineConsumer() { - boolean end = false; - - @Override - public void writeLine(String line) throws IOException { - if (line.isEmpty()) { - end = true; - } - if (end) { - return; - } - String key = null; - int keyEnd = 0; - int valueStart = 0; - final int l = line.length(); - while (keyEnd < l) { - if (line.charAt(keyEnd) == ':') { - valueStart = keyEnd + 1; - break; - } - keyEnd++; - } - if (keyEnd > 0) { - key = line.substring(0, keyEnd); - } - if (key != null) { - while (valueStart < l && Character.isWhitespace(line.charAt(valueStart))) { - valueStart++; - } - if ("Ant version".equals(key)) { - int valueEnd = line.indexOf("compiled on", valueStart); - final String value = line.substring(valueStart, valueEnd).trim(); - versionInfo.put(key, value); - } else { - final String value = line.substring(valueStart); - versionInfo.put(key, value); - } - } - } - - @Override - public void close() throws IOException { - } - }; - readAntEnvironmentInformation(cmdOutput); - return versionInfo; - } - - private static void readAntEnvironmentInformation(LineConsumer cmdOutput) throws IOException { - if (!Files.isReadable(BUILD_FILE_PATH)) { - try (Writer writer = Files.newBufferedWriter(BUILD_FILE_PATH, Charset.forName("UTF-8"))) { - writer.write(BUILD_FILE_CONTENT); - } - } - final CommandLine commandLine = new CommandLine(getAntExecCommand()).add("-f", BUILD_FILE_PATH.toString(), "-quiet", "-emacs"); - final ProcessBuilder processBuilder = new ProcessBuilder().command(commandLine.toShellCommand()).redirectErrorStream(true); - final Process process = processBuilder.start(); - ProcessUtil.process(process, cmdOutput, LineConsumer.DEV_NULL); - } - - /** Get source directories. */ - public static List getSourceDirectories(java.io.File buildFile) throws IOException { - return getSourceDirectories(readProject(buildFile)); - } - - /** Get source directories. */ - public static List getSourceDirectories(VirtualFile buildFile) throws IOException { - //TODO: try fix problem with some build.xml that don't have basedir prop - return getSourceDirectories(readProject(buildFile)); - } - - /** - * Read description of ant project. - * - * @param buildFile - * path to build.xml file - * @return description of ant project - */ - public static Project readProject(java.io.File buildFile) throws IOException { - org.apache.tools.ant.Project antProject = new org.apache.tools.ant.Project(); - antProject.setBasedir(buildFile.getParentFile().getAbsolutePath()); //TODO: try fix problem with some build.xml that don't have basedir prop - try { - ProjectHelper2.configureProject(antProject, buildFile); - } catch (Exception e) { -// throw new IOException("Error parsing ant file. " + e.getMessage()); - return antProject; //TODO: return empty project. Skip all parsing error. Lets importing project if not parse build.xml. In this case will used default props. - } - return antProject; - } - - public static Project readProject(VirtualFile buildFile) throws IOException { - return readProject(((VirtualFileImpl)buildFile).getIoFile()); - } - - - /** Get source directories. */ - public static List getSourceDirectories(Project project) { - Hashtable properties = project.getProperties(); - String absProjectPath = project.getBaseDir().getAbsolutePath(); - List paths = new ArrayList<>(2); - - if (properties.containsKey("src.dir")) { - String srcPath = (String)properties.get("src.dir"); - srcPath = srcPath.substring(absProjectPath.length()); - - if (srcPath.startsWith("/")) { - srcPath = srcPath.substring(1); - } - paths.add(srcPath); - } - if (properties.containsKey("test.dir")) { - String testPath = (String)properties.get("test.dir"); - testPath = testPath.substring(absProjectPath.length()); - - if (testPath.startsWith("/")) { - testPath = testPath.substring(1); - } - paths.add(testPath); - } - if (paths.isEmpty()) { - paths.add("src"); - paths.add("test"); - } - return paths; - } -} diff --git a/plugins/plugin-java/che-plugin-java-ant-tools/src/main/java/org/eclipse/che/ide/ant/tools/buildfile/BuildFileGenerator.java b/plugins/plugin-java/che-plugin-java-ant-tools/src/main/java/org/eclipse/che/ide/ant/tools/buildfile/BuildFileGenerator.java deleted file mode 100644 index b3539e493f8..00000000000 --- a/plugins/plugin-java/che-plugin-java-ant-tools/src/main/java/org/eclipse/che/ide/ant/tools/buildfile/BuildFileGenerator.java +++ /dev/null @@ -1,264 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2015 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.ide.ant.tools.buildfile; - -import org.eclipse.che.api.core.ServerException; - -import org.w3c.dom.Comment; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; -import java.io.StringWriter; -import java.util.Map; -import java.util.TreeMap; - -/** - * Creates build.xml file. That need for Ant automation build tool to be able to build simple project using Ant. - * Idea based on eclipse Ant build file creator from eclipse sources (org.eclipse.ant.internal.ui.datatransfer.BuildFileCreator). - * - * @author Vladyslav Zhukovskii - */ -public class BuildFileGenerator { - - /** Name of the project, which used in build file generation. */ - private String projectName; - - /** - * Create instance of {@link BuildFileGenerator}. - * - * @param projectName - * name of the generated project. - */ - public BuildFileGenerator(String projectName) { - this.projectName = projectName; - } - - /** Root container of the document tree. */ - private Document doc; - - /** Element which represent document tree. */ - private Element root; - - /** - * Build simple Ant build file (build.xml) content based on project name. - * - * @return string representation of auto generated build file - */ - public String getBuildFileContent() throws ServerException { - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - try { - this.doc = dbf.newDocumentBuilder().newDocument(); - createRoot(); - createProperty(); -// createClassPath(); - createBuild(); - createClean(); - return documentToString(doc); - } catch (ParserConfigurationException | TransformerException e) { - throw new ServerException(e.getMessage(), e); - } - } - - /** - * Create project tag. - * - */ - private void createRoot() { - root = doc.createElement("project"); - root.setAttribute("name", projectName); - root.setAttribute("default", "build"); - root.setAttribute("basedir", "."); - - doc.appendChild(root); - } - - - /** - * Create property tag. - * - */ - private void createProperty() { - Map locationProperties = new TreeMap<>(); - locationProperties.put("build", "${basedir}/build"); - locationProperties.put("build.classes", "${build}/classes"); - locationProperties.put("src.dir", "${basedir}/src"); - - Element nameProperty = doc.createElement("property"); - nameProperty.setAttribute("name", "name"); - nameProperty.setAttribute("value", projectName); - - Node node = root.getFirstChild(); - node = root.insertBefore(nameProperty, node); - - for (Map.Entry locationProperty : locationProperties.entrySet()) { - Element locationElement = doc.createElement("property"); - locationElement.setAttribute("name", locationProperty.getKey()); - locationElement.setAttribute("location", locationProperty.getValue()); - node = node.getNextSibling(); - node = root.insertBefore(locationElement, node); - } - } - -// /** -// * Create classpath tag. -// * -// * -// * -// */ -// private void createClassPath() { -// Element path = doc.createElement("path"); -// path.setAttribute("id", "libs.dir"); -// -// Element fieldSet = doc.createElement("fileset"); -// fieldSet.setAttribute("dir", "lib"); -// fieldSet.setAttribute("includes", "**/*.jar"); -// -// path.appendChild(fieldSet); -// -// root.appendChild(path); -// } - - /** - * Create build target tag. - * - * ... - * - */ - private void createBuild() { - //Insert comment - Comment buildComment = doc.createComment("Application build"); - root.appendChild(buildComment); - - //Create main target tag - Element target = doc.createElement("target"); - target.setAttribute("name", "build"); - target.setAttribute("depends", "clean"); - target.setAttribute("description", "Builds the application"); - - //Insert comment - Comment createDirectoryComment = doc.createComment("Create directory"); - target.appendChild(createDirectoryComment); - - //Create mkdir tag inside target - Element mkdir = doc.createElement("mkdir"); - mkdir.setAttribute("dir", "${build.classes}"); - target.appendChild(mkdir); - - //Insert comment - Comment compileSourcesComment = doc.createComment("Compile source code"); - target.appendChild(compileSourcesComment); - - //Create javac tag inside target - Element javac = doc.createElement("javac"); - javac.setAttribute("srcdir", "${src.dir}"); - javac.setAttribute("destdir", "${build.classes}"); - javac.setAttribute("debug", "false"); - javac.setAttribute("deprecation", "true"); - javac.setAttribute("optimize", "true"); - javac.setAttribute("includeantruntime", "true"); - -// //Create classpath tag inside javac -// Element classpath = doc.createElement("classpath"); -// classpath.setAttribute("refid", "libs.dir"); -// javac.appendChild(classpath); - - target.appendChild(javac); - - //Insert comment - Comment copyNecessaryFiles = doc.createComment("Copy necessary files"); - target.appendChild(copyNecessaryFiles); - - //Create copy tag inside target - Element copy = doc.createElement("copy"); - copy.setAttribute("todir", "${build.classes}"); - - //Create fileset tag inside copy - Element copyFileset = doc.createElement("fileset"); - copyFileset.setAttribute("dir", "${src.dir}"); - copyFileset.setAttribute("includes", "**/*.*"); - copyFileset.setAttribute("excludes", "**/*.java"); - copy.appendChild(copyFileset); - - target.appendChild(copy); - - //Insert comment - Comment createJarComment = doc.createComment("Create JAR-file"); - target.appendChild(createJarComment); - - //Create jar tag inside target - Element jar = doc.createElement("jar"); - jar.setAttribute("jarfile", "${build}/${name}.jar"); - - //Create fileset tag inside jar - Element jarFileset = doc.createElement("fileset"); - jarFileset.setAttribute("dir", "${build.classes}"); - jar.appendChild(jarFileset); - - target.appendChild(jar); - - root.appendChild(target); - } - - /** - * Create clean target tag. - * - * ... - * - */ - private void createClean() { - //Insert comment - Comment cleanUpComment = doc.createComment("Clean up"); - root.appendChild(cleanUpComment); - - //Create main target tag - Element target = doc.createElement("target"); - target.setAttribute("name", "clean"); - target.setAttribute("description", "Remove all temporary files"); - - //Insert comment - Comment deleteFileComment = doc.createComment("Delete files"); - target.appendChild(deleteFileComment); - - //Create delete tag inside target tag - Element delete = doc.createElement("delete"); - delete.setAttribute("dir", "${build.classes}"); - - target.appendChild(delete); - - root.appendChild(target); - } - - /** Convert document to formatted XML string. */ - private String documentToString(Document doc) throws TransformerException { - StringWriter writer = new StringWriter(); - Source source = new DOMSource(doc); - Result result = new StreamResult(writer); - TransformerFactory factory = TransformerFactory.newInstance(); - factory.setAttribute("indent-number", "4"); - - Transformer transformer = factory.newTransformer(); - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); - transformer.transform(source, result); - - return writer.toString(); - } -} diff --git a/plugins/plugin-java/che-plugin-java-ant-tools/src/test/java/org/eclipse/che/ide/ant/tools/buildfile/BuildFileGeneratorTest.java b/plugins/plugin-java/che-plugin-java-ant-tools/src/test/java/org/eclipse/che/ide/ant/tools/buildfile/BuildFileGeneratorTest.java deleted file mode 100644 index 77d5c0856cd..00000000000 --- a/plugins/plugin-java/che-plugin-java-ant-tools/src/test/java/org/eclipse/che/ide/ant/tools/buildfile/BuildFileGeneratorTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2015 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.ide.ant.tools.buildfile; - -import org.junit.Test; - -import java.util.Scanner; - -import static org.junit.Assert.assertEquals; - -/** @author Vladyslav Zhukovskii */ -public class BuildFileGeneratorTest { - - @Test - public void testGenerateBuildFile() throws Exception { - String genBuildFile = new BuildFileGenerator("test").getBuildFileContent(); - String testBuildFile = getTestBuildFileContent(); - - assertEquals(genBuildFile, testBuildFile); - } - - private String getTestBuildFileContent() throws Exception { - StringBuilder sb = new StringBuilder(); - try (Scanner sc = new Scanner(ClassLoader.getSystemResourceAsStream("test-build.xml"))) { - while (sc.hasNextLine()) { - sb.append(sc.nextLine()).append(System.getProperty("line.separator")); - } - } - - return sb.toString(); - } -} diff --git a/plugins/plugin-java/che-plugin-java-ant-tools/src/test/resources/test-build.xml b/plugins/plugin-java/che-plugin-java-ant-tools/src/test/resources/test-build.xml deleted file mode 100644 index 8a5bb890e7c..00000000000 --- a/plugins/plugin-java/che-plugin-java-ant-tools/src/test/resources/test-build.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/plugins/plugin-java/che-plugin-java-ext-ant/pom.xml b/plugins/plugin-java/che-plugin-java-ext-ant/pom.xml deleted file mode 100644 index 76d9fd2d1d9..00000000000 --- a/plugins/plugin-java/che-plugin-java-ext-ant/pom.xml +++ /dev/null @@ -1,100 +0,0 @@ - - - - 4.0.0 - - che-plugin-java-parent - org.eclipse.che.plugin - 4.0.0-SNAPSHOT - - che-plugin-java-ext-ant - jar - Che Plugin :: Java :: Extension Ant - - - com.google.inject - guice - ${com.google.code.guice.version} - - - guava - com.google.guava - - - - - org.eclipse.che.core - che-core-ide-api - ${project.version} - - - org.eclipse.che.plugin - che-plugin-java-ant-tools - ${project.version} - - - org.eclipse.che.plugin - che-plugin-java-ext-java - ${project.version} - - - org.eclipse.che.plugin - che-plugin-runner-ext-runner - ${project.version} - - - junit - junit - ${junit.version} - test - - - org.mockito - mockito-core - ${org.mockito.version} - test - - - - src/main/java - target/classes - - - src/main/java - - - src/main/resources - - - - - src/test/java - - - src/test/resources - - - - - com.mycila - license-maven-plugin - - - **/test-build.xml - - - - - - diff --git a/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/AntExtension.java b/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/AntExtension.java deleted file mode 100644 index 59956deacb9..00000000000 --- a/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/AntExtension.java +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2015 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.ide.extension.ant.client; - -import org.eclipse.che.ide.api.project.client.ProjectServiceClient; -import org.eclipse.che.api.project.shared.dto.ProjectDescriptor; -import org.eclipse.che.ide.api.event.FileEvent; -import org.eclipse.che.ide.api.event.FileEventHandler; -import org.eclipse.che.ide.api.event.ProjectActionEvent; -import org.eclipse.che.ide.api.event.ProjectActionHandler; -import org.eclipse.che.ide.api.event.RefreshProjectTreeEvent; -import org.eclipse.che.ide.api.extension.Extension; -import org.eclipse.che.ide.api.project.tree.TreeStructureProviderRegistry; -import org.eclipse.che.ide.api.project.tree.generic.ProjectNode; -import org.eclipse.che.ide.ext.java.client.dependenciesupdater.DependenciesUpdater; -import org.eclipse.che.ide.ext.java.shared.Constants; -import org.eclipse.che.ide.extension.ant.client.projecttree.AntProjectTreeStructureProvider; -import org.eclipse.che.ide.extension.ant.shared.AntAttributes; -import org.eclipse.che.ide.rest.AsyncRequestCallback; -import org.eclipse.che.ide.rest.DtoUnmarshallerFactory; -import org.eclipse.che.ide.rest.Unmarshallable; -import org.eclipse.che.ide.util.loging.Log; -import com.google.inject.Inject; -import com.google.inject.Singleton; -import com.google.web.bindery.event.shared.EventBus; - -/** - * Extension for support Ant projects. - * - * @author Vladyslav Zhukovskii - */ -@Singleton -@Extension(title = "Ant", version = "3.0.0") -public class AntExtension { - - /** Create instance of {@link AntExtension}. */ - @Inject - public AntExtension(final EventBus eventBus, - final DependenciesUpdater dependenciesUpdater, - final DtoUnmarshallerFactory dtoUnmarshallerFactory, - final ProjectServiceClient projectServiceClient, - TreeStructureProviderRegistry treeStructureProviderRegistry) { - // Handle project opened event to fire update dependencies. - eventBus.addHandler(ProjectActionEvent.TYPE, new ProjectActionHandler() { - @Override - public void onProjectOpened(ProjectActionEvent event) { - ProjectDescriptor project = event.getProject(); - if (AntAttributes.ANT_ID.equals(project.getType()) - && project.getAttributes().containsKey(Constants.LANGUAGE) - && project.getAttributes().get(Constants.LANGUAGE).get(0).equals("java")) { - dependenciesUpdater.updateDependencies(project, false); - } - } - - @Override - public void onProjectClosing(ProjectActionEvent event) { - } - - @Override - public void onProjectClosed(ProjectActionEvent event) { - } - }); - - // Handle build.xml file save operation and if ant configuration has been changed reload project tree. - // For example, if user provide custom source directory. - eventBus.addHandler(FileEvent.TYPE, new FileEventHandler() { - @Override - public void onFileOperation(final FileEvent event) { - if (event.getOperationType() == FileEvent.FileOperation.SAVE && "build.xml".equals(event.getFile().getName())) { - final ProjectNode project = event.getFile().getProject(); - Unmarshallable unmarshaller = dtoUnmarshallerFactory.newUnmarshaller(ProjectDescriptor.class); - projectServiceClient.getProject(project.getData().getPath(), - new AsyncRequestCallback(unmarshaller) { - @Override - protected void onSuccess(ProjectDescriptor result) { - if (!result.getAttributes().equals(project.getData().getAttributes())) { - project.setData(result); - eventBus.fireEvent(new RefreshProjectTreeEvent(project)); - } - } - - @Override - protected void onFailure(Throwable exception) { - Log.info(getClass(), "Unable to get the project.", exception); - } - } - ); - } - } - }); - - treeStructureProviderRegistry.associateProjectTypeToTreeProvider(AntAttributes.ANT_ID, AntProjectTreeStructureProvider.ID); - } -} diff --git a/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/inject/AntGinModule.java b/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/inject/AntGinModule.java deleted file mode 100644 index 5c021537be8..00000000000 --- a/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/inject/AntGinModule.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2015 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.ide.extension.ant.client.inject; - -import org.eclipse.che.ide.api.extension.ExtensionGinModule; -import org.eclipse.che.ide.api.project.tree.TreeStructureProvider; -import org.eclipse.che.ide.api.project.type.wizard.ProjectWizardRegistrar; -import org.eclipse.che.ide.extension.ant.client.projecttree.AntProjectTreeStructureProvider; -import org.eclipse.che.ide.extension.ant.client.wizard.AntPageView; -import org.eclipse.che.ide.extension.ant.client.wizard.AntPageViewImpl; -import org.eclipse.che.ide.extension.ant.client.projecttree.AntNodeFactory; -import org.eclipse.che.ide.extension.ant.client.wizard.AntProjectWizardRegistrar; -import com.google.gwt.inject.client.AbstractGinModule; -import com.google.gwt.inject.client.assistedinject.GinFactoryModuleBuilder; -import com.google.gwt.inject.client.multibindings.GinMultibinder; -import com.google.inject.Singleton; - -/** @author Vladyslav Zhukovskii */ -@ExtensionGinModule -public class AntGinModule extends AbstractGinModule { - /** {@inheritDoc} */ - @Override - protected void configure() { - bind(AntPageView.class).to(AntPageViewImpl.class).in(Singleton.class); - - install(new GinFactoryModuleBuilder().build(AntNodeFactory.class)); - GinMultibinder.newSetBinder(binder(), TreeStructureProvider.class).addBinding().to(AntProjectTreeStructureProvider.class); - - GinMultibinder.newSetBinder(binder(), ProjectWizardRegistrar.class).addBinding().to(AntProjectWizardRegistrar.class); - } -} diff --git a/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/projecttree/AntFolderNode.java b/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/projecttree/AntFolderNode.java deleted file mode 100644 index 80ac7c9f299..00000000000 --- a/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/projecttree/AntFolderNode.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2015 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.ide.extension.ant.client.projecttree; - -import org.eclipse.che.ide.api.project.client.ProjectServiceClient; -import org.eclipse.che.api.project.shared.dto.ItemReference; -import org.eclipse.che.ide.api.project.tree.AbstractTreeNode; -import org.eclipse.che.ide.api.project.tree.TreeNode; -import org.eclipse.che.ide.ext.java.client.projecttree.JavaSourceFolderUtil; -import org.eclipse.che.ide.ext.java.client.projecttree.nodes.JavaFolderNode; -import org.eclipse.che.ide.rest.DtoUnmarshallerFactory; -import com.google.inject.Inject; -import com.google.inject.assistedinject.Assisted; -import com.google.web.bindery.event.shared.EventBus; - -import javax.validation.constraints.NotNull; -import org.eclipse.che.commons.annotation.Nullable; - -/** - * {@link AntFolderNode} that may contains {@link JavaFolderNode}s. - * - * @author Vladyslav Zhukovskii - */ -public class AntFolderNode extends JavaFolderNode { - - /** Create instance of {@link AntFolderNode}. */ - @Inject - protected AntFolderNode(@Assisted TreeNode parent, @Assisted ItemReference data, @Assisted AntProjectTreeStructure treeStructure, - EventBus eventBus, ProjectServiceClient projectServiceClient, - DtoUnmarshallerFactory dtoUnmarshallerFactory) { - super(parent, data, treeStructure, eventBus, projectServiceClient, dtoUnmarshallerFactory); - } - - @NotNull - @Override - public AntProjectTreeStructure getTreeStructure() { - return (AntProjectTreeStructure)super.getTreeStructure(); - } - - /** {@inheritDoc} */ - @Nullable - @Override - protected AbstractTreeNode createChildNode(ItemReference item) { - if (JavaSourceFolderUtil.isSourceFolder(item, getProject())) { - return getTreeStructure().newSourceFolderNode(this, item); - } else if ("folder".equals(item.getType())) { - return getTreeStructure().newJavaFolderNode(this, item); - } else { - return super.createChildNode(item); - } - } -} diff --git a/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/projecttree/AntNodeFactory.java b/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/projecttree/AntNodeFactory.java deleted file mode 100644 index f1e756c3201..00000000000 --- a/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/projecttree/AntNodeFactory.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2015 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.ide.extension.ant.client.projecttree; - -import org.eclipse.che.api.project.shared.dto.ItemReference; -import org.eclipse.che.api.project.shared.dto.ProjectDescriptor; -import org.eclipse.che.ide.api.project.tree.TreeNode; -import org.eclipse.che.ide.ext.java.client.projecttree.JavaNodeFactory; - -import javax.validation.constraints.NotNull; -import org.eclipse.che.commons.annotation.Nullable; - -/** - * Factory that helps to create nodes for {@link AntProjectTreeStructure}. - * - * @author Artem Zatsarynnyi - * @see JavaNodeFactory - */ -public interface AntNodeFactory extends JavaNodeFactory { - /** - * Creates a new {@link AntFolderNode} owned by the specified {@code treeStructure} - * with the specified {@code parent} and associated {@code data}. - * - * @param parent - * the parent node - * @param data - * the associated {@link ItemReference} - * @param treeStructure - * the {@link AntProjectTreeStructure} to create the node for - * @return a new {@link AntFolderNode} - */ - AntFolderNode newAntFolderNode(@NotNull TreeNode parent, - @NotNull ItemReference data, - @NotNull AntProjectTreeStructure treeStructure); - - /** - * Creates a new {@link AntProjectNode} owned by the specified {@code treeStructure} - * with the specified {@code parent} and associated {@code data}. - * - * @param parent - * the parent node - * @param data - * the associated {@link ProjectDescriptor} - * @param treeStructure - * the {@link AntProjectTreeStructure} to create the node for - * @return a new {@link AntProjectNode} - */ - AntProjectNode newAntProjectNode(@Nullable TreeNode parent, - @NotNull ProjectDescriptor data, - @NotNull AntProjectTreeStructure treeStructure); -} diff --git a/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/projecttree/AntProjectNode.java b/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/projecttree/AntProjectNode.java deleted file mode 100644 index da6ce1a9052..00000000000 --- a/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/projecttree/AntProjectNode.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2015 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.ide.extension.ant.client.projecttree; - -import org.eclipse.che.ide.api.project.client.ProjectServiceClient; -import org.eclipse.che.api.project.shared.dto.ItemReference; -import org.eclipse.che.api.project.shared.dto.ProjectDescriptor; -import org.eclipse.che.ide.api.project.tree.AbstractTreeNode; -import org.eclipse.che.ide.api.project.tree.TreeNode; -import org.eclipse.che.ide.ext.java.client.projecttree.JavaSourceFolderUtil; -import org.eclipse.che.ide.ext.java.client.projecttree.nodes.JavaProjectNode; -import org.eclipse.che.ide.rest.DtoUnmarshallerFactory; -import com.google.inject.Inject; -import com.google.inject.assistedinject.Assisted; -import com.google.web.bindery.event.shared.EventBus; - -import javax.validation.constraints.NotNull; -import org.eclipse.che.commons.annotation.Nullable; -import java.util.List; - -/** - * Node that represents Ant project. - * - * @author Vladyslav Zhukovskii - */ -public class AntProjectNode extends JavaProjectNode { - - /** Create instance of {@link AntProjectNode}. */ - @Inject - protected AntProjectNode(@Assisted TreeNode parent, - @Assisted ProjectDescriptor data, - @Assisted AntProjectTreeStructure treeStructure, - EventBus eventBus, - ProjectServiceClient projectServiceClient, - DtoUnmarshallerFactory dtoUnmarshallerFactory) { - super(parent, data, treeStructure, eventBus, projectServiceClient, dtoUnmarshallerFactory); - } - - /** {@inheritDoc} */ - @NotNull - @Override - public AntProjectTreeStructure getTreeStructure() { - return (AntProjectTreeStructure)super.getTreeStructure(); - } - - /** {@inheritDoc} */ - @Nullable - @Override - protected AbstractTreeNode createChildNode(ItemReference item, List modules) { - if (JavaSourceFolderUtil.isSourceFolder(item, getProject())) { - return getTreeStructure().newSourceFolderNode(AntProjectNode.this, item); - } else if ("folder".equals(item.getType())) { - return getTreeStructure().newJavaFolderNode(AntProjectNode.this, item); - } else { - return super.createChildNode(item, modules); - } - } -} diff --git a/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/projecttree/AntProjectTreeStructure.java b/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/projecttree/AntProjectTreeStructure.java deleted file mode 100644 index 356f8badf76..00000000000 --- a/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/projecttree/AntProjectTreeStructure.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2015 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.ide.extension.ant.client.projecttree; - -import org.eclipse.che.ide.api.project.client.ProjectServiceClient; -import org.eclipse.che.api.project.shared.dto.ItemReference; -import org.eclipse.che.ide.api.app.AppContext; -import org.eclipse.che.ide.api.app.CurrentProject; -import org.eclipse.che.ide.api.icon.IconRegistry; -import org.eclipse.che.ide.api.project.tree.AbstractTreeNode; -import org.eclipse.che.ide.api.project.tree.TreeNode; -import org.eclipse.che.ide.ext.java.client.navigation.JavaNavigationService; -import org.eclipse.che.ide.ext.java.client.projecttree.JavaTreeStructure; -import org.eclipse.che.ide.ext.java.client.projecttree.nodes.JavaFolderNode; -import org.eclipse.che.ide.rest.DtoUnmarshallerFactory; -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.web.bindery.event.shared.EventBus; - -import javax.validation.constraints.NotNull; -import java.util.ArrayList; -import java.util.List; - -/** - * Tree structure for Ant project. - * - * @author Vladyslav Zhukovskii - */ -public class AntProjectTreeStructure extends JavaTreeStructure { - - /** Create instance of {@link AntProjectTreeStructure}. */ - protected AntProjectTreeStructure(AntNodeFactory nodeFactory, EventBus eventBus, AppContext appContext, - ProjectServiceClient projectServiceClient, IconRegistry iconRegistry, - DtoUnmarshallerFactory dtoUnmarshallerFactory, JavaNavigationService service) { - super(nodeFactory, eventBus, appContext, projectServiceClient, iconRegistry, dtoUnmarshallerFactory, service); - } - - /** {@inheritDoc} */ - @Override - public void getRootNodes(@NotNull AsyncCallback>> callback) { - if (projectNode == null) { - final CurrentProject currentProject = appContext.getCurrentProject(); - if (currentProject != null) { - projectNode = getNodeFactory().newAntProjectNode(null, currentProject.getRootProject(), this); - } else { - callback.onFailure(new IllegalStateException("No project is opened.")); - return; - } - } - List> parent = new ArrayList<>(); - parent.add(projectNode); - callback.onSuccess(parent); - } - - @Override - public AntNodeFactory getNodeFactory() { - return (AntNodeFactory)nodeFactory; - } - - /** {@inheritDoc} */ - @Override - public JavaFolderNode newJavaFolderNode(@NotNull AbstractTreeNode parent, @NotNull ItemReference data) { - return getNodeFactory().newAntFolderNode(parent, data, this); - } -} diff --git a/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/projecttree/AntProjectTreeStructureProvider.java b/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/projecttree/AntProjectTreeStructureProvider.java deleted file mode 100644 index 0e80116fe39..00000000000 --- a/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/projecttree/AntProjectTreeStructureProvider.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2015 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.ide.extension.ant.client.projecttree; - -import org.eclipse.che.ide.api.project.client.ProjectServiceClient; -import org.eclipse.che.ide.api.app.AppContext; -import org.eclipse.che.ide.api.icon.IconRegistry; -import org.eclipse.che.ide.api.project.tree.TreeStructure; -import org.eclipse.che.ide.api.project.tree.TreeStructureProvider; -import org.eclipse.che.ide.ext.java.client.navigation.JavaNavigationService; -import org.eclipse.che.ide.rest.DtoUnmarshallerFactory; -import com.google.inject.Inject; -import com.google.inject.Singleton; -import com.google.web.bindery.event.shared.EventBus; - -import javax.validation.constraints.NotNull; - -/** - * Tree structure provider responsible for creating tree structure instances for project. - * - * @author Vladyslav Zhukovskii - */ -@Singleton -public class AntProjectTreeStructureProvider implements TreeStructureProvider { - public final static String ID = "ant"; - private AntNodeFactory nodeFactory; - private EventBus eventBus; - private AppContext appContext; - private IconRegistry iconRegistry; - private ProjectServiceClient projectServiceClient; - private DtoUnmarshallerFactory dtoUnmarshallerFactory; - private JavaNavigationService service; - - /** Create instance of {@link AntProjectTreeStructureProvider}. */ - @Inject - public AntProjectTreeStructureProvider(AntNodeFactory nodeFactory, EventBus eventBus, AppContext appContext, - IconRegistry iconRegistry, ProjectServiceClient projectServiceClient, - DtoUnmarshallerFactory dtoUnmarshallerFactory, JavaNavigationService service) { - this.nodeFactory = nodeFactory; - this.eventBus = eventBus; - this.appContext = appContext; - this.iconRegistry = iconRegistry; - this.projectServiceClient = projectServiceClient; - this.dtoUnmarshallerFactory = dtoUnmarshallerFactory; - this.service = service; - } - - @NotNull - @Override - public String getId() { - return ID; - } - - @Override - public TreeStructure get() { - return new AntProjectTreeStructure(nodeFactory, eventBus, appContext, projectServiceClient, iconRegistry, dtoUnmarshallerFactory, - service); - } -} diff --git a/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/wizard/AntPagePresenter.java b/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/wizard/AntPagePresenter.java deleted file mode 100644 index 15fe2e82576..00000000000 --- a/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/wizard/AntPagePresenter.java +++ /dev/null @@ -1,112 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2015 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.ide.extension.ant.client.wizard; - -import org.eclipse.che.ide.api.project.client.ProjectServiceClient; -import org.eclipse.che.api.project.shared.dto.ImportProject; -import org.eclipse.che.ide.api.project.type.wizard.ProjectWizardMode; -import org.eclipse.che.ide.api.wizard.AbstractWizardPage; -import org.eclipse.che.ide.extension.ant.shared.AntAttributes; -import org.eclipse.che.ide.rest.AsyncRequestCallback; -import org.eclipse.che.ide.rest.StringMapListUnmarshaller; -import org.eclipse.che.ide.util.loging.Log; - -import com.google.gwt.user.client.ui.AcceptsOneWidget; -import com.google.inject.Inject; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -import static org.eclipse.che.ide.api.project.type.wizard.ProjectWizardMode.CREATE; -import static org.eclipse.che.ide.api.project.type.wizard.ProjectWizardMode.UPDATE; -import static org.eclipse.che.ide.api.project.type.wizard.ProjectWizardRegistrar.PROJECT_PATH_KEY; -import static org.eclipse.che.ide.api.project.type.wizard.ProjectWizardRegistrar.WIZARD_MODE_KEY; -import static org.eclipse.che.ide.extension.ant.shared.AntAttributes.ANT_ID; - -/** - * Wizard page for Ant project. - * - * @author Vladyslav Zhukovskii - * @author Artem Zatsarynnyi - */ -public class AntPagePresenter extends AbstractWizardPage implements AntPageView.ActionDelegate { - - private final AntPageView view; - private final ProjectServiceClient projectServiceClient; - - /** Create instance of {@link AntPagePresenter}. */ - @Inject - public AntPagePresenter(AntPageView view, ProjectServiceClient projectServiceClient) { - super(); - this.view = view; - view.setDelegate(this); - this.projectServiceClient = projectServiceClient; - } - - @Override - public void init(ImportProject dataObject) { - super.init(dataObject); - - final ProjectWizardMode wizardMode = ProjectWizardMode.parse(context.get(WIZARD_MODE_KEY)); - if (CREATE == wizardMode) { - // set default values - Map> attributes = dataObject.getProject().getAttributes(); - attributes.put(AntAttributes.SOURCE_FOLDER, Arrays.asList(AntAttributes.DEF_SRC_PATH)); - attributes.put(AntAttributes.TEST_SOURCE_FOLDER, Arrays.asList(AntAttributes.DEF_TEST_SRC_PATH)); - return; - } - - if (UPDATE == wizardMode) { - projectServiceClient.estimateProject(context.get(PROJECT_PATH_KEY), ANT_ID, getEstimateProjectCallback()); - } - } - - public AsyncRequestCallback>> getEstimateProjectCallback() { - return new AsyncRequestCallback>>(new StringMapListUnmarshaller()) { - @Override - protected void onSuccess(Map> result) { - List srcFolder = result.get(AntAttributes.SOURCE_FOLDER); - srcFolder = srcFolder != null && !srcFolder.isEmpty() ? srcFolder : Arrays.asList(AntAttributes.DEF_SRC_PATH); - setAttribute(AntAttributes.SOURCE_FOLDER, srcFolder); - - - List testSrcFolder = result.get(AntAttributes.TEST_SOURCE_FOLDER); - testSrcFolder = testSrcFolder != null && !testSrcFolder.isEmpty() ? testSrcFolder : Arrays.asList(AntAttributes.DEF_TEST_SRC_PATH); - setAttribute(AntAttributes.TEST_SOURCE_FOLDER, testSrcFolder); - } - - @Override - protected void onFailure(Throwable exception) { - Log.error(getClass(), exception.getMessage()); - } - }; - } - - - /** {@inheritDoc} */ - @Override - public boolean canSkip() { - return true; - } - - /** {@inheritDoc} */ - @Override - public void go(AcceptsOneWidget container) { - container.setWidget(view); - } - - /** Sets single value of attribute of data-object. */ - private void setAttribute(String attrId, List value) { - Map> attributes = dataObject.getProject().getAttributes(); - attributes.put(attrId, value); - } -} diff --git a/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/wizard/AntPageView.java b/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/wizard/AntPageView.java deleted file mode 100644 index 78cd70f19a0..00000000000 --- a/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/wizard/AntPageView.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2015 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.ide.extension.ant.client.wizard; - -import org.eclipse.che.ide.api.mvp.View; -import com.google.inject.ImplementedBy; - -/** @author Vladyslav Zhukovskii */ -@ImplementedBy(AntPageViewImpl.class) -public interface AntPageView extends View { - public interface ActionDelegate { - } -} diff --git a/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/wizard/AntPageViewImpl.java b/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/wizard/AntPageViewImpl.java deleted file mode 100644 index 6813b410bed..00000000000 --- a/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/wizard/AntPageViewImpl.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2015 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.ide.extension.ant.client.wizard; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.uibinder.client.UiBinder; -import com.google.gwt.user.client.ui.DockLayoutPanel; -import com.google.gwt.user.client.ui.Widget; - -/** @author Vladyslav Zhukovskii */ -public class AntPageViewImpl implements AntPageView { - private static AntPageViewImplUiBinder ourUiBinder = GWT.create(AntPageViewImplUiBinder.class); - private final DockLayoutPanel rootElement; - - interface AntPageViewImplUiBinder extends UiBinder { - } - - /** Create instance of {@link AntPageViewImpl}. */ - public AntPageViewImpl() { - rootElement = ourUiBinder.createAndBindUi(this); - } - - /** {@inheritDoc} */ - @Override - public void setDelegate(ActionDelegate delegate) { - } - - /** {@inheritDoc} */ - @Override - public Widget asWidget() { - return rootElement; - } -} diff --git a/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/wizard/AntPageViewImpl.ui.xml b/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/wizard/AntPageViewImpl.ui.xml deleted file mode 100644 index e5a54cab655..00000000000 --- a/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/wizard/AntPageViewImpl.ui.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/wizard/AntProjectWizardRegistrar.java b/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/wizard/AntProjectWizardRegistrar.java deleted file mode 100644 index ce436df0aa4..00000000000 --- a/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/client/wizard/AntProjectWizardRegistrar.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2015 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.ide.extension.ant.client.wizard; - -import org.eclipse.che.api.project.shared.dto.ImportProject; -import org.eclipse.che.ide.api.project.type.wizard.ProjectWizardRegistrar; -import org.eclipse.che.ide.api.wizard.WizardPage; -import org.eclipse.che.ide.extension.ant.shared.AntAttributes; - -import com.google.inject.Inject; -import com.google.inject.Provider; - -import javax.validation.constraints.NotNull; - -import java.util.ArrayList; -import java.util.List; - -import static org.eclipse.che.ide.ext.java.shared.Constants.JAVA_CATEGORY; - -/** - * Provides information for registering Ant project type into project wizard. - * - * @author Artem Zatsarynnyi - */ -public class AntProjectWizardRegistrar implements ProjectWizardRegistrar { - private final List>> wizardPages; - - @Inject - public AntProjectWizardRegistrar(Provider antPagePresenter) { - wizardPages = new ArrayList<>(); - wizardPages.add(antPagePresenter); - } - - @NotNull - public String getProjectTypeId() { - return AntAttributes.ANT_ID; - } - - @NotNull - public String getCategory() { - return JAVA_CATEGORY; - } - - @NotNull - public List>> getWizardPages() { - return wizardPages; - } -} diff --git a/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/server/inject/AntModule.java b/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/server/inject/AntModule.java deleted file mode 100644 index 855e11ec91e..00000000000 --- a/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/server/inject/AntModule.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2015 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.ide.extension.ant.server.inject; - -import com.google.inject.AbstractModule; -import com.google.inject.multibindings.Multibinder; - -import org.eclipse.che.api.project.server.ValueProviderFactory; -import org.eclipse.che.api.project.server.handlers.ProjectHandler; -import org.eclipse.che.api.project.server.type.ProjectType; -import org.eclipse.che.ide.extension.ant.server.project.type.AntProjectGenerator; -import org.eclipse.che.ide.extension.ant.server.project.type.AntProjectType; -import org.eclipse.che.ide.extension.ant.server.project.type.AntValueProviderFactory; -import org.eclipse.che.inject.DynaModule; - -/** - * @author Vladyslav Zhukovskii - * @author Dmitry Shnurenko - */ -@DynaModule -public class AntModule extends AbstractModule { - /** {@inheritDoc} */ - @Override - protected void configure() { - Multibinder multiBinder = Multibinder.newSetBinder(binder(), ValueProviderFactory.class); - multiBinder.addBinding().to(AntValueProviderFactory.class); - - Multibinder projectTypeMultibinder = Multibinder.newSetBinder(binder(), ProjectType.class); - projectTypeMultibinder.addBinding().to(AntProjectType.class); - - Multibinder.newSetBinder(binder(), ProjectHandler.class).addBinding().to(AntProjectGenerator.class); - } -} diff --git a/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/server/project/type/AntProjectGenerator.java b/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/server/project/type/AntProjectGenerator.java deleted file mode 100644 index ef17a34c09f..00000000000 --- a/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/server/project/type/AntProjectGenerator.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2015 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.ide.extension.ant.server.project.type; - -import org.eclipse.che.api.core.ConflictException; -import org.eclipse.che.api.core.ForbiddenException; -import org.eclipse.che.api.core.ServerException; -import org.eclipse.che.api.project.server.FolderEntry; -import org.eclipse.che.api.project.server.handlers.CreateProjectHandler; -import org.eclipse.che.api.project.server.type.AttributeValue; -import org.eclipse.che.ide.ant.tools.buildfile.BuildFileGenerator; -import org.eclipse.che.ide.extension.ant.shared.AntAttributes; - -import java.util.Map; - -/** - * Generates Ant-project structure. - * - * @author Artem Zatsarynnyi - */ -public class AntProjectGenerator implements CreateProjectHandler { - - @Override - public String getProjectType() { - return AntAttributes.ANT_ID; - } - - @Override - public void onCreateProject(FolderEntry baseFolder, Map attributes, Map options) - throws ForbiddenException, ConflictException, ServerException { - final String buildXmlContent = new BuildFileGenerator(baseFolder.getName()).getBuildFileContent(); - baseFolder.createFile(AntAttributes.BUILD_FILE, buildXmlContent.getBytes(), "text/xml"); - - AttributeValue sourceFolders = attributes.get(AntAttributes.SOURCE_FOLDER); - if (sourceFolders != null) { - baseFolder.createFolder(sourceFolders.getString()); - } - AttributeValue testSourceFolders = attributes.get(AntAttributes.TEST_SOURCE_FOLDER); - if (testSourceFolders != null) { - baseFolder.createFolder(testSourceFolders.getString()); - } - } -} diff --git a/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/server/project/type/AntProjectType.java b/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/server/project/type/AntProjectType.java deleted file mode 100644 index c53b7338cf1..00000000000 --- a/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/server/project/type/AntProjectType.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2015 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.ide.extension.ant.server.project.type; - -import org.eclipse.che.api.project.server.type.ProjectType; -import org.eclipse.che.ide.ext.java.server.projecttype.JavaProjectType; -import org.eclipse.che.ide.extension.ant.shared.AntAttributes; -import com.google.inject.Inject; -import com.google.inject.Singleton; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Arrays; - -import static org.eclipse.che.ide.api.project.type.RunnerCategory.JAVA; - -/** - * @author Vladyslav Zhukovskii - * @author Dmitry Shnurenko - */ -@Singleton -public class AntProjectType extends ProjectType { - private static final Logger LOG = LoggerFactory.getLogger(AntProjectType.class); - - /** Create instance of {@link AntProjectType}. */ - @Inject - public AntProjectType(AntValueProviderFactory antValueProviderFactory, - JavaProjectType javaProjectType) { - super(AntAttributes.ANT_ID, AntAttributes.ANT_NAME, true, false); - addParent(javaProjectType); - setDefaultBuilder("ant"); - addVariableDefinition(AntAttributes.SOURCE_FOLDER, "", true, antValueProviderFactory); - addVariableDefinition(AntAttributes.TEST_SOURCE_FOLDER, "", true, antValueProviderFactory); - addRunnerCategories(Arrays.asList(JAVA.toString())); - } -} diff --git a/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/server/project/type/AntValueProviderFactory.java b/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/server/project/type/AntValueProviderFactory.java deleted file mode 100644 index eba1c318987..00000000000 --- a/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/server/project/type/AntValueProviderFactory.java +++ /dev/null @@ -1,124 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2015 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.ide.extension.ant.server.project.type; - -import org.eclipse.che.api.core.ForbiddenException; -import org.eclipse.che.api.core.ServerException; -import org.eclipse.che.api.project.server.FolderEntry; -import org.eclipse.che.api.project.server.ValueProvider; -import org.eclipse.che.api.project.server.ValueProviderFactory; -import org.eclipse.che.api.project.server.ValueStorageException; -import org.eclipse.che.api.project.server.VirtualFileEntry; -import org.eclipse.che.api.vfs.server.VirtualFile; -import org.eclipse.che.ide.ant.tools.AntUtils; - -import java.io.IOException; -import java.nio.file.Paths; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import static org.eclipse.che.ide.extension.ant.shared.AntAttributes.BUILD_FILE; -import static org.eclipse.che.ide.extension.ant.shared.AntAttributes.DEF_TEST_SRC_PATH; -import static org.eclipse.che.ide.extension.ant.shared.AntAttributes.SOURCE_FOLDER; -import static org.eclipse.che.ide.extension.ant.shared.AntAttributes.TEST_SOURCE_FOLDER; - -/** - * Provide value for specific property from Ant project. - * - * @author Vladyslav Zhukovskii - */ -public class AntValueProviderFactory implements ValueProviderFactory { - - /** - * Try to find build.xml in project root directory and parse it into {@link org.apache.tools.ant.Project} to ba able to obtain various - * information from Ant build file. - * - * @param project - * current opened project in Codenvy - * @return {@link org.apache.tools.ant.Project} object of parsed build file - * @throws ServerException - * if error occurred while getting file on server side - * @throws ForbiddenException - * if access to build file is forbidden - * @throws ValueStorageException - */ - protected VirtualFile getBuildXml(FolderEntry project) throws ServerException, ForbiddenException, ValueStorageException { - VirtualFileEntry buildXml = project.getChild(BUILD_FILE); - if (buildXml == null) { - throw new ValueStorageException(BUILD_FILE + " does not exist."); - } - return buildXml.getVirtualFile(); - } - - /** @return instance of {@link ValueStorageException} with specified message. */ - protected ValueStorageException readException(Exception e) { - return new ValueStorageException("Can't read build.xml: " + e.getMessage()); - } - - /** @return instance of {@link ValueStorageException} with specified message. */ - protected ValueStorageException writeException(Exception e) { - return new ValueStorageException("Can't write build.xml: " + e.getMessage()); - } - - @Override - public ValueProvider newInstance(FolderEntry projectFolder) { - return new AntValueProvider(projectFolder); - } - - - - /** Provide access to value of various information from {@link org.apache.tools.ant.Project}. */ - protected class AntValueProvider implements ValueProvider { - /** IDE project. */ - private final FolderEntry projectFolder; - - /** Create instance of {@link AntValueProvider}. */ - protected AntValueProvider(FolderEntry projectFolder) { - this.projectFolder = projectFolder; - } - - /** {@inheritDoc} */ - @Override - public List getValues(String attributeName) throws ValueStorageException { - try { - org.apache.tools.ant.Project antProject = AntUtils.readProject(getBuildXml(projectFolder)); - if (SOURCE_FOLDER.equals(attributeName)) { - String srcDir = antProject.getProperty("src.dir"); - if (srcDir == null) { - srcDir = DEF_TEST_SRC_PATH; - } else { - // Don't show absolute path (seems Ant parser resolves it automatically). User shouldn't know any absolute paths on our - // file system. This is temporary solution, this shouldn't be actual when get rid form ant parsers for build.xml files. - final java.nio.file.Path relPath = antProject.getBaseDir().toPath().relativize(Paths.get(srcDir)); - srcDir = relPath.toString(); - } - return Arrays.asList(srcDir); - } else if(TEST_SOURCE_FOLDER.equals(attributeName)) { - String testDir = antProject.getProperty("test.dir"); - if (testDir == null) { - testDir = DEF_TEST_SRC_PATH; - } - return Arrays.asList(testDir); - } - return Collections.emptyList(); - } catch (IOException | ForbiddenException | ServerException e) { - throw readException(e); - } - } - - @Override - public void setValues(String attributeName, List value) throws ValueStorageException { - - } - - } -} diff --git a/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/shared/AntAttributes.java b/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/shared/AntAttributes.java deleted file mode 100644 index f083dee0ceb..00000000000 --- a/plugins/plugin-java/che-plugin-java-ext-ant/src/main/java/org/eclipse/che/ide/extension/ant/shared/AntAttributes.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2015 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.ide.extension.ant.shared; - -/** @author Vladyslav Zhukovskii */ -public interface AntAttributes { - final String ANT_ID = "ant"; - final String ANT_NAME = "Ant Project"; - - final String ANT_GENERATOR_ID = "ant"; - - final String SOURCE_FOLDER = "ant.source.folder"; - final String TEST_SOURCE_FOLDER = "ant.test.source.folder"; - - final String DEF_SRC_PATH = "src"; - final String DEF_TEST_SRC_PATH = "test"; - - final String BUILD_FILE = "build.xml"; -} diff --git a/plugins/plugin-java/che-plugin-java-ext-ant/src/main/resources/org/eclipse/che/ide/extension/ant/Ant.gwt.xml b/plugins/plugin-java/che-plugin-java-ext-ant/src/main/resources/org/eclipse/che/ide/extension/ant/Ant.gwt.xml deleted file mode 100644 index ea323928393..00000000000 --- a/plugins/plugin-java/che-plugin-java-ext-ant/src/main/resources/org/eclipse/che/ide/extension/ant/Ant.gwt.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/plugins/plugin-java/che-plugin-java-ext-ant/src/test/resources/test-build.xml b/plugins/plugin-java/che-plugin-java-ext-ant/src/test/resources/test-build.xml deleted file mode 100644 index ef88f3754d1..00000000000 --- a/plugins/plugin-java/che-plugin-java-ext-ant/src/test/resources/test-build.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - -