Community: Java Tools Archives
EclipseZone writes about NetBeans winning "bossie" award
Posted by ddevore on September 19, 2007 at 08:12 AM | Permalink
| Comments (7)
EclipseZone has an article on NetBeans winning the bossie award which ended up being a better article than I expected. The article can be found here the bossie article can be found here.
I have been a long time NetBeans user and have used Eclipse in the past. My preference is NetBeans though I know Eclipse is a good ide also. The reason my preference has become NetBeans is because it has more out of the box than Eclipse and I would like getting as much as I can from the original and not have to worry about plugins. Some of the comments on the article were that Eclipse has more plugins and I can see why they would. First it has a larger user base and second it has less out of the box so it needs them. Another said that Eclipse beats NetBeans hands down for basic Java editing because of code editing, refactoring, and compile-on-save "feature". I don't think that the editing and refactoring are basically the same until NetBeans 6.0 is released. The compile-on-save is more of a nuisance to me than anything else. How many times have you saved a file and had Eclipse go into the world of not responding?
I am done commenting on their comments you can read them yourself here. What I think the IDE wars will come down to is the people ingrained in one or the other will stay with it unless thy meet someone who has a very strong conviction on the other convinces them to give it a try. They may try it but will not likely change for good. Then you have the people on the fence they will change from one to the other and will not end up using either significantly more than the other.
The only way I can see this scenario changing is if something happens to one of them that either spring boards them well above the other or one of the companies goes out of business, both very unlikely. If NetBeans wants to be have the larger market share they will have to get partners involved to promote NetBeans as the base of their tools. Eclipse does this which is where some of their share comes from. Personally I would rather be a leader than a follower but to increase numbers of users exposed to the wonderful features of NetBeans they will have to do something and this has worked for others.
Now go read the article and let me know what you think.
Maven Repository with NetBeans 5.0
Posted by ddevore on February 17, 2006 at 08:21 AM | Permalink
| Comments (17)
This entry is for using a Maven repository in NetBeans with the ant build process. I have seen a lot of discussion over Maven and its repositories. Personally I would like to use Maven in the NetBeans build but there currently is no direct integration of Maven in the NetBeans. Before you post a comment about the Mevenide, yes I know about that project http://mevenide.codehaus.org/ and http://docs.codehaus.org/display/MEVENIDE/MevenideNetbeans2.0 but the last time I checked it was not integrated into the current build process. I would like to see NetBeans have a switch that would allow you to choose between ant and Maven for building. Until then I am going to stick with the ant build process because NetBeans does such a good job with it.
Now on with adding a Maven repositories into the ant build process within NetBeans. If you are not familiar with Maven please look here for more information about Maven http://maven.apache.org/.
If you are familiar with Maven or have read the above link you will know that there was a version 1 and now a version 2 Maven. Each version has its own repository and setup which is outside of this blog. I will save that discussion for another day. For more information on repositories please see the following links.
Introduction to Repository definitions and artifact resolution
Introduction to Repositories
In integrating Maven I kept the build clean for 2 reasons. First I wanted to make it easily movable from project to project without a lot of modifications. Second it was written so that it could be removed easily because it tries to download the repository files each time you do a build. So on with the files.
There are 3 files needed for this integration. First is the maven-artifact-ant-2.0.2-dep.jar which can be downloaded from here. Second is a POM or Project Object Model which is the build file for Maven. Third is a repository xml file, created originally by someone else that I modified to fit better in the NetBeans build, which is imported into the build.xml.
POM
The POM which we are using is a scaled down version from a complete Maven POM, it is only the dependencies section.
<project>
    <modelVersion>3.0.0</modelVersion>
    <groupId>BMGCH</groupId>
    <artifactId>core_lib</artifactId>
    <version>1.0-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.9</version>
        </dependency>
        <dependency>
            <groupId>j2ee</groupId>
            <artifactId>j2ee</artifactId>
            <version>1.4.2</version>
        </dependency>
    </dependencies>
