Showing diffs
TweetPosted on Sunday Mar 09, 2014 at 09:06AM in Technology
Assume this:
kyle-no-MacBook:gitprac5 kyle$ ls -l total 8 -rw-r--r--+ 1 kyle staff 5 3 9 09:04 hoge.txt kyle-no-MacBook:gitprac5 kyle$ cat hoge.txt hoge kyle-no-MacBook:gitprac5 kyle$ git status # On branch master nothing to commit, working directory clean kyle-no-MacBook:gitprac5 kyle$
Show unstaged changes
kyle-no-MacBook:gitprac5 kyle$ echo hogehoge >> hoge.txt kyle-no-MacBook:gitprac5 kyle$ git diff diff --git a/hoge.txt b/hoge.txt index 2262de0..1904c09 100644 --- a/hoge.txt +++ b/hoge.txt @@ -1 +1,2 @@ hoge +hogehoge kyle-no-MacBook:gitprac5 kyle$
Show staged changes
kyle-no-MacBook:gitprac5 kyle$ git add hoge.txt kyle-no-MacBook:gitprac5 kyle$ git diff --cached diff --git a/hoge.txt b/hoge.txt index 2262de0..1904c09 100644 --- a/hoge.txt +++ b/hoge.txt @@ -1 +1,2 @@ hoge +hogehoge kyle-no-MacBook:gitprac5 kyle$
- There are no unstaged changes now so result of git diff is empty
kyle-no-MacBook:gitprac5 kyle$ git diff kyle-no-MacBook:gitprac5 kyle$
Show both of unstaged and staged changes
Edit hoge.txt again
kyle-no-MacBook:gitprac5 kyle$ echo hogehogehoge >> hoge.txt
Show unstaged changes
kyle-no-MacBook:gitprac5 kyle$ git diff diff --git a/hoge.txt b/hoge.txt index 1904c09..9d1d67e 100644 --- a/hoge.txt +++ b/hoge.txt @@ -1,2 +1,3 @@ hoge hogehoge +hogehogehoge
Show staged changes
kyle-no-MacBook:gitprac5 kyle$ git diff --cached diff --git a/hoge.txt b/hoge.txt index 2262de0..1904c09 100644 --- a/hoge.txt +++ b/hoge.txt @@ -1 +1,2 @@ hoge +hogehoge
- This means that an another copy is created when we execute git add.
Show diff between 2 branches
kyle-no-MacBook:hello kyle$ git diff b4 origin/b4 diff --git a/README.md b/README.md index b8630fa..9c70835 100644 --- a/README.md +++ b/README.md @@ -1,2 +1 @@ b4-local1 -CANCEL kyle-no-MacBook:hello kyle$
Tags: git
Statuses of resources
TweetPosted on Sunday Mar 09, 2014 at 08:28AM in Technology
Statuses
- untracked
- unmodified
- modified
- staged
untracked
- Newly created file what not connected to the any part of git.
- We use git add to connect these file to git.
unmodified
- Files connected to git but no changes were made yet.
modified
- Files connected to git and modified.
- When we do commit with this kind of resources only, no changes will be made.
staged
- Files connected to git and modified, and declared to commit next time.
Examples of an newly created file
Create a repository
kyle-no-MacBook:gitprac5 kyle$ git init Initialized empty Git repository in /Users/kyle/tmp/gitprac5/.git/ kyle-no-MacBook:gitprac5 kyle$
Create a file
kyle-no-MacBook:gitprac5 kyle$ echo hoge > hoge.txt kyle-no-MacBook:gitprac5 kyle$ git status # On branch master # # Initial commit # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # hoge.txt nothing added to commit but untracked files present (use "git add" to track) kyle-no-MacBook:gitprac5 kyle$
- Now hoge.txt is untracked.
Add to Index
kyle-no-MacBook:gitprac5 kyle$ git add hoge.txt kyle-no-MacBook:gitprac5 kyle$ git status # On branch master # # Initial commit # # Changes to be committed: # (use "git rm --cached <file>..." to unstage) # # new file: hoge.txt # kyle-no-MacBook:gitprac5 kyle$
- Now README is staged (?).
Commit
kyle-no-MacBook:gitprac5 kyle$ git commit -m 'initial' [master (root-commit) ffbe516] initial 1 file changed, 1 insertion(+) create mode 100644 hoge.txt kyle-no-MacBook:gitprac5 kyle$ git status # On branch master nothing to commit, working directory clean kyle-no-MacBook:gitprac5 kyle$
- Now README is unmodified.
Cancel git add to new file
- We can cancel it like this:
kyle-no-MacBook:gitprac5 kyle$ echo README! > README kyle-no-MacBook:gitprac5 kyle$ git status # On branch master # Untracked files: # (use "git add <file>..." to include in what will be committed) # # README nothing added to commit but untracked files present (use "git add" to track) kyle-no-MacBook:gitprac5 kyle$ git add README kyle-no-MacBook:gitprac5 kyle$ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # new file: README # kyle-no-MacBook:gitprac5 kyle$ git reset HEAD README kyle-no-MacBook:gitprac5 kyle$ git status # On branch master # Untracked files: # (use "git add <file>..." to include in what will be committed) # # README nothing added to commit but untracked files present (use "git add" to track) kyle-no-MacBook:gitprac5 kyle$
- Also this deletes all of untracked files:
kyle-no-MacBook:gitprac5 kyle$ git clean -f Removing README kyle-no-MacBook:gitprac5 kyle$ ls -l total 8 -rw-r--r--+ 1 kyle staff 5 3 9 08:40 hoge.txt kyle-no-MacBook:gitprac5 kyle$ git status # On branch master nothing to commit, working directory clean kyle-no-MacBook:gitprac5 kyle$
Examples of existing file that already tracked by git
kyle-no-MacBook:gitprac5 kyle$ echo hogehoge >> hoge.txt kyle-no-MacBook:gitprac5 kyle$ git status # On branch master # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: hoge.txt # no changes added to commit (use "git add" and/or "git commit -a") kyle-no-MacBook:gitprac5 kyle$
- Now hoge.txt modified but not staged.
kyle-no-MacBook:gitprac5 kyle$ git add hoge.txt kyle-no-MacBook:gitprac5 kyle$ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: hoge.txt # kyle-no-MacBook:gitprac5 kyle$
- Now hoge.txt staged.
- Let's take one more modify.
kyle-no-MacBook:gitprac5 kyle$ echo hogehogehoge >> hoge.txt kyle-no-MacBook:gitprac5 kyle$ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: hoge.txt # # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: hoge.txt # kyle-no-MacBook:gitprac5 kyle$
- This means last change (hogehogehoge) will not send by next commit.
- Next commit will send the change (hogehoge) only.
- So when you want to commit (hogehogehoge) next time, you need to execute git add once again.
kyle-no-MacBook:gitprac5 kyle$ git add hoge.txt kyle-no-MacBook:gitprac5 kyle$ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: hoge.txt # kyle-no-MacBook:gitprac5 kyle$
References
Tags: git
How to define JVM parameters
TweetPosted on Friday Mar 07, 2014 at 08:09AM in Technology
Environment
- WildFly 8.0.0.Final
- JBoss Tools (Kepler) 4.1.1.Final
- Eclipse Kepler SR1
- Oracle JDK7u51
- OS X 10.9.2
Test Servlet
- This time we're going to test it with enabling of assertion.
@WebServlet("/")
public class AssertServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
assert false : "test";
}
}
Configure standalone.conf for launching through standalone.sh
- Add this statement to $WILDFLY_HOME/bin/standalone.conf
JAVA_OPTS=$JAVA_OPTS -ea
- This can be done on unix systems like this:
echo "JAVA_OPTS=\"\$JAVA_OPTS -ea\"" >> standalone.conf
- Now the Servlet throws Assertion Error when we launch WildFly through standalone.sh:
09:05:00,614 ERROR [io.undertow.request] (default task-1) UT005023: Exception handling request to /assert/: java.lang.AssertionError: test
at assert0.AssertServlet.doGet(AssertServlet.java:16) [classes:]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:687) [jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final]
...
- But it won't work with WildFly instances that launched by Eclipse.
Configuring Eclipse
Open Servers view and double-click WildFly instance

Click “Open launch configuration”

Add “-ea” to “VM arguments:” - OK

wildfly-maven-plugin
- Like this:
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>1.0.1.Final</version>
<configuration>
<jboss-home>${wildfly.home}</jboss-home>
<modules-path>${wildfly.home}/modules</modules-path>
<jvm-args>-ea -Xms64m -Xmx512m -XX:MaxPermSize=256m
-Djava.net.preferIPv4Stack=true
-Djboss.server.base.dir=${wildfly.home}/standalone
-Djboss.socket.binding.port-offset=${wildfly.port.offset}</jvm-args>
<port>${wildfly.port.mgmt}</port>
</configuration>
...
Assertion notes
Eclipse
We can enable assertion for every JUnit run configuration which will newly create.

This won't make assertions enable for already created run configurations.
Maven Surefire Plugin
- “By default, Surefire enables JVM assertions for the execution of your test cases. To disable the assertions, set this flag to “false”[3].
References
Tags: wildfly
Profiling with VisualVM
TweetPosted on Thursday Mar 06, 2014 at 05:04PM in Technology
Environment
Local
- VisualVM 1.7.0_51 (Build 1352-130117); platform 20130117-unknown-revn
- WildFly 8.0.0.Final
- Oracle JDK7u51
- OS X 10.9.2
Remote profiling target
- WildFly 8.0.0.Final
- Oracle JDK7u45
- OS X 10.9.1
Profiling local instances
- We don't need any special operation to profiling with local instances.
- After just launch VisualVM, we can see local instances.

