J'ai testé plusieurs variantes d'ajout d'une propriété système dans Wildfly (version 8.2.1) standalone.xml via le plugin Wildfly Maven. Fondamentalement, il ajoute une propriété système si elle n'existe pas, et change sa valeur si c'est le cas. Idéalement, je veux un script CLI en mode batch, avec if-else imbriqué. Cependant, les problèmes sont les suivants:Wildfly CLI ajouter/mettre à jour les propriétés du lot système et if-else
- Il ne fonctionne pas en mode batch
- Nested if-else ne fonctionne pas même en mode non-lot
- résultats similaires si elle est exécutée dans le script CLI - lot et si- imbriquée d'autre ne fonctionne pas
Voici la section plugin dans mon pom.xml
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>1.0.2.Final</version>
<executions>
<execution>
<id>addConfig</id>
<phase>install</phase>
<goals><goal>execute-commands</goal></goals>
<configuration>
<execute-commands>
<!-- <batch>true</batch> Issue #1. Not working in batch mode -->
<batch>false</batch> <!-- This works -->
<commands>
<command>if (outcome != success) of /system-property=app.env:read-resource</command>
<command>/system-property=app.env:add(value=local)</command>
<command>else</command>
<command>/system-property=app.env:remove</command>
<command>/system-property=app.env:add(value=local)</command>
<command>end-if</command>
</commands>
<!-- Issue #2. Nested if-else not working, even in non-batch mode -->
<!--
<batch>false</batch>
<commands>
<command>if (outcome != success) of /system-property=app.env:read-resource</command>
<command>/system-property=app.env:add(value=local)</command>
<command>else</command>
<command>if (result.value == qa) of /system-property=app.env:read-resource</command>
<command>/system-property=app.env:remove</command>
<command>/system-property=app.env:add(value=local)</command>
<command>else</command>
<command>/system-property=app.env:remove</command>
<command>/system-property=app.env:add(value=qa)</command>
<command>end-if</command>
<command>end-if</command>
</commands>
-->
<!-- Issue #3. Batch and nested if-else not working in CLI script. -->
<!--
<scripts>
<script>target/classes/scripts/add-config.cli</script>
</scripts>
-->
</execute-commands>
</configuration>
</execution>
</executions>
</plugin>
Voici l'exception si dans le lot Mode:
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.wildfly.plugins:wildfly-maven-plugin:1.0.2.Final:execute-commands (addConfig)
on project jboss-config: Execution addConfig of goal org.wildfly.plugins:wildfly-maven-plugin:1.0.2.Final:execute-commands failed: Command 'if (outcome != success) of /system-property=app.env:read-resource' is invalid. The command is not allowed in a batch.
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution addConfig of goal org.wildfly.plugins:wildfly-maven-plugin:1.0.2.Final:execute-commands failed: Command 'if (outcome != success) of /system-property=app.env:read-resource' is invalid. The command is not allowed in a batch.
... 20 more
Caused by: java.lang.IllegalArgumentException: Command 'if (outcome != success) of /system-property=app.env:read-resource' is invalid. The command is not allowed in a batch.
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
... 21 more
Caused by: org.jboss.as.cli.operation.OperationFormatException: The command is not allowed in a batch.
... 24 more
est ici l'exception si elle a un imbriquée if-else, non en lots:
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.wildfly.plugins:wildfly-maven-plugin:1.0.2.Final:execute-commands (addConfig)
on project jboss-config: Execution addConfig of goal org.wildfly.plugins:wildfly-maven-plugin:1.0.2.Final:execute-commands failed: Command 'if (result.value == qa) of /system-property=app.env:read-resource' is invalid. if is not allowed while in batch mode.
...
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution addConfig of goal org.wildfly.plugins:wildfly-maven-plugin:1.0.2.Final:execute-commands failed: Command 'if (result.value == qa) of /system-property=app.env:read-resource' is invalid. if is not allowed while in batch mode.
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145)
... 20 more
Caused by: java.lang.IllegalArgumentException: Command 'if (result.value == qa) of /system-property=app.env:read-resource' is invalid. if is not allowed while in batch mode.
at org.wildfly.plugin.cli.Commands.executeCommands(Commands.java:178)
... 21 more
Caused by: org.jboss.as.cli.CommandFormatException: if is not allowed while in batch mode.
at org.jboss.as.cli.handlers.ifelse.IfHandler.doHandle(IfHandler.java:130)
... 24 more
Pour être complet, voici le script que je veux courir
batch
if (outcome != success) of /system-property=app.env:read-resource
/system-property=app.env:add(app.env=local)
else
if (result.value == qa) of /system-property=app.env:read-resource
/system-property=app.env:remove
/system-property=app.env:add(app.env=local)
else
/system-property=app.env:remove
/system-property=app.env:add(app.env=qa)
end-if
end-if
run-batch
et ce qui fonctionne réellement:
if (outcome != success) of /system-property=app.env:read-resource
/system-property=app.env:add(value=local)
else
/system-property=app.env:remove
/system-property=app.env:add(value=local)
end-if
Merci James. J'ai édité la question originale pour corriger les fautes de frappe. –
Pas de problème. J'ai supposé que c'était une erreur de copier/coller, mais je voulais être clair dans la réponse. –