Matt RaibleMatt Raible is a Web Developer and Java Champion. Connect with him on LinkedIn.

The Angular Mini-Book The Angular Mini-Book is a guide to getting started with Angular. You'll learn how to develop a bare-bones application, test it, and deploy it. Then you'll move on to adding Bootstrap, Angular Material, continuous integration, and authentication.

Spring Boot is a popular framework for building REST APIs. You'll learn how to integrate Angular with Spring Boot and use security best practices like HTTPS and a content security policy.

For book updates, follow @angular_book on Twitter.

The JHipster Mini-Book The JHipster Mini-Book is a guide to getting started with hip technologies today: Angular, Bootstrap, and Spring Boot. All of these frameworks are wrapped up in an easy-to-use project called JHipster.

This book shows you how to build an app with JHipster, and guides you through the plethora of tools, techniques and options you can use. Furthermore, it explains the UI and API building blocks so you understand the underpinnings of your great application.

For book updates, follow @jhipster-book on Twitter.

10+ YEARS


Over 10 years ago, I wrote my first blog post. Since then, I've authored books, had kids, traveled the world, found Trish and blogged about it all.

Maven Console and setting properties

I've been using Maven at my new gig and the Maven Console in order to avoid its painfully slow startup times. Using a slow-ass PowerBook in conjunction with Maven makes my face turn read and my ears smoke sometimes, but I'm getting used to it, much to my dismay. While the console has made things tolerable, Maven itself keeps getting in the way. I hate how it *requires* me to run my tests everytime I build or deploy. So I've turned that off by creating a build.properties file with "maven.test.skip=true". The problem with the Maven Console is it doesn't let me turn tests back on, so I'm stuck with running "maven test -Dmaven.test.skip=false" when I want to run my tests.

There's two ways I can think of to solve this problem:

  • If "maven idea:multiproject" allows me to setup my project so that Tomcat/Resin/whatever can point to my source directory and I don't have to deploy. I'm a web developer, and I typically have to run "maven deploy" to test simple UI changes. That's why I turn the tests off - because I want a 1-2 second turnaround to see my changes. BTW, it's too bad there's no "eclipse:multiproject" goal.
  • Enhance the console so it's possible to set properties. For example, typing "-Dmaven.test.skip=false" would set the property so the next time I run "maven war", my tests would be run. That, or allow me to run "maven war -Dmaven.test.skip=false". Allowing this would also make it possible to run a single test from the command line, instead of all (the only current option).

Posted in Java at Jan 20 2005, 09:43:30 AM MST 11 Comments
Comments:

What we've done is define a goal that "redeploys" the web-content portion (jsp, css, gif, etc) of our application without going through maven's war:war. In our case we use OC4J and have our own maven plugin with a goal that simply copies the web-content to the deployment dir in OC4J. I know this technique will also work in Tomcat but I guess you'd have to define your own goal in your maven.xml (I'm not sure what maven plugin's are available for Tomcat).

Posted by Norm Deane on January 20, 2005 at 05:54 PM MST #

Yeah, I have a "deploy" goal that does this already:

    <goal name="deploy" prereqs="war:webapp">
        <copy todir="${maven.tomcat.home}/webapps">
            <fileset dir="${maven.build.dir}">
                <include name="${pom.artifactId}/**"/>
            </fileset>
        </copy>
    </goal>
My main issue is I want to turn on/off running of tests when using the console. Since the console doesn't allow setting of properties - (AFAIK) this is not currently possible.

Posted by Matt Raible on January 20, 2005 at 06:01 PM MST #

This won't get you any closer to achieving goal #1 (being able to set properties from within the maven console) but this will achieve goal #2 (skipping tests on a content redeploy). You can remove the preGoal on war:webapp and just copy the web content from maven.war.src to the tomcat dir. Something like...

<goal name="deploy">
   <ant:copy todir="${maven.tomcat.home}/webapps">
      <ant:fileset dir="${maven.war.src}"
         includes="${maven.war.src.includes}"
         excludes="${maven.war.src.excludes}">
      </ant:fileset>
   </ant:copy>
</goal>

By skipping the prereq on war:webapp you'll skip running the tests. I've looked through the console plugin and I don't see any way to set properties from within a maven console session.

Posted by Norm Deane on January 20, 2005 at 06:25 PM MST #

You can simply create a new goal in a maven.xml where you set the property and then you'd just have to invoke this new goal. IOW, in your maven.xml:

<goal name="skipTest">
  <j:set var="maven.test.skip" value="true"/>
  <attainGoal name="test"/>
</goal>

Then, at your console prompt,

Console> skipTest

If you don't want to skip the tests,

Console> test

should do it.

Posted by Sri Sankaran on January 20, 2005 at 06:33 PM MST #

I use the MevenIDE with Eclipse. It seems to do the trick. It also keeps Maven and Eclipse in sync. The POM and .classpath are easy to sync. I don't see much of a problem with speed and Maven. The Eclipse integration makes it as easy to work with as Ant (almost). You can configure run goaps with the props set the way you want them. I am running on a top of the line laptop (about 1 year old). Pentium 4 with 1 gig of memory. It isn't pretty. It is heavy to carry. But it runs fast.

Posted by Rick Hightower on January 20, 2005 at 10:15 PM MST #

Matt, properties have been available in console for as long as I can remember:

maven.test.skip=true

I've updated the doco to reflect this as I notice it didn't have anything. Thanks.

I tend to get Maven to do its thing in 3-10 seconds on an old P3 laptop - if you are getting worse performance I'd encourage you to come over to the Maven User's List so that we can find out what the problem is.

You can also use your IDE for deploying webapps like you mentioned. If you set

maven.multiproject.type=war

on your webapp's project.properties, maven idea:multiproject will generate a web module (IDEA 4.0+). I use this, and then have IDEA compile and copy the files directly into the servlet container. From IDEA 4.5+ you can also start Tomcat (in normal or debug mode) inside IDEA and have it deploy the webapp for you. I now use this all the time and find it to be most efficient.

This leaves Maven for CI, the site and making releases, or for users to build the product rather than day-to-day use; leaving that to the IDE which is what it does best. Horses for courses as they say.

Posted by Brett Porter on January 20, 2005 at 11:01 PM MST #

BTW, it's too bad there's no "eclipse:multiproject" goal.
<code>maven -Dgoal=eclipse multiproject:goal</code>

Posted by Wolfgang Groiss on January 21, 2005 at 07:38 AM MST #

Oh great. Should have RTFA fully before posting. *turnsAwayInShame*

Posted by 81.10.192.170 on January 21, 2005 at 07:40 AM MST #

Thanks for the tip Brett - works great!

Posted by Matt Raible on January 21, 2005 at 07:48 AM MST #

Great timing Matt, I've had the same questions and have been meaning to look into it. This just saved me a bunch of time!

Posted by Todd Huss on January 21, 2005 at 05:55 PM MST #

How much memory do you have in your pb? Mine is pretty fast (1.25). I put another gig of RAM in (~$300).

Posted by Rob on January 24, 2005 at 06:52 AM MST #

Post a Comment:
  • HTML Syntax: Allowed