forked from OpenLiberty/ci.ant
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OpenLiberty#3: Split server task into operation-specific tasks
- Loading branch information
1 parent
efb665d
commit f0c1643
Showing
11 changed files
with
897 additions
and
442 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
src/main/java/net/wasdev/wlp/ant/servertasks/ServerCreate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* (C) Copyright IBM Corporation 2014, 2015. | ||
* | ||
* 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 net.wasdev.wlp.ant.servertasks; | ||
|
||
import org.apache.tools.ant.BuildException; | ||
|
||
import net.wasdev.wlp.ant.ServerTask; | ||
|
||
public class ServerCreate extends ServerTask { | ||
@Override | ||
public void execute() { | ||
initTask(); | ||
|
||
try { | ||
doCreate(); | ||
} catch (Exception e) { | ||
throw new BuildException(e); | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/net/wasdev/wlp/ant/servertasks/ServerDebug.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* (C) Copyright IBM Corporation 2014, 2015. | ||
* | ||
* 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 net.wasdev.wlp.ant.servertasks; | ||
|
||
import java.util.List; | ||
|
||
import org.apache.tools.ant.BuildException; | ||
|
||
import net.wasdev.wlp.ant.ServerTask; | ||
|
||
public class ServerDebug extends ServerTask { | ||
@Override | ||
public void execute() { | ||
initTask(); | ||
|
||
try { | ||
List<String> command = getInitialCommand("debug"); | ||
addCleanOption(command); | ||
processBuilder.command(command); | ||
Process p = processBuilder.start(); | ||
checkReturnCode(p, processBuilder.command().toString(), ReturnCode.OK.getValue()); | ||
|
||
} catch (Exception e) { | ||
throw new BuildException(e); | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/net/wasdev/wlp/ant/servertasks/ServerDump.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* (C) Copyright IBM Corporation 2014, 2015. | ||
* | ||
* 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 net.wasdev.wlp.ant.servertasks; | ||
|
||
import java.util.List; | ||
|
||
import org.apache.tools.ant.BuildException; | ||
|
||
import net.wasdev.wlp.ant.ServerTask; | ||
|
||
public class ServerDump extends ServerTask { | ||
@Override | ||
public void execute() { | ||
initTask(); | ||
|
||
try { | ||
List<String> command = getInitialCommand("dump"); | ||
addArchiveOption(command); | ||
addIncludeOption(command); | ||
processBuilder.command(command); | ||
Process p = processBuilder.start(); | ||
checkReturnCode(p, processBuilder.command().toString(), ReturnCode.OK.getValue()); | ||
|
||
} catch (Exception e) { | ||
throw new BuildException(e); | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/net/wasdev/wlp/ant/servertasks/ServerJavaDump.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* (C) Copyright IBM Corporation 2014, 2015. | ||
* | ||
* 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 net.wasdev.wlp.ant.servertasks; | ||
|
||
import java.util.List; | ||
|
||
import org.apache.tools.ant.BuildException; | ||
|
||
import net.wasdev.wlp.ant.ServerTask; | ||
|
||
public class ServerJavaDump extends ServerTask { | ||
@Override | ||
public void execute() { | ||
initTask(); | ||
|
||
try { | ||
List<String> command = getInitialCommand("javadump"); | ||
addIncludeOption(command); | ||
processBuilder.command(command); | ||
Process p = processBuilder.start(); | ||
checkReturnCode(p, processBuilder.command().toString(), ReturnCode.OK.getValue()); | ||
|
||
} catch (Exception e) { | ||
throw new BuildException(e); | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/net/wasdev/wlp/ant/servertasks/ServerPackage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* (C) Copyright IBM Corporation 2014, 2015. | ||
* | ||
* 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 net.wasdev.wlp.ant.servertasks; | ||
|
||
import java.util.List; | ||
|
||
import org.apache.tools.ant.BuildException; | ||
|
||
import net.wasdev.wlp.ant.ServerTask; | ||
|
||
public class ServerPackage extends ServerTask { | ||
@Override | ||
public void execute() { | ||
initTask(); | ||
|
||
try { | ||
List<String> command = getInitialCommand("package"); | ||
addArchiveOption(command); | ||
addIncludeOption(command); | ||
addOsOption(command); | ||
processBuilder.command(command); | ||
Process p = processBuilder.start(); | ||
checkReturnCode(p, processBuilder.command().toString(), ReturnCode.OK.getValue()); | ||
|
||
} catch (Exception e) { | ||
throw new BuildException(e); | ||
} | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
src/main/java/net/wasdev/wlp/ant/servertasks/ServerRun.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* (C) Copyright IBM Corporation 2014, 2015. | ||
* | ||
* 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 net.wasdev.wlp.ant.servertasks; | ||
|
||
import java.text.MessageFormat; | ||
import java.util.List; | ||
import java.util.concurrent.atomic.AtomicBoolean; | ||
|
||
import org.apache.tools.ant.BuildException; | ||
import org.apache.tools.ant.Project; | ||
|
||
import net.wasdev.wlp.ant.ServerTask; | ||
|
||
public class ServerRun extends ServerTask { | ||
@Override | ||
public void execute() { | ||
initTask(); | ||
|
||
try { | ||
// create server first if it doesn't exist | ||
if (!serverConfigRoot.exists()) { | ||
log(MessageFormat.format(messages.getString("info.server.create"), serverName)); | ||
doCreate(); | ||
} | ||
|
||
List<String> command = getInitialCommand("run"); | ||
addCleanOption(command); | ||
processBuilder.command(command); | ||
final Process p = processBuilder.start(); | ||
final AtomicBoolean shutdown = new AtomicBoolean(false); | ||
Runtime.getRuntime().addShutdownHook(new Thread() { | ||
public void run() { | ||
shutdown.set(true); | ||
List<String> stopCommand = getInitialCommand("stop"); | ||
processBuilder.command(stopCommand); | ||
try { | ||
Process p = processBuilder.start(); | ||
p.waitFor(); | ||
} catch (Exception e) { | ||
log("Error stopping server", e, Project.MSG_WARN); | ||
} | ||
} | ||
}); | ||
int exitCode = getReturnCode(p, processBuilder.command().toString()); | ||
if (!shutdown.get() && exitCode != ReturnCode.OK.getValue()) { | ||
throw new BuildException(MessageFormat.format(messages.getString("error.invoke.command"), | ||
processBuilder.command().toString(), exitCode, ReturnCode.OK.getValue())); | ||
} | ||
} catch (Exception e) { | ||
throw new BuildException(e); | ||
} | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
src/main/java/net/wasdev/wlp/ant/servertasks/ServerStart.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* (C) Copyright IBM Corporation 2014, 2015. | ||
* | ||
* 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 net.wasdev.wlp.ant.servertasks; | ||
|
||
import java.text.MessageFormat; | ||
import java.util.List; | ||
|
||
import org.apache.tools.ant.BuildException; | ||
|
||
import net.wasdev.wlp.ant.ServerTask; | ||
|
||
public class ServerStart extends ServerTask { | ||
@Override | ||
public void execute() { | ||
initTask(); | ||
|
||
try { | ||
// create server first if it doesn't exist | ||
if (!serverConfigRoot.exists()) { | ||
log(MessageFormat.format(messages.getString("info.server.create"), serverName)); | ||
doCreate(); | ||
} | ||
|
||
List<String> command = getInitialCommand("start"); | ||
addCleanOption(command); | ||
processBuilder.command(command); | ||
Process p = processBuilder.start(); | ||
checkReturnCode(p, processBuilder.command().toString(), ReturnCode.OK.getValue(), | ||
ReturnCode.REDUNDANT_ACTION_STATUS.getValue()); | ||
|
||
// check server started message code. | ||
long startTimeout = SERVER_START_TIMEOUT_DEFAULT; | ||
if (timeout != null && !timeout.equals("")) { | ||
startTimeout = Long.valueOf(timeout); | ||
} | ||
validateServerStarted(getLogFile(), startTimeout); | ||
|
||
} catch (Exception e) { | ||
throw new BuildException(e); | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/main/java/net/wasdev/wlp/ant/servertasks/ServerStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* (C) Copyright IBM Corporation 2014, 2015. | ||
* | ||
* 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 net.wasdev.wlp.ant.servertasks; | ||
|
||
import java.util.List; | ||
|
||
import org.apache.tools.ant.BuildException; | ||
|
||
import net.wasdev.wlp.ant.ServerTask; | ||
|
||
public class ServerStatus extends ServerTask { | ||
@Override | ||
public void execute() { | ||
initTask(); | ||
|
||
try { | ||
List<String> command = getInitialCommand("status"); | ||
processBuilder.command(command); | ||
Process p = processBuilder.start(); | ||
int exitCode = getReturnCode(p, processBuilder.command().toString()); | ||
|
||
if (resultProperty == null) { | ||
resultProperty = "wlp." + serverName + ".status"; | ||
} | ||
|
||
getProject().setUserProperty(resultProperty, String.valueOf(exitCode)); | ||
|
||
} catch (Exception e) { | ||
throw new BuildException(e); | ||
} | ||
} | ||
} |
Oops, something went wrong.