[14627] | 1 | /*
|
---|
| 2 | * Copyright 2001-2004 The Apache Software Foundation
|
---|
| 3 | *
|
---|
| 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
| 5 | * you may not use this file except in compliance with the License.
|
---|
| 6 | * You may obtain a copy of the License at
|
---|
| 7 | *
|
---|
| 8 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
| 9 | *
|
---|
| 10 | * Unless required by applicable law or agreed to in writing, software
|
---|
| 11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
| 13 | * See the License for the specific language governing permissions and
|
---|
| 14 | * limitations under the License.
|
---|
| 15 | *
|
---|
| 16 | */
|
---|
| 17 |
|
---|
| 18 | package org.apache.tools.ant.taskdefs.optional.jsp.compilers;
|
---|
| 19 |
|
---|
| 20 | import java.io.File;
|
---|
| 21 | import java.util.Enumeration;
|
---|
| 22 | import java.util.Vector;
|
---|
| 23 | import org.apache.tools.ant.Project;
|
---|
| 24 | import org.apache.tools.ant.taskdefs.optional.jsp.JspC;
|
---|
| 25 | import org.apache.tools.ant.types.CommandlineJava;
|
---|
| 26 |
|
---|
| 27 | /**
|
---|
| 28 | * This is the default implementation for the JspCompilerAdapter interface.
|
---|
| 29 | * This is currently very light on the ground since only one compiler type is
|
---|
| 30 | * supported.
|
---|
| 31 | *
|
---|
| 32 | */
|
---|
| 33 | public abstract class DefaultJspCompilerAdapter
|
---|
| 34 | implements JspCompilerAdapter {
|
---|
| 35 |
|
---|
| 36 | private static String lSep = System.getProperty("line.separator");
|
---|
| 37 |
|
---|
| 38 | /**
|
---|
| 39 | * Logs the compilation parameters, adds the files to compile and logs the
|
---|
| 40 | * "niceSourceList"
|
---|
| 41 | */
|
---|
| 42 | protected void logAndAddFilesToCompile(JspC jspc,
|
---|
| 43 | Vector compileList,
|
---|
| 44 | CommandlineJava cmd) {
|
---|
| 45 | jspc.log("Compilation " + cmd.describeJavaCommand(),
|
---|
| 46 | Project.MSG_VERBOSE);
|
---|
| 47 |
|
---|
| 48 | StringBuffer niceSourceList = new StringBuffer("File");
|
---|
| 49 | if (compileList.size() != 1) {
|
---|
| 50 | niceSourceList.append("s");
|
---|
| 51 | }
|
---|
| 52 | niceSourceList.append(" to be compiled:");
|
---|
| 53 |
|
---|
| 54 | niceSourceList.append(lSep);
|
---|
| 55 |
|
---|
| 56 | Enumeration e = compileList.elements();
|
---|
| 57 | while (e.hasMoreElements()) {
|
---|
| 58 | String arg = (String) e.nextElement();
|
---|
| 59 | cmd.createArgument().setValue(arg);
|
---|
| 60 | niceSourceList.append(" " + arg + lSep);
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 | jspc.log(niceSourceList.toString(), Project.MSG_VERBOSE);
|
---|
| 64 | }
|
---|
| 65 |
|
---|
| 66 | /**
|
---|
| 67 | * our owner
|
---|
| 68 | */
|
---|
| 69 | protected JspC owner;
|
---|
| 70 |
|
---|
| 71 | /**
|
---|
| 72 | * set the owner
|
---|
| 73 | */
|
---|
| 74 | public void setJspc(JspC owner) {
|
---|
| 75 | this.owner = owner;
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | /** get the owner
|
---|
| 79 | * @return the owner; should never be null
|
---|
| 80 | */
|
---|
| 81 | public JspC getJspc() {
|
---|
| 82 | return owner;
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 |
|
---|
| 86 | /**
|
---|
| 87 | * add an argument oneple to the argument list, if the value aint null
|
---|
| 88 | *
|
---|
| 89 | * @param argument The argument
|
---|
| 90 | */
|
---|
| 91 | protected void addArg(CommandlineJava cmd, String argument) {
|
---|
| 92 | if (argument != null && argument.length() != 0) {
|
---|
| 93 | cmd.createArgument().setValue(argument);
|
---|
| 94 | }
|
---|
| 95 | }
|
---|
| 96 |
|
---|
| 97 |
|
---|
| 98 | /**
|
---|
| 99 | * add an argument tuple to the argument list, if the value aint null
|
---|
| 100 | *
|
---|
| 101 | * @param argument The argument
|
---|
| 102 | * @param value the parameter
|
---|
| 103 | */
|
---|
| 104 | protected void addArg(CommandlineJava cmd, String argument, String value) {
|
---|
| 105 | if (value != null) {
|
---|
| 106 | cmd.createArgument().setValue(argument);
|
---|
| 107 | cmd.createArgument().setValue(value);
|
---|
| 108 | }
|
---|
| 109 | }
|
---|
| 110 |
|
---|
| 111 | /**
|
---|
| 112 | * add an argument tuple to the arg list, if the file parameter aint null
|
---|
| 113 | *
|
---|
| 114 | * @param argument The argument
|
---|
| 115 | * @param file the parameter
|
---|
| 116 | */
|
---|
| 117 | protected void addArg(CommandlineJava cmd, String argument, File file) {
|
---|
| 118 | if (file != null) {
|
---|
| 119 | cmd.createArgument().setValue(argument);
|
---|
| 120 | cmd.createArgument().setFile(file);
|
---|
| 121 | }
|
---|
| 122 | }
|
---|
| 123 |
|
---|
| 124 | /**
|
---|
| 125 | * ask if compiler can sort out its own dependencies
|
---|
| 126 | * @return true if the compiler wants to do its own
|
---|
| 127 | * depends
|
---|
| 128 | */
|
---|
| 129 | public boolean implementsOwnDependencyChecking() {
|
---|
| 130 | return false;
|
---|
| 131 | }
|
---|
| 132 |
|
---|
| 133 | /**
|
---|
| 134 | * get our project
|
---|
| 135 | * @return owner project data
|
---|
| 136 | */
|
---|
| 137 | public Project getProject() {
|
---|
| 138 | return getJspc().getProject();
|
---|
| 139 | }
|
---|
| 140 | }
|
---|
| 141 |
|
---|