org.codehaus.mojo.weblogic.DeployMojo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of weblogic-maven-plugin Show documentation
Show all versions of weblogic-maven-plugin Show documentation
This plugin will support various tasks within the Weblogic 8.1,
9.x, 10.x and 12.x environment. This version starts to support weblogic 10 and
11. The mojo supports such tasks as deploy,
undeploy,clientgen,servicegen, and appc are supported as well as
many others. The plugin uses exposed API's that are subject to
change but have been tested in 8.1 SP 4-6 and 9.0 - 9.2 MP3, 10.x.
There are two versions of the plugin to support the two
environments based on differences in the JDK. The 9.x version is
currently being refactored to support the standard JSR supported
deployment interface. The code used in the plugin has been
contributed to the Cargo project however to date has not be
integrated into the codebase. Please feel free to suggest
improvements or help support this plugin effort.
The newest version!
package org.codehaus.mojo.weblogic;
/*
* Copyright 2006 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.
*/
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.tools.ant.Project;
import org.codehaus.mojo.weblogic.util.WeblogicMojoUtilities;
import weblogic.ant.taskdefs.management.WLDeploy;
import java.io.File;
/**
* Deploy an artifact to Weblogic servers(s) or cluster(s).
*
* @author Scott Ryan
* @version $Id: DeployMojo.java 17525 2012-09-16 13:39:50Z jonnio $
* @description Deploy an artifact (war, ear, etc) to a target(s) which can be servers or clusters.
* @goal deploy
*/
public class DeployMojo
extends DeployMojoBase {
/**
* This method will perform the deployment of artifact to the targets.
*
* @throws MojoExecutionException Thrown if we fail to obtain a Weblogic deployment instance.
*/
public void execute() throws MojoExecutionException {
super.execute();
if (getLog().isInfoEnabled()) {
getLog().info("Weblogic Deployment beginning with parameters " + this.toString());
}
final File targetSource;
try {
targetSource = new File(this.getArtifactPath());
} catch (IllegalArgumentException e) {
//this means we don't have a source...exit quitely
return;
}
try {
final WLDeploy deployer = new WLDeploy();
final Project project = new Project();
project.setName("deploy");
project.addBuildListener(this.getDefaultLogger());
project.setSystemProperties();
deployer.setProject(project);
deployer.setRemote(this.isRemote());
deployer.setVerbose(this.isVerbose());
deployer.setAdminUrl(WeblogicMojoUtilities.getAdminUrl(this.getAdminServerProtocol(),
this.getAdminServerHostName(), this.getAdminServerPort()));
deployer.setNoStage(this.isStage());
deployer.setUser(this.getUserId());
deployer.setPassword(this.getPassword());
deployer.setName(this.getName());
deployer.setTargets(this.getTargetNames());
deployer.setSource(targetSource);
deployer.setAction("deploy");
deployer.setDebug(this.isDebug());
deployer.setEnableSecurityValidation(true);
deployer.setUpload(this.isUpload());
deployer.execute();
} catch (Exception ex) {
getLog().error("Exception encountered during deployment ", ex);
throw new MojoExecutionException("Exception encountered during deployment", ex);
}
if (getLog().isInfoEnabled()) {
getLog().info("Weblogic Deployment successful ");
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy