Package org.apache.tools.ant.types

Examples of org.apache.tools.ant.types.Path$PathElement


   */
  public Path createSrc()
  {
    if (src == null)
    {
      src = new Path(getProject());
    }
   
    return src.createPath();
  }
View Full Code Here


   */
  public Path createClasspath()
  {
    if (classpath == null)
    {
      classpath = new Path(getProject());
    }
   
    return classpath.createPath();
  }
View Full Code Here

     */
    private Path getClassPath()
    {
        if( m_classpath == null )
        {
            m_classpath = new Path( getProject() );
        }
        return m_classpath;
    }
View Full Code Here

     *
     * @return the resulting created path
     */
    public Path createClasspath() {
        if (this.classpath == null) {
            this.classpath = new Path(getProject());
        }
        return this.classpath.createPath();
    }
View Full Code Here

                }

                // if there are no groovy statements between the enclosing Groovy tags
                // then read groovy statements in from a text file using the src attribute
                if (command == null || command.trim().length() == 0) {
                    createClasspath().add(new Path(getProject(), srcFile.getParentFile().getCanonicalPath()));
                    command = getText(new BufferedReader(new FileReader(srcFile)));
                }

                if (command != null) {
                    execGroovy(command, out);
View Full Code Here

        groovy.setProject(builder.getProject());
        groovy.parseAndRunScript(shell, null, null, null, new File(args[0]), builder);
    }

    private void createClasspathParts() {
        Path path;
        if (classpath != null) {
            path = super.createClasspath();
            path.setPath(classpath.toString());
        }

        if (includeAntRuntime) {
            path = super.createClasspath();
            path.setPath(System.getProperty("java.class.path"));
        }
        String groovyHome = null;
        final String[] strings = getSysProperties().getVariables();
        if (strings != null) {
            for (String prop : strings) {
                if (prop.startsWith("-Dgroovy.home=")) {
                    groovyHome = prop.substring("-Dgroovy.home=".length());
                }
            }
        }
        if (groovyHome == null) {
            groovyHome = System.getProperty("groovy.home");
        }
        if (groovyHome == null) {
            groovyHome = System.getenv("GROOVY_HOME");
        }
        if (groovyHome == null) {
            throw new IllegalStateException("Neither ${groovy.home} nor GROOVY_HOME defined.");
        }
        File jarDir = new File(groovyHome, "embeddable");
        if (!jarDir.exists()) {
            throw new IllegalStateException("GROOVY_HOME incorrectly defined. No embeddable directory found in: " + groovyHome);
        }
        final File[] files = jarDir.listFiles();
        for (File file : files) {
            try {
                log.debug("Adding jar to classpath: " + file.getCanonicalPath());
            } catch (IOException e) {
                // ignore
            }
            path = super.createClasspath();
            path.setLocation(file);
        }
    }
View Full Code Here

     *
     * @return a nested src element.
     */
    public Path createSrc() {
        if (src == null) {
            src = new Path(getProject());
        }
        return src.createPath();
    }
View Full Code Here

     *
     * @return a sourcepath to be configured
     */
    public Path createSourcepath() {
        if (compileSourcepath == null) {
            compileSourcepath = new Path(getProject());
        }
        return compileSourcepath.createPath();
    }
View Full Code Here

     *
     * @return a class path to be configured
     */
    public Path createClasspath() {
        if (compileClasspath == null) {
            compileClasspath = new Path(getProject());
        }
        return compileClasspath.createPath();
    }
