/*-------------------------------------------------------------------------- * Copyright 2008 utgenome.org * * 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. *--------------------------------------------------------------------------*/ //-------------------------------------- // utgb-shell Project // // Deploy.java // Since: Jan 14, 2008 // // $URL$ // $Author$ //-------------------------------------- package org.utgenome.shell; import java.io.File; import org.utgenome.config.TrackConfiguration; import org.xerial.util.cui.OptionParser; import org.xerial.util.cui.OptionParserException; public class Deploy extends UTGBShellSubCommandBase { private enum Opt { // MANAGER_URL, USER, CONTEXT_PATH, DONOT_GENERATE_CONTEXT_XML, }; private OptionParser optionParser = new OptionParser(); public Deploy() { // optionParser.addOptionWithArgument(Opt.MANAGER_URL, "m", "manager", "URL", "tomcat // manager url. default = // http://localhost:8080/manager"); // optionParser.addOptionWithArgument(Opt.USER, "u", "user", "USER_NAME", "user name"); optionParser.addOptionWithArgument(Opt.CONTEXT_PATH, "p", "path", "CONTEXT_PATH", "web application context path"); optionParser.addOption(Opt.DONOT_GENERATE_CONTEXT_XML, "n", "nocontext", "do not generate context.xml"); } @Override public void execute(String[] args) throws UTGBShellException { if (!isInProjectRoot()) throw new UTGBShellException("not in the project root"); TrackConfiguration config = loadTrackConfiguration(); try { optionParser.parse(args); // generate context.xml file if (!optionParser.isSet(Opt.DONOT_GENERATE_CONTEXT_XML)) createContextXML(optionParser.isSet(Opt.CONTEXT_PATH) ? optionParser.getValue(Opt.CONTEXT_PATH) : config.getProjectName(), new File("") .getAbsolutePath(), false); Maven.runMaven("tomcat:deploy"); } catch (OptionParserException e) { throw new UTGBShellException(e); } } @Override public String name() { return "deploy"; } public String getDetailedDescription() { return loadUsage("help-deploy.txt"); } public String getOneLinerDescription() { return "deploy the war file to the remote tomcat server"; } public String getOptionList() { return optionParser.helpMessage(); } }