Chris' Tech Blog

April 19, 2012

Netbeans: Go away!

Filed under: Java, Maven, Netbeans — Chris Ey @ 9:56 am

I start hating Netbeans: It constantly seems to get in my way.
For example, I want to debug the webapp. That causes netbeans to run all tests (via MVN). Those tests fail and that’s known, I just f*cking want to debug the app. Have not found a switch to convince Netbeans to set -DskipTests=true for debug mode.
Or: Why doesn’t netbeans automagically show the file I’m editing in the projects tab? I get sick pressing “ctrl-shift-1″ to do that.
Or: I have tons of open files all the time, why would you want to hide them randomly from the tabs and let me search them in the drop-down to the right? Eclipse and IntelliJ handle that one a lot better.
Netbeans: GO AWAY!
(and no I can’t switch or I lose project support which I don’t want to, no time for that)

February 3, 2011

Maven Quick Reference Card – a life saver!

Filed under: Java, Maven — Chris Ey @ 8:16 am

Not much to say – how come that after years of using Maven and after endless searching for maven related stuff I find a quick reference card which pretty much contains most solutions already:

http://maven.apache.org/guides/MavenQuickReferenceCard.pdf

Cheers!

August 27, 2010

Maven filtering with deployment profiles

Filed under: Java, Maven — Chris Ey @ 4:32 am

When you set up a maven project, especially for web application projects (producing a WAR file), you often need to configure the WAR file before it gets deployed. I use maven filtering together with maven profiles.

There are tons of ways to accomplish this, but I prefer to integrate deployment properties into the WAR itself. This way, the build process already produces a stand-alone WAR file ready to use, and you don’t need an additional step to modify the WAR content.

This is how you can accomplish this (pom.xml):

	<build>
		<resources>
			<resource>
				<directory>${basedir}/src/main/java</directory>
				<filtering>true</filtering>
				<includes>
					<include>**</include>
				</includes>
				<excludes>
					<exclude>**/*.java</exclude>
				</excludes>
			</resource>
			<resource>
				<directory>
					${basedir}/src/main/webapp/WEB-INF
				</directory>
				<includes>
					<include>web.xml</include>
				</includes>
				<filtering>true</filtering>
				<targetPath>..</targetPath>
			</resource>
			[...]
		<resources>
		[...]
		<filters>
			<filter>src/main/filters/filter-${env}.properties</filter>
		</filters>
	</build>
	<dependencies>
		[...]
	</dependencies>
	<properties>
		<!-- This is the default profile if no profile is selected on the command line -->
		<env>dev</env>
		[...]
	</properties>
	<profiles>
		<profile>
			<id>dev</id>
			<properties>
				<env>dev</env>
			</properties>
		</profile>
		<profile>
			<id>prod</id>
			<properties>
				<env>prod</env>
			</properties>
		</profile>
	<profiles>

Now, create one filter file for each profile (for the two profiles dev and prod in the example above):

src/main/filters/filter-dev.properties
src/main/filters/filter-prod.properties

insert filter token as described here, and execute your maven with a profile for deployment:

mvn clean install -P prod

March 20, 2010

mvn eclipse: “Request to merge when ‘filtering’ is not identical.”

Filed under: Eclipse, Java, Maven — Chris Ey @ 11:16 pm

When filtering properties is turned on with maven and I regenerated the eclipse project with maven (mvn eclipse:eclipse), I got this problem after updating to a current mvn release:

org.apache.maven.lifecycle.LifecycleExecutionException: Request to merge when 'filtering' is not identical. Original=source src/main/java: output=null, include=[**/*.java], exclude=[], test=false, filtering=false, merging with=resource src/main/java: output=target/classes, include=[**], exclude=[**/*.java|config.properties|**/*.java], test=false, filtering=true

Well, looks like I’m not the only one with this problem! The best thread & solutions I found here:

http://forums.atlassian.com/thread.jspa?threadID=34952&tstart=30

In short, you want to use version 2.6 of the eclipse plugin, and a quick way to do that is execute mvn eclipse this way:

mvn org.apache.maven.plugins:maven-eclipse-plugin:2.6:eclipse -DdownloadSources=true -DdownloadJavadocs=true

Powered by WordPress