Profiling Remote instances
Create a management user in the target instance
kyle-no-MacBook:bin kyle$ pwd /Users/kyle/apps/wildfly-8.0.0.Final/bin kyle-no-MacBook:bin kyle$ ./add-user.sh kyle *** Picked up _JAVA_OPTIONS: -Dfile.encoding=UTF-8 Added user 'kyle' to file '/Users/kyle/apps/wildfly-8.0.0.Final/standalone/configuration/mgmt-users.properties' Added user 'kyle' to file '/Users/kyle/apps/wildfly-8.0.0.Final/domain/configuration/mgmt-users.properties' kyle-no-MacBook:bin kyle$
Define a system property in the target instance to accept connection from remote host
- CAUTION: this makes management port to accept connections from everyone.
/system-property=jboss.bind.address.management:add(value=0.0.0.0)
Launch VisualVM
- We have to specify an additional jar on startup option like this:
jvisualvm --cp:a /Users/kyle/apps/wildfly-8.0.0.Final/bin/client/jboss-cli-client.jar
- If it doesn't work, try “-cp:a” instead
Add and connect to target
Right-click “Remote” - “Add a remote host”

Enter hostname - OK

Right-click hostname - add a JMX connection

Enter connection url, username and password that created in above step - OK
NOTICE: Usually, WildFly's management port is 9990. I customized it as 49990 for my environment.Double-click a icon which appeared with JMX icon. now we can do profiling with remote WildFly instance.

service:jmx:http-remoting-jmx://[HOSTNAME]:9990
References
- Connecting VisualVM with a remote JBoss AS 7 / EAP6 JVM process | akquinet-blog
- [AS7-4695] Server does not start with sun jmx enabled - JBoss Issue Tracker
- Using jconsole to connect to JMX on AS7 | Community
- adding alternative jmx connectivity (i.e. JBoss 7) | Oracle Community
- JMX subsystem configuration - WildFly 8 - Project Documentation Editor
Tags: wildfly
Switching environment specific configuration files
TweetPosted on Tuesday Mar 04, 2014 at 08:18PM in Technology
- In my last posting Treating environment specific configurations with Maven filtering, I said that I don't want to create separate files for each environment.
- But it is still needed by some cases.
- Such as web.xml, logback.xml is too long for treat with Maven properties at some cases.
- So I'm going to find a way to achieve it.
Environment
- Apache Maven 3.1.1
- Jenkins 1.551
- WildFly 8.0.0.Final
- Eclipse Kepler SR1
- Oracle JDK7u51
- OS X 10.9.2
Preparation
~/.m2/settings.xml
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<profiles>
<profile>
<id>development</id>
<properties>
<hogeApp.environmentId>dev</hogeApp.environmentId>
</properties>
</profile>
</profiles>
</settings>
Explicit selection of the Maven Profile is mandatory.
Right-click the project - Maven - Select Maven Profiles

Check “development” - OK

Sample project
Project structure
kyle-no-MacBook:switch kyle$ tree src
src
├── main
│ ├── java
│ │ └── org
│ │ └── nailedtothex
│ │ └── sw
│ │ └── MainServlet.java
│ ├── resources
│ │ ├── _dev
│ │ │ └── env-specific.properties
│ │ ├── _it
│ │ │ └── env-specific.properties
│ │ └── common.properties
│ └── webapp
│ ├── WEB-INF
│ │ ├── index.jsp
│ │ └── lib
│ ├── _dev
│ │ └── WEB-INF
│ │ └── web.xml
│ └── _it
│ └── WEB-INF
│ └── web.xml
└── test
├── java
│ └── org
│ └── nailedtothex
│ └── sw
│ └── MainServletIT.java
└── resources
├── _dev
│ └── test-env-specific.properties
├── _it
│ └── test-env-specific.properties
└── test-common.properties
- We can place environment specific files in the folders named such as “_dev” or “_it”.
- Common resources among environments are can be placed on the regular place.
- /webapp/WEB-INF/index.jsp and /src/main/resources/common.properties are regarded as common resources.
- So they will be included for every environment.
- This mechanism supports both of /src/main/resources and /src/webapp, and /src/test/resources too.
- MainServet acquires all of properties, then dispatch to /WEB-INF/index.jsp, and return variables to the client.
Produced artifact by standalone Maven
kyle-no-MacBook:switch kyle$ mvn clean package -P development >/dev/null; unzip -l target/switch.war
Picked up _JAVA_OPTIONS: -Dfile.encoding=UTF-8
Archive: target/switch.war
Length Date Time Name
-------- ---- ---- ----
0 03-05-14 11:12 META-INF/
129 03-05-14 11:12 META-INF/MANIFEST.MF
0 03-05-14 11:12 WEB-INF/
0 03-05-14 11:12 WEB-INF/classes/
0 03-05-14 11:12 WEB-INF/classes/org/
0 03-05-14 11:12 WEB-INF/classes/org/nailedtothex/
0 03-05-14 11:12 WEB-INF/classes/org/nailedtothex/sw/
64 03-05-14 11:12 WEB-INF/classes/common.properties
75 03-05-14 11:12 WEB-INF/classes/env-specific.properties
2479 03-05-14 11:12 WEB-INF/classes/org/nailedtothex/sw/MainServlet.class
158 03-04-14 22:41 WEB-INF/index.jsp
470 03-04-14 22:31 WEB-INF/web.xml
2433 03-05-14 10:15 META-INF/maven/org.nailedtothex/switch/pom.xml
116 03-05-14 11:12 META-INF/maven/org.nailedtothex/switch/pom.properties
-------- -------
5924 14 files
kyle-no-MacBook:switch kyle$
Resources
Whole resources are available in GitHub.
- pom.xml
- There are also configurations about integration test with WildFly.
- MainServlet.java
- index.jsp
- MainServletIT.java
Output of MainServlet on development environment
- This is output of when I deployed the application to WildFly through Eclipse.
kyle-no-MacBook:switch kyle$ curl http://localhost:8080/switch/ This value came from context-param defined in /src/main/webapp/_dev/WEB-INF/web.xml This value came from /src/main/resources/common.properties This value came from /src/main/resources/_dev/env-specific.properties kyle-no-MacBook:switch kyle$
Test execution from command-line
- Ensure WildFly is stopped before execute the command.
kyle-no-MacBook:switch kyle$ mvn verify -P development,test-with-wildfly
Picked up _JAVA_OPTIONS: -Dfile.encoding=UTF-8
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building switch 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- properties-maven-plugin:1.0-alpha-2:read-project-properties (default) @ switch ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ switch ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ switch ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ switch ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ switch ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.16:test (default-test) @ switch ---
[INFO]
[INFO] --- maven-war-plugin:2.4:war (default-war) @ switch ---
[INFO] Packaging webapp
[INFO] Assembling webapp [switch] in [/Users/kyle/gits1/switch/switch/target/switch]
[INFO] Processing war project
[INFO] Copying webapp webResources [/Users/kyle/gits1/switch/switch/src/main/webapp/_dev] to [/Users/kyle/gits1/switch/switch/target/switch]
[INFO] Copying webapp resources [/Users/kyle/gits1/switch/switch/src/main/webapp]
[INFO] Webapp assembled in [36 msecs]
[INFO] Building war: /Users/kyle/gits1/switch/switch/target/switch.war
[INFO]
[INFO] --- wildfly-maven-plugin:1.0.1.Final:start (wildfly-run) @ switch ---
[INFO] JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre
[INFO] JBOSS_HOME=/Users/kyle/apps/wildfly-8.0.0.Final
[INFO] Server is starting up.
Picked up _JAVA_OPTIONS: -Dfile.encoding=UTF-8
3 05, 2014 12:01:24 午後 org.xnio.Xnio <clinit>
INFO: XNIO version 3.2.0.Final
3 05, 2014 12:01:25 午後 org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.2.0.Final
3 05, 2014 12:01:25 午後 org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 4.0.0.Final
12:01:25,334 INFO [org.jboss.modules] (main) JBoss Modules version 1.3.0.Final
12:01:25,601 INFO [org.jboss.msc] (main) JBoss MSC version 1.2.0.Final
12:01:25,689 INFO [org.jboss.as] (MSC service thread 1-6) JBAS015899: WildFly 8.0.0.Final "WildFly" starting
12:01:25,696 DEBUG [org.jboss.as.config] (MSC service thread 1-6) Configured system properties:
awt.toolkit = sun.lwawt.macosx.LWCToolkit
file.encoding = UTF-8
*SNIP*
12:01:27,910 INFO [org.jboss.as.server] (ServerService Thread Pool -- 29) JBAS018559: Deployed "switch.war" (runtime-name : "switch.war")
12:01:27,911 INFO [org.jboss.as.server] (ServerService Thread Pool -- 29) JBAS018559: Deployed "mavenprops.war" (runtime-name : "mavenprops.war")
12:01:27,920 INFO [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management
12:01:27,920 INFO [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
12:01:27,921 INFO [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.0.0.Final "WildFly" started in 2929ms - Started 359 of 419 services (100 services are lazy, passive or on-demand)
[INFO]
[INFO] >>> wildfly-maven-plugin:1.0.1.Final:deploy (wildfly-run) @ switch >>>
[INFO]
[INFO] --- properties-maven-plugin:1.0-alpha-2:read-project-properties (default) @ switch ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ switch ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ switch ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ switch ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ switch ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.16:test (default-test) @ switch ---
[INFO] Skipping execution of surefire because it has already been run for this configuration
[INFO]
[INFO] --- maven-war-plugin:2.4:war (default-war) @ switch ---
[INFO] Packaging webapp
[INFO] Assembling webapp [switch] in [/Users/kyle/gits1/switch/switch/target/switch]
[INFO] Processing war project
[INFO] Copying webapp webResources [/Users/kyle/gits1/switch/switch/src/main/webapp/_dev] to [/Users/kyle/gits1/switch/switch/target/switch]
[INFO] Copying webapp resources [/Users/kyle/gits1/switch/switch/src/main/webapp]
[INFO] Webapp assembled in [8 msecs]
[INFO] Building war: /Users/kyle/gits1/switch/switch/target/switch.war
[INFO]
[INFO] <<< wildfly-maven-plugin:1.0.1.Final:deploy (wildfly-run) @ switch <<<
[INFO]
[INFO] --- wildfly-maven-plugin:1.0.1.Final:deploy (wildfly-run) @ switch ---
12:01:30,671 INFO [org.jboss.as.repository] (management-handler-thread - 3) JBAS014900: Content added at location /Users/kyle/apps/wildfly-8.0.0.Final/standalone/data/content/77/69a251de04b468b0d3afc81afe32b2c1b58a63/content
12:01:30,678 INFO [org.wildfly.extension.undertow] (MSC service thread 1-9) JBAS017535: Unregistered web context: /switch
12:01:30,713 INFO [org.hibernate.validator.internal.util.Version] (MSC service thread 1-9) HV000001: Hibernate Validator 5.0.3.Final
12:01:30,756 INFO [org.jboss.as.server.deployment] (MSC service thread 1-16) JBAS015877: Stopped deployment switch.war (runtime-name: switch.war) in 81ms
12:01:30,757 INFO [org.jboss.as.server.deployment] (MSC service thread 1-12) JBAS015876: Starting deployment of "switch.war" (runtime-name: "switch.war")
12:01:30,785 INFO [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015877: Stopped deployment switch.war (runtime-name: switch.war) in 27ms
12:01:30,786 INFO [org.jboss.as.server.deployment] (MSC service thread 1-14) JBAS015876: Starting deployment of "switch.war" (runtime-name: "switch.war")
12:01:30,829 INFO [org.wildfly.extension.undertow] (MSC service thread 1-14) JBAS017534: Registered web context: /switch
12:01:30,871 INFO [org.jboss.as.server] (management-handler-thread - 3) JBAS018562: Redeployed "switch.war"
12:01:30,871 INFO [org.jboss.as.server] (management-handler-thread - 3) JBAS018565: Replaced deployment "switch.war" with deployment "switch.war"
[INFO]
[INFO] --- maven-failsafe-plugin:2.16:integration-test (default) @ switch ---
[INFO] Failsafe report directory: /Users/kyle/gits1/switch/switch/target/failsafe-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Picked up _JAVA_OPTIONS: -Dfile.encoding=UTF-8
Running org.nailedtothex.sw.MainServletIT
testEnvSpecific: {app.hostname=localhost, wildfly.port.offset=0, wildfly.port.mgmt=9990, wildfly.home=/Users/kyle/apps/wildfly-8.0.0.Final, value=This value came from /src/test/resources/_dev/test-env-specific.properties, app.port=8080}
testCommon: {app.environmentId=dev, app.path=/switch, value=This value came from /src/test/resources/test-common.properties}
test(): environment=dev, url=http://localhost:8080/switch/
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.568 sec - in org.nailedtothex.sw.MainServletIT
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- wildfly-maven-plugin:1.0.1.Final:undeploy (wildfly-stop) @ switch ---
12:01:31,863 INFO [org.wildfly.extension.undertow] (MSC service thread 1-3) JBAS017535: Unregistered web context: /switch
12:01:31,873 INFO [org.jboss.as.server.deployment] (MSC service thread 1-8) JBAS015877: Stopped deployment switch.war (runtime-name: switch.war) in 10ms
12:01:31,889 INFO [org.jboss.as.repository] (management-handler-thread - 4) JBAS014901: Content removed from location /Users/kyle/apps/wildfly-8.0.0.Final/standalone/data/content/77/69a251de04b468b0d3afc81afe32b2c1b58a63/content
12:01:31,889 INFO [org.jboss.as.server] (management-handler-thread - 4) JBAS018558: Undeployed "switch.war" (runtime-name: "switch.war")
[INFO]
[INFO] --- wildfly-maven-plugin:1.0.1.Final:shutdown (wildfly-stop) @ switch ---
12:01:31,917 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-16) JBAS010409: Unbound data source [java:jboss/jdbc/JBatchDS]
*SNIP*
12:01:31,950 INFO [org.jboss.as] (MSC service thread 1-10) JBAS015950: WildFly 8.0.0.Final "WildFly" stopped in 28ms
[INFO]
[INFO] --- maven-failsafe-plugin:2.16:verify (default) @ switch ---
[INFO] Failsafe report directory: /Users/kyle/gits1/switch/switch/target/failsafe-reports
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.541s
[INFO] Finished at: Wed Mar 05 12:01:32 JST 2014
[INFO] Final Memory: 14M/245M
[INFO] ------------------------------------------------------------------------
kyle-no-MacBook:switch kyle$
How to apply this method to Jenkins job which executes integration test?
- We need to specify the profile named “test-with-wildfly”
- And appropriate environmentId on MAVEN_OPTS.

Test run
- integration-test phase executed expectedly.
[INFO] --- maven-failsafe-plugin:2.16:integration-test (default) @ switch ---
[INFO] Failsafe report directory: /Users/Shared/Jenkins/Home/jobs/Switch/workspace/switch/target/failsafe-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running org.nailedtothex.sw.MainServletIT
testEnvSpecific: {app.hostname=localhost, wildfly.port.offset=40000, wildfly.port.mgmt=49990, wildfly.home=/Users/Shared/Jenkins/wildfly-8.0.0.Final, value=This value came from /src/test/resources/_it/test-env-specific.properties, app.port=48080}
testCommon: {app.environmentId=it, app.path=/switch, value=This value came from /src/test/resources/test-common.properties}
test(): environment=it, url=http://localhost:48080/switch/
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.738 sec - in org.nailedtothex.sw.MainServletIT
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
Remarks
- I don't know whether it is good idea for any cases because we easily misses to keep these platform specific files correctly.
- Sometimes we forget about these files need to be edited or created.
- So, I guess that we are better to apply this method for few numbers of resources that really required this way.
Unresolved issues
- Eclipse produces the package contains unnecessary resources.
- It seems to that exclusions are ignored.
- I guess this is not a problem for most cases, because correct environment specific resources are included.
kyle-no-MacBook:switch kyle$ unzip -l ~/apps/wildfly-8.0.0.Final/standalone/deployments/switch.war
Archive: /Users/kyle/apps/wildfly-8.0.0.Final/standalone/deployments/switch.war
Length Date Time Name
-------- ---- ---- ----
222 03-05-14 11:25 META-INF/maven/org.nailedtothex/switch/pom.properties
4476 03-05-14 11:25 META-INF/maven/org.nailedtothex/switch/pom.xml
470 03-05-14 11:25 WEB-INF/web.xml
105 03-05-14 11:23 META-INF/MANIFEST.MF
2186 03-05-14 10:15 WEB-INF/classes/org/nailedtothex/sw/MainServlet.class
64 03-05-14 10:15 WEB-INF/classes/common.properties
75 03-05-14 10:15 WEB-INF/classes/env-specific.properties
75 03-05-14 09:46 WEB-INF/classes/_dev/env-specific.properties
158 03-04-14 22:41 WEB-INF/index.jsp
74 03-04-14 22:34 WEB-INF/classes/_it/env-specific.properties
433 03-04-14 22:14 _dev/WEB-INF/web.xml
0 03-04-14 22:04 META-INF/
0 03-04-14 22:04 META-INF/maven/
0 03-04-14 22:04 META-INF/maven/org.nailedtothex/
0 03-04-14 22:04 META-INF/maven/org.nailedtothex/switch/
0 03-05-14 09:48 WEB-INF/
0 03-04-14 22:34 WEB-INF/classes/
0 03-04-14 22:04 WEB-INF/classes/org/
0 03-04-14 22:04 WEB-INF/classes/org/nailedtothex/
0 03-04-14 22:04 WEB-INF/classes/org/nailedtothex/sw/
0 03-04-14 22:34 WEB-INF/classes/_dev/
0 03-04-14 22:13 _dev/
0 03-04-14 22:13 _dev/WEB-INF/
0 03-04-14 22:34 WEB-INF/classes/_it/
0 03-05-14 09:48 WEB-INF/lib/
-------- -------
8338 25 files
kyle-no-MacBook:switch kyle$
References
- Maven War plugin - Adding and Filtering External Web Resources
- maven 2 - maven2: excluding directory from WAR - Stack Overflow
- maven-war-pluginでファイルの除外やweb.xmlの指定など:Javaってまだいけますか
- Configure a Maven project for multiple target environments | Vino.java
- maven - Eclipse and m2e: how to automatically exclude a resource folder from JAR? - Stack Overflow
- Bug 388683 – maven-surefire-plugin SystemPropertyVariables ignored
- Properties Maven Plugin - Introduction
Tags: maven