</project>
The first section; modelVersion, goupId, artifactId, and version are settings for the project and do not have any affect on the build except for they must be there. If you want more information about these fields please see the Maven links above. To be honest I just wanted to get this working so I didn't really care what those values were since they didn't make a difference to the build. The next section is the dependencies section. This is where you define what you are downloading. If you look in a Maven repository it is setup with a directory which coorlates to the groupId, the artifactId is the first part of the jar file name with the dash before the version number. So for instance the log4j dependency listed above is in the directory log4j off the root of the repository then there is a jar directory with the file log4j-1.2.9.jar in it. Now most of the time you will not browsing the repository but we don't have a repository directory setup so I need to.
repository.xml
The repository.xml is where the work actually happens in this process. It looks like the following.
<?xml version="1.0" encoding="UTF-8"?>
<!--
        Document : repository.xml
        Created on : September 30, 2005, 8:15 AM
        Author : ddevore
        Description:
                This is a ant scripting document for utilizing the repository
                functionality included in Maven2. To use this correctly you must have
                the maven-artifact-ant jar file in the maven.lib.dir location. The libs
                downloaded will be located in the lib.dir location. The lib.dir will
                be removed with the clean target for the project.
                For this file to be run correctly you must import it into the main
                build.xml with the following line.
                <import file="repository.xml"/>
                The downloading can be called independently of the build process by
                using the download-libs tagret.
                Upon first checking out a project from CVS which uses the repository
                you will get unresolved references. To fix this simply do a build or
                download-libs on the project, which will download the libs in the proper
                directory.
                NOTE: The libs still need to be added to the NetBeans project.
                This script is setup for the NetBeans build scripts and is dependent
                on them so it will not work without them.
                Properties:
                        lib.dir = The directory for the dependent libs.
                        maven.lib.dir = The directory for the maven ant jar file.
                        maven.lib.jar = The name of the maven ant jar file.
                        maven.remote.repository = The remote repository name to use.
                        maven.repository.type = The type of repository. Valid values are
                                        legacy = Maven 1 repository.
                                        default = Maven 2 repository.
-->
<project name="core_lib-repository" default="default" basedir="."
                xmlns:artifact="urn:maven-artifact-ant-batch">
        <description>Downloads dependent libs defined in the pom.xml.</description>
        <property name="lib.dir" value="build/dependent_libs"/>
        <property name="maven.lib.dir" value="src/lib"/>
        <property name="maven.lib.jar"
                        value="maven-artifact-ant-2.0.2-dep.jar"/>
        <property name="maven.remote.repository"
                        value="http://dev.columbiahouse.com/maven"/>
        <property name="maven.repository.type" value="legacy"/>
        <typedef resource="org/apache/maven/artifact/ant/antlib.xml"
                        uri="urn:maven-artifact-ant-batch">
                <classpath>
                        <pathelement location="${maven.lib.dir}/${maven.lib.jar}" />
                </classpath>
        </typedef>
        <target name="download-libs" depends="init">
                <artifact:pom id="maven.project" file="pom.xml" />
                <artifact:dependencies pathId="dependency.classpath"
                                filesetId="dependency.fileset">
                        <pom refid="maven.project"/>
                        <remoteRepository url="${maven.remote.repository}"
                                        layout="${maven.repository.type}" />
                </artifact:dependencies>
                <copy todir="${lib.dir}" flatten="true">
                        <fileset refid="dependency.fileset" />
                </copy>
        </target>
        <target name="-pre-compile" depends="download-libs"/>
</project>
What this all means is this. First the project name attribute. I put the project name with a -repository at the end to make it unique, if you don't do this you will get a warning running the project because the name is already declared. The properties are fairly easy to see. The lib.dir is where where the libs will be downloaded to, I put them in the build directory so they will not be put into CVS. The maven.lib.dir and maven.lib.jar is the directory and file name for the maven-artifact-ant jar file. The maven.remote.repository is the location of the repository with the maven.repository.type being the type, legacy means it is a Maven 1 repository. After that it is defining and running the task. The last target is telling the NetBeans build process to download the libs before doing a compile.
To get this to be included in the build you must include it in the build.
<import file="repository.xml"/>
<import file="nbproject/build-impl.xml"/>
The repository.xml must be before the build-impl import or it will not be imported.
maven-artifact-ant-2.0.2-dep.jar
The only thing left is to put the maven-artifact-ant-2.0.2-dep.jar in the proper place. From my repository.xml you can see that I put it in the src/lib directory. Put it in the proper directory and you will be good to go.
Good and Bad
This allows you to pull libs from a Maven repository so you don't have to store them in CVS and you always have the latest. There are 3 problems with this though.
1. When you check out a project you will have unresolved dependencies so you will have to either run the download-libs target or do a build.
2. Wnen you clean you will again get unresolved dependencies. This is a problem with where I put the libs. If you put them outside the build or dist directory you won't loose them upon a clean but NB will then want to put them into CVS.
3. It wants to download them each and every time you build which is not that big of a problem unless you have a large project or a lot of dependent projects then it could take some time. This can be fixed by either removing the import for the repository.xml from the build, which will remove the repository capabilities completely, or take out the -pre-compile target from the repository.xml. Taking out the -pre-compile would be the safest since you can still run the download-libs target with this method.
Sun Java Studio Creator 2 Released
Posted by ddevore on January 26, 2006 at 08:05 PM | Permalink
| Comments (0)
I have been a part of the Creator 2 EA program for about 3 months now and have loved testing it out. This IDE makes web development using JSF as easy as drawing a page on a white board.
If you have not tried it do what I am doing right now and download it. Give it a try and you will see that it is by far the best IDE for web page design available today.
http://developers.sun.com/prodtech/javatools/jscreator/downloads/
Also, let me know what you think about it and how it works. As I work with it I will be blogging my experiences. If there is something you would like to say comment here.
How To Refresh Web Services in Creator 2
Posted by ddevore on January 26, 2006 at 06:14 AM | Permalink
| Comments (0)
If you are developing a front end for Web Services in Creator 2 and need to make a change to the Web Service currently there is no automatic way to tell Creator to refresh the Web Service and regenerate the libs for the service. This document will walk you through refreshing the web service so that you can see the changes made to the Web Service.
Remove the Web Service from the Project
First you must remove all references to the Web Service from the pages which currently use it. To do this you must remove the references to the service from each page which uses it. First select the page and select the Outline tab on the lower half of the left side of the screen. Find the reference to the service and delete it. Then select the Java button to open the Java source for the page. Since the reference for the service has been deleted the references to the service should show as an error, comment out all references to the service. Once you have done this for allpages which reference the service click on the Servers and select the Web Services section and delete the reference to the service from the list of services. Once all references to the service are removed clean the project and shut down Creator.
Remove the libs
Next you must remove the libs from the lib directory. To do this go to the project directory and expand the lib/webservice_clients directory, this is where all generated Web Service libs are held. The libs for the Web Service will begin with the service name for the service I am working with it is ChangeofAddress so my files are named like this:
ChangeofAddress-1133983181995.jar
ChangeofAddress-1133983181995DesignTime.jar
Remove these files.
Remove references from project properties
Next we must remove the references from the projects properties. Go to the project directory and expand the nbproject directory. Edit the project.properties file and search for the lines with the service name. You will find 3 references to the libs. The first is easy simply remove the lines. The second and third you must modify the line above it for the project to properly open. The following is a list of the references and how to modify them to remove them from the project properly.
1. Remove these lines
file.reference.ChangeofAddress-1133983181995.jar
=lib/webservice_clients/ChangeofAddress-1133983181995.jar
file.reference. ChangeofAddress-1133983181995DesignTime.jar
=lib/webservice_clients/ChangeofAddress-1133983181995DesignTime.jar
2. Modify as follows
    ${libs.WEBSVC_SUPPORT_LIB.classpath}:\
    ${file.reference.ChangeofAddress-1133983181995.jar}:\
    ${file.reference.ChangeofAddress-1133983181995DesignTime.jar}
# Space-separated list of extra javac options
Modify like this
    ${libs.WEBSVC_SUPPORT_LIB.classpath}
# Space-separated list of extra javac options
Keep in mind that if there are more services being referenced there may be more jar files listed. The important thing to remember is that if this is the last in the list REMOVE the :\ at the end before the # Space-separated list of extra javac options line.
3. Modify as follows
    ${libs.WEBSVC_SUPPORT_LIB.classpath}:\
    ${file.reference.ChangeofAddress-1133983181995.jar}:\
war.ear.name=LibTest.war
Modify like this
    ${libs.WEBSVC_SUPPORT_LIB.classpath}
war.ear.name=LibTest.war
Once again keep in mind that if there are more services being referenced there may be more jar files listed. The important thing to remember is that if this is the last in the list REMOVE the :\ at the end before the war.ear.name=LibTest.war line.
Next edit the project.xml file and remove the references to the libs there. There are 2 references in this file and can be simply removed. The following is the example for the service I am removing.
The first is a reference to both jar files, remove them with the library files begin and end tags.
                <library files="1">
                    <file>${file.reference.ChangeofAddress-1133983181995.jar}</file>
                </library>
                <library files="1">
                    <file>${file.reference.ChangeofAddress-1133983181995DesignTime.jar}</file>
                </library>
The second is a reference to the actual service client jar file, remove it with the library files begin and end tags.
                <library files="1">
                    <file>${file.reference.ChangeofAddress-1133983181995.jar}</file>
                    <path-in-war>WEB-INF/lib</path-in-war>
                </library>
Resume Development
Once those are removed youcan continue development. Start Creator, add the service back to the Servers | Web Services, add it back to the pages which need it and uncomment the code commented out while removing it from the project. Once this is done you will see the changes. Please note that when you add a service to a page a second time it may change the object reference like this changeofAddressClient2 instead of changeofAddressClient1 so you may need to modify some of the code you commented out to reflect this change.
Notes
I have been told that they are working on this problem but since I have run into it I figured that some other prople would have also and they might want to know how to insure they were working on the latest version.
|