All Downloads are FREE. Search and download functionalities are using the official Maven repository.

protoj.lang.command.PublishCommand Maven / Gradle / Ivy

The newest version!
/**
 * Copyright 2009 Ashley Williams
 * 
 * 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 protoj.lang.command;

import joptsimple.OptionSet;
import joptsimple.OptionSpec;
import protoj.lang.Command;
import protoj.lang.CommandStore;
import protoj.lang.PublishFeature;
import protoj.lang.StandardProject;

/**
 * Publishes project artifacts to a maven repository by performing a maven
 * deploy. The repository url and additional configuration must be performed
 * in-code. The following options are supported:
 * 
    *
  1. -artifact: the name of the artifact to be published. The artifacts * directory is checked for classes, source and javadoc containing artifacts * that match the name. If this option isn't specified then all discovered * artifacts are published.
  2. *
  3. -user: used if the publish command has been configured for a remote * protocol such as scp.
  4. *
  5. -key: the path to the private key for scp key-based authentication. If * not specified then the default key location is used if it exists.
  6. *
  7. -password: the password for scp transport if specified.
  8. *
  9. -passphrase: the passphrase for scp key-based authentication. Can be left * out if there is no passphrase for the given key.
  10. *
* * Example: publish Example: "publish -user bob" Example: * "publish -user bob -key ~/.ssh/myprivatekey" * * @author Ashley Williams * */ public final class PublishCommand { public final class Body implements Runnable { public void run() { OptionSet options = getDelegate().getOptions(); String user = options.valueOf(userOption); String key = options.valueOf(keyOption); String password = options.valueOf(passwordOption); String passphrase = options.valueOf(passphraseOption); PublishFeature feature = project.getPublishFeature(); if (options.has(artifactOption)) { String artifact = options.valueOf(artifactOption); feature.deploy(artifact, user, key, password, passphrase); } else { feature.deployAll(user, key, password, passphrase); } } } /** * Provides the basic command functionality. */ private Command delegate; private OptionSpec artifactOption; private StandardProject project; private OptionSpec userOption; private OptionSpec keyOption; private OptionSpec passwordOption; private OptionSpec passphraseOption; public PublishCommand(StandardProject project) { this.project = project; CommandStore store = project.getCommandStore(); delegate = store.addCommand("publish", "16m", new Body()); delegate.initHelpResource("/protoj-common/language/english/publish.txt"); delegate.initAliases("deploy"); artifactOption = delegate.getParser().accepts(getArtifactOption()) .withRequiredArg(); userOption = delegate.getParser().accepts(getUserOption()) .withRequiredArg(); keyOption = delegate.getParser().accepts(getKeyOption()) .withRequiredArg(); passwordOption = delegate.getParser().accepts(getPasswordOption()) .withRequiredArg(); passphraseOption = delegate.getParser().accepts(getPassphraseOption()) .withRequiredArg(); } public String getPassphraseOption() { return "passphrase"; } public String getPasswordOption() { return "password"; } public String getKeyOption() { return "key"; } public String getUserOption() { return "user"; } public String getArtifactOption() { return "artifact"; } public Command getDelegate() { return delegate; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy