/* * Copyright 2000-2004 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package org.apache.tools.ant.taskdefs; import java.io.File; import java.io.FileWriter; import java.io.IOException; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; import org.apache.tools.ant.types.EnumeratedAttribute; /** * Writes a message to the Ant logging facilities. * * @since Ant 1.1 * * @ant.task category="utility" */ public class Notify extends Task { protected File lockDir = null; protected String name = "default"; /** * Does the work. * * @exception BuildException if something goes wrong with the build */ public void execute() throws BuildException { new File(lockDir, name+".lck").delete(); } /** * Message to write. * * @param msg Sets the name for this lock... should be unique for this ant instance */ public void setName(String name) { this.name = name; } /** * Directory to put locks into * @param lockDir the file to write to, if not set, echo to * standard output */ public void setLockDir(File lockDir) { this.lockDir = lockDir; } /** * Ensure we have a consistent and legal set of attributes, and set * any internal flags necessary based on different combinations * of attributes. * @exception BuildException if an error occurs */ protected void validateAttributes() throws BuildException { if (lockDir == null || !lockDir.exists()) { throw new BuildException("lockDir must be specified and must exist"); } if (name == null || name.trim().equals("")) { throw new BuildException("a name must be provided"); } } }