8 Replies Latest reply on Jun 14, 2007 8:55 AM by 577684

    JDeveloper extension : JDevLibsForAnt

    Jan Vervecken
      hi

      I would like to be able to use Ant to compile and package my code, but I don't want to maintain libraries in two places, JDeveloper and Ant.

      My first approach was to call JDeveloper from Ant using a custom JDeveloper extension that provides an MBean to "access" the JDeveloper extension API.
      http://verveja.footsteps.be/~verveja/files/oracle/CallJDevApps-v0.01.zip
      Although it "works", it is intended to be used from within JDeveloper.

      My second approach was to have a custom JDeveloper extension automatically maintain an Ant build file on each library change in JDeveloper. This Ant build file can than be imported into another Ant build file.
      http://verveja.footsteps.be/~verveja/files/oracle/JDevLibsForAntApps-v0.01.zip

      Although this does what I want, I have a few questions:
      (1) What is the preferred way to get the "outputDirectory" of a Project (see LibrariesProjectChangeListener$MyJProjectPaths)?
      (2) How can I get notified of changes to my custom project options (see JDevLibsForAntOptionsPanel and LibrariesProjectChangeListener.isChangeLibraryRelated())?

      All suggestions for improvement are welcome.

      many thanks
      Jan Vervecken
        • 1. Re: JDeveloper extension : JDevLibsForAnt
          Brian.Duff
          Hi Jan,

          You can get the output directory of a project via:
          JavaProject javaProject = JavaProject.getInstance( project );
          URL outputDir = javaProject.getOutputDirectory();
          To receive notification of changes to the project, you can attach a StructureChangeListener to a specific hash structure, or to the whole hash structure of the project.
          someProject.getProperties().addStructureChangeListener( new StructureChangeListener() {
            public void structureValuesChanged( StructureChangeEvent event ) {
            }
          });
          You might be interested in the jd-ant open source project I recently started on google code:

          http://code.google.com/p/jd-ant/

          It's still in a very early incubation stage. But the goal of this project is to provide ant tasks that will comprehensively build a JDeveloper project from outside the IDE. It intentionally does not directly depend on any IDE APIs - instead it contains a stripped down version of HashStructureIO so that it can process project files directly.

          Thanks,
          Brian
          • 2. Re: JDeveloper extension : JDevLibsForAnt
            Jan Vervecken
            Thanks for your reply Brian.

            I will take a look at the getOutputDirectory() method and StructureChangeListener you suggest.

            I've looked at some of the source in your jd-ant project. It is an interesting idea, but I have a question.
            I suppose you 'll also need some way to find out what particular JAR files constitute a library defined in JDeveloper?
            For example, in a JDeveloper project file like this ...
            http://jd-ant.googlecode.com/svn/trunk/jdant/jdant.jpr
            ... there is a reference to some "Apache Ant" library.
            How do you plan on accessing the details of such a library?

            regards
            Jan
            • 3. Re: JDeveloper extension : JDevLibsForAnt
              Brian.Duff
              Hi Jan,

              I'm planning to implement that by processing the extension manifest information in the product (which is where those libraries are defined).


              Thanks,
              Brian
              • 4. Re: JDeveloper extension : JDevLibsForAnt
                Brian.Duff
                Writing about it inspired me to actually do the implementation ;) Still a WIP, but you can see the code for this here:

                http://jd-ant.googlecode.com/svn/trunk/jdant/src/org/dubh/jdant/Library.java
                http://jd-ant.googlecode.com/svn/trunk/jdant/src/org/dubh/jdant/LibraryScanner.java

                Performance was my major concern with this, but as it turns out, it seems to take a tiny fraction of a second to process all the extension manifests in the whole product and find library definitions :)

                Thanks,
                Brian
                • 5. about jd-ant
                  Jan Vervecken
                  Thanks for your reply Brian, that was some fast coding. :)

                  I've tried your code, and indeed it is feasible to access library details.

                  I wonder why you started jd-ant as an open source project.
                  Does this mean that Oracle doesn't plan better support for "building JDeveloper applications without JDeveloper"?

                  regards
                  Jan
                  • 6. Re: JDeveloper extension : JDevLibsForAnt
                    Jan Vervecken
                    hi Brian

                    I looked at the getOutputDirectory() method and StructureChangeListener you suggested.

                    I could use the getOutputDirectory() method without any problems, but using a StructureChangeListener the way you suggested did not seem to execute the structureValuesChanged() method for me, maybe I did something wrong.
                    However, I've been able to get notified of changes to my custom project options using Project.addProjectChangeListener() using the correct property name.

                    I also managed to introduce a context menu option on projects to explicitly "merge" to the output file.

                    These changes are available in an updated extension at
                    http://verveja.footsteps.be/~verveja/files/oracle/JDevLibsForAntApps-v0.02.zip

                    regards
                    Jan Vervecken
                    • 7. Re: about jd-ant
                      Brian.Duff
                      Hi Jan,

                      I started it as an open source project only because I have a couple of other open source JDeveloper extension projects which were previously using hand-coded ant buildfiles that I want to update and move to google code.

                      As a plus point, I can also leverage the stuff I'm doing in this google code project on our internal build system. One of my side projects internally over the last year or so has been improving this system. It's currently primarily driven by jpr files (which is an ideal way to work for us), but the code to support it is pretty gnarly and slow - it uses DOM to parse project files, and some fragile XPath expressions.

                      Please don't take anything I did as an indication of Oracle's plans to do one thing or another ;)

                      I'll look into the listener thing when I'm back in the office tomorrow (enjoying memorial day today...). AFAIK, it should work for anything based on HashStructure, so perhaps there's something subtle about the way it interacts with projects specifically.

                      Thanks,
                      Brian
                      • 8. Re: JDeveloper extension : JDevLibsForAnt
                        577684
                        I was interested to read your dialogue because I too am trying to use Ant to automate the build and deployment of JDeveloper projects. I have to say that I'm a total newcomer to JDeveloper, Ant and Java, so much of what you're saying is way above my head!

                        I've achieved some degree of success with BPEL modules, mainly by using a <for> task to iterate over the build.xml files created by JDeveloper. However I'm coming unstuck with the non-BPEL bits; I know what keystrokes are required to tell JDeveloper how to do the job manually, but I have very little clue about what goes on under the bonnet when I initiate a deployment, so replicating it in my Ant project is well-nigh impossible; furthermore the build.xml files produced by JDeveloper for the non-BPEL stuff all seem to stop short of actually doing the deployment - either to a server or to jar/war/ear files.

                        I then came across the JDeveloper Ant task <jdev> at http://www.oracle.com/technology/products/jdev/htdocs/partners/addins/exchange/anttasks/index.html
                        which sounded as though it might help. However I encountered some difficulty in getting it to do anything useful other than simply firing up JDeveloper, so I am currently having a dialogue with its author, Gerard Davison at Oracle, to try and get some help. He also suggested a tool called ojmake, which is available in the jdev/bin directory of the Technology Preview for 11, which I've also tried playing with, but I can't get it to work in JDev 10.

                        Does anybody out there have any knowledge either of the <jdev> Ant task or ojmake, or of any other tools that might help in this situation?