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.

AppFuse and all it's libraries

I received a question about AppFuse that I've been pondering every since. The question basically boils down to two things:

  • How do you manage Eclipse's .classpath file in conjunction with lib.properties (the file that manages it for Ant)?
  • When using AppFuse for multiple projects, do you put a "lib" folder in each project or use a central repository?

Quick Answers: I replace files in the appfuse/lib directory and update lib.properties. Then I update my project properties in Eclipse to reference the new jars. A pain, yes - but only a 2 minute process. I run all my tests before I bother changing the Eclipse classpath. As for multiple projects - the easiest thing to do is to move $yourProject/lib to a folder called "libs" in the same directory as $yourProject and change the ${lib.dir} property in properties.xml to point to the new folder.

Begins Rambling... I'm currently using AppFuse on 3 different projects. 1 is AppFuse itself, the 2nd is Struts Resume, and the third is for a client I created a webapp for in August. Right now, when I synch up Struts Resume with AppFuse, I copy paste from appfuse/lib to struts-resume/lib and update the lib.properties appropriately. I can't just copy lib.properties to struts-resume/lib because struts-resume uses libraries that appfuse doesn't. Yes, this is admittedly a pain in the arse. It's almost as bad as changing all the method signatures when moving the Hibernate Session from all method signatures into the constructors (can your IDE do that?!). I don't want to make people download appfuse to build struts-resume though, so I doubt I'll change this process.

The whole "massive lib folder" has been bouncing around in my head for quite some time. I'd like to use Maven or Greebo to download the dependencies for AppFuse, but at the same time, it's nice being able to download the whole thing at once and be up and running. I don't want to go the Maven route because I don't really want/need a website for AppFuse and it sounds tough to get it working with XDoclet (though WebShop looks like it might be a good template). KISS

The project.xml in AppFuse is my feeble 20-minute attempt to get it Mavenized (it's currently not used). I tried Greebo this morning, and it really does nothing for me. Especially since I've setup separate compile/test classpaths (read from lib.properties). It'd be a real pain with Greebo to separate out the classpath's for testing and building - it seems to only support one long classpath. Also, who wants to make their whole best-practices open-source app dependent on a 0.1 open-source app?

As for having my IDE (wether it be Eclipse or IDEA) reading the classpath from Ant - that would be the sweetest feature of the year! Currently in Eclipse and IDEA, I have to give an absolute path to j2ee.jar since I don't want to distribute it (it's 11 MB). When I switch b/w OS X and WinXP, I always have to change this classpath. I'm sure there's an easier way with setting variables in the IDE, I just haven't figured it out yet.

The other thing that is annoying is that IDEA doesn't seem to read my $ANT_HOME environment variable. Does it have it's own $ANT_HOME? It's annoying for me b/c I check for JUnit classes in the classpath in my "init" task, and IDEA doesn't find them. Don't worry Eclipse bashers - it doesn't work in Eclipse either. This is fine with me b/c I prefer the command line, but those "I use my IDE for everything" folks might not like it because they can't run AppFuse's build.xml file from w/in their IDE.

Posted in Java at Oct 23 2003, 06:21:59 PM MDT 7 Comments
Comments:

In IDEA, you need to go to the ant runner side bar(or whatever it is called) and set the properties for ant. In there you can set the classpath, for ant, and other such nonsense. I usually set my servlet.jar there so I don't have to include it with my webapp. Does this make sense, or did I just say the same thing you did? Too late at night for me...

Posted by Steven Citron-Pousty on October 24, 2003 at 02:27 AM MDT #

Matt, I've put together a crude ant task that will update the Eclipse system-wide classpath variables in file: ${eclipse.home}/workspace/.metadata/.plugins/org.eclipse.jdt.core/pref_store.ini It keeps it in sych with my lib.properties file. It is an optional task that I just run standalone whenever it needs re-synching. It has survived from Eclipse just before 2.1 to M3 with no problems. I've got some problems with M4 now, but not sure how. It's a hack and would need adjusting to your environment, but if anyone wants it they can have it (separate email, too large to put here).

Posted by Richard Mixon on October 24, 2003 at 04:12 AM MDT #

Sounds like what I'm looking for Richard - please send to [email protected] - I can integrate it as part of AppFuse. Or you could post it on my wiki.

Posted by Matt Raible on October 24, 2003 at 04:33 AM MDT #

  • I'm using the ${lib.dir} thing with multiple projects and its working ok. We just use &entity; stuff to include common pieces of build files across multiple projects and have a big "repository" of libraries in lib.dir, with some projects using different versions of some things than others. Using the new <import> stuff from Ant 1.6 is on my list of refactorings to do for our projects, and it should really help a lot.
  • IDEA - yeah, it doesn't set ANT_HOME. I have this at the top of my build files: <code> <property name="ant.home" location="${user.home}/bin/jakarta-ant"/> </code> yeah, that is a shame, but works. you could use ${env.ANT_HOME} there as well (if you use <code><property environment="env"/></code> first)
  • for j2ee.jar, my JavaDevWithAnt project does this:
        <property name="env.J2EE_HOME" location="${j2ee.lib.dir}"/>
        <property name="j2ee.home" location="${env.J2EE_HOME}"/>
        <property name="j2ee.jar" location="${j2ee.home}/lib/j2ee.jar"/>
    
    This defaults it to the stuff in lib.properties:
    #
    # J2EE - http://java.sun.com
    #
    j2ee.version       = 1.3
    j2ee.lib.dir=${lib.dir}/j2sdkee${j2ee.version}
    
    And gets it from the environment otherwise.

Posted by Erik Hatcher on October 24, 2003 at 02:09 PM MDT #

Erik,

I am using ${env.ANT_HOME} - I believe the problem is because I'm checking for junit's TestCase class in my "init" - I always put junit.jar in $ANT_HOME/lib when running from the command line (I'm not explicitly defining $ANT_HOME/lib/*.jar in my classpath). Where do I need to put junit.jar so that IDEA will see it in it's classpath?

As for j2ee.jar, I modeled my process after yours - but Ant is not my problem here. The problem is that in Eclipse (and IDEA), I have to add j2ee.jar to my IDE's classpath. It can't read Ant's properties, so I have to point to the exact file - which is always different when I switch machines (and definitely different for other developers using AppFuse).

Posted by Matt Raible on October 24, 2003 at 02:51 PM MDT #

Spotted this... http://www.jroller.com/page/aspinei/20031004#ant_goodies_extracting_info_from

Posted by Graham on October 25, 2003 at 06:41 AM MDT #

<matt> It's almost as bad as changing all the method signatures when moving the Hibernate Session from all method signatures into the constructors (can your IDE do that?!) </matt> My framework does require me to pass the Hibernate Session. Spring handles it for you. Passing it to all methods is same as passing around JDBC connection in the old days. Spring makes it completely painless. You should look at Spring's Hibernate and Transaction support, it's well documented. Prashant Rane

Posted by Prashant Rane on October 27, 2003 at 01:51 AM MST #

Post a Comment:
  • HTML Syntax: Allowed