View Full Code Here

                    for (File srcFile : compileList) {
                        log(srcFile.getAbsolutePath());
                    }
                }

                Path classpath = getClasspath() != null ? getClasspath() : new Path(getProject());
                // extract joint options, some get pushed up...
                List<String> jointOptions = new ArrayList<String>();
                if (jointCompilation) {
                    RuntimeConfigurable rc = javac.getRuntimeConfigurableWrapper();
                    for (Iterator i = rc.getAttributeMap().entrySet().iterator(); i.hasNext();) {
                        final Map.Entry e = (Map.Entry) i.next();
                        final String key = e.getKey().toString();
                        final String value = getProject().replaceProperties(e.getValue().toString());
                        if (key.contains("debug")) {
                            String level = "";
                            if (javac.getDebugLevel() != null) {
                                level = ":" + javac.getDebugLevel();
                            }
                            jointOptions.add("-Fg" + level);
                        } else if (key.contains("debugLevel")) {
                            // ignore, taken care of in debug
                        } else if ((key.contains("nowarn"))
                                || (key.contains("verbose"))
                                || (key.contains("deprecation"))) {
                            // false is default, so something to do only in true case
                            if ("on".equalsIgnoreCase(value) || "true".equalsIgnoreCase(value) || "yes".equalsIgnoreCase("value"))
                                jointOptions.add("-F" + key);
                        } else if (key.contains("classpath")) {
                            classpath.add(javac.getClasspath());
                        } else if ((key.contains("depend"))
                                || (key.contains("extdirs"))
                                || (key.contains("encoding"))
                                || (key.contains("source"))
                                || (key.contains("target"))
                                || (key.contains("verbose"))) { // TODO remove extra verbose?
                            jointOptions.add("-J" + key + "=" + value);
                        } else {
                            log("The option " + key + " cannot be set on the contained <javac> element. The option will be ignored", Project.MSG_WARN);
                        }
                        // includes? excludes?
                    }
                    // ant's <javac> supports nested <compilerarg value=""> elements (there can be multiple of them)
                    // for additional options to be passed to javac.
                    Enumeration children = rc.getChildren();
                    while (children.hasMoreElements()) {
                        RuntimeConfigurable childrc = (RuntimeConfigurable) children.nextElement();
                        if (childrc.getElementTag().equals("compilerarg")) {
                            for (Iterator i = childrc.getAttributeMap().entrySet().iterator(); i.hasNext();) {
                                final Map.Entry e = (Map.Entry) i.next();
                                final String key = e.getKey().toString();
                                if (key.equals("value")) {
                                    final String value = getProject().replaceProperties(e.getValue().toString());
                                    StringTokenizer st = new StringTokenizer(value, " ");
                                    while (st.hasMoreTokens()) {
                                        String optionStr = st.nextToken();
                                        jointOptions.add(optionStr.replace("-X", "-FX"));
                                    }
                                }
                            }
                        }
                    }
                }

                String separator = System.getProperty("file.separator");
                List<String> commandLineList = new ArrayList<String>();

                if (fork) {
                    String javaHome;
                    if (forkJDK != null) {
                        javaHome = forkJDK.getPath();
                    } else {
                        javaHome = System.getProperty("java.home");
                    }
                    if (includeAntRuntime) {
                        classpath.addExisting((new Path(getProject())).concatSystemClasspath("last"));
                    }
                    if (includeJavaRuntime) {
                        classpath.addJavaRuntime();
                    }

                    commandLineList.add(javaHome + separator + "bin" + separator + "java");
                    commandLineList.add("-classpath");
                    commandLineList.add(classpath.toString());

                    final String fileEncodingProp = System.getProperty("file.encoding");
                    if ((fileEncodingProp != null) && !fileEncodingProp.equals("")) {
                        commandLineList.add("-Dfile.encoding=" + fileEncodingProp);
                    }
                    if (targetBytecode != null) {
                        commandLineList.add("-Dgroovy.target.bytecode=" + targetBytecode);
                    }

                    if ((memoryInitialSize != null) && !memoryInitialSize.equals("")) {
                        commandLineList.add("-Xms" + memoryInitialSize);
                    }
                    if ((memoryMaximumSize != null) && !memoryMaximumSize.equals("")) {
                        commandLineList.add("-Xmx" + memoryMaximumSize);
                    }
                    if (!"*.groovy".equals(getScriptExtension())) {
                        String tmpExtension = getScriptExtension();
                        if (tmpExtension.startsWith("*.")) tmpExtension = tmpExtension.substring(1);
                        commandLineList.add("-Dgroovy.default.scriptExtension=" + tmpExtension);
                    }
                    commandLineList.add("org.codehaus.groovy.tools.FileSystemCompiler");
                }
                commandLineList.add("--classpath");
                commandLineList.add(classpath.toString());
                if (jointCompilation) {
                    commandLineList.add("-j");
                    commandLineList.addAll(jointOptions);
                }
                commandLineList.add("-d");
View Full Code Here

TOP

Related Classes of org.apache.tools.ant.types.Path$PathElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.