1 2 Previous Next 22 Replies Latest reply on Apr 1, 2009 8:21 AM by erimag

    configuring dev vs. prod modes for builds

    gonorrhea

      I am using seam-gen's build.xml from 2.0.2-FP


      I need to do builds for dev and prod.


      current components.xml snippet:


      <core:init debug="@debug@" jndi-pattern="@jndiPattern@"/>



      debug is a variable located in components.properties


      current web.xml snippet:


      <!-- Facelets development mode (disable in production) -->
         
         <context-param>
            <param-name>facelets.DEVELOPMENT</param-name>
            <param-value>true</param-value>
         </context-param>



      refactored web.xml snippet:


      <!-- Facelets development mode (disable in production) -->
         
         <context-param>
            <param-name>facelets.DEVELOPMENT</param-name>
            <param-value>|@facelets_mode@|</param-value>
         </context-param>



      How can I achieve this so that when I run 'ant explode' or 'ant deploy' the correct variable for facelets_mode is dynamically used?  Must I pass a variable like this via ant cmd line?


      ant deploy -Dfacelets_mode=prod



      Is it possible to configure this so it from facelets_mode=prod from a .properties file like components.properties?  Or is it a runtime parameter that must be passed to the JVM b/c it's the deployment descriptor for the servlet(s)?


      How bout including only one of two different web.xml (one web.xml for prod in one directory, one web.xml for dev in another direcotry) files in the build.xml depending on the value of facelets_mode variable?


      Any other configs I need to do or be aware of for dev vs. prod builds?  I know that the foo-dev-ds.xml and foo-prod-ds.xml is already handled in my build.xml via:


      <property name="profile" value="dev" />
      <property file="build-${profile}.properties" />

        • 1. Re: configuring dev vs. prod modes for builds
          gonorrhea

          DAllen sheds some light:


          A majority of your time working in the view will be spent developing JSF pages. You
          certainly want those changes to be picked up as well. If you’re using JSP for your JSF
          pages, you’re already covered. However, projects created by seam-gen use Facelets as
          the JSF view technology. Facelets will not read a view template more than one time
          unless it’s running in development mode. This mode is the complement to runtime
          JSP compilation. To enable development mode, you just need to ensure that the build-
          <profile>.properties file for your profile has the debug property set to true:
          debug=true
          When the build is run, this property will be applied to the web.xml descriptor, setting
          the facelets.DEVELOPMENT servlet context parameter in the web.xml descriptor to
          true:



          <context-param>
          <param-name>facelets.DEVELOPMENT</param-name>
          <param-value>true</param-value>
          </context-param>



          So how does this work if I don't have a variable for my facelets.DEVELOPMENT param-value?

          • 2. Re: configuring dev vs. prod modes for builds
            joblini

            Hi Ron,


            Why not make it a variable, for example @debug@, then in build.xml


            <filterset>
                 <filter token="debug" value="${debug}" />
            </filterset>



            • 3. Re: configuring dev vs. prod modes for builds
              gonorrhea

              Ingo Jobling wrote on Mar 25, 2009 22:52:


              Hi Ron,

              Why not make it a variable, for example @debug@, then in build.xml

              <filterset>
                   <filter token="debug" value="${debug}" />
              </filterset>






              Hey thx a lot for the reply.  From your idea I found section 12.4 Customizing web apps in the Java Development with Ant book which is very helpful as well.


              You can literally uncomment code in web.xml with the example in the book...


              This is their solution in the build.xml:


              <copy todir="build/WEB-INF" file="web/WEB-INF/web.xml" overwrite="yes">
              <filterset>
                  <filter token="start.cactus.config" value="--&gt;">
                  <filter token="end.cactus.config" value="&lt;!--"
              </filterset>
              </copy>

              • 4. Re: configuring dev vs. prod modes for builds
                gonorrhea

                Well I tried incorporating this into my build.xml for the war target:


                <copy todir="${war.dir}/WEB-INF"
                        file="${basedir}/resources/WEB-INF/web.xml"
                        overwrite="yes">
                        <filterset>    
                          <filter token="facelets-debug" value="${debug}"/>                       
                        </filterset>
                </copy>



                in addition to this in the web.xml:


                <context-param>
                      <param-name>facelets.DEVELOPMENT</param-name>
                      <param-value>@facelets-debug@</param-value>
                   </context-param>



                And now the following folder is read-only:


                \exploded-archives\BETS.war\WEB-INF



                and I am getting this build error when I run 'ant clean':


                C:\java\projects\BETS\build.xml:284: Unable to delete file C:\java\projects\BETS\exploded-archives\BETS.war\WEB-INF



                very strange.  I closed JBDS and windows explorer and I still can't manually delete the WEB-INF folder...

                • 5. Re: configuring dev vs. prod modes for builds
                  gonorrhea

                  WEB-INF is not accessible.  access is denied.

                  • 6. Re: configuring dev vs. prod modes for builds
                    gonorrhea

                    so that access problem seems to have been an anomaly.


                    I found the following tip in Seam in Action for components.properties:


                    debug=#{facesContext.externalContext.request.serverName eq 'localhost'}



                    Is it possible to use EL in web.xml?


                    e.g.:


                    <context-param>
                          <param-name>facelets.DEVELOPMENT</param-name>
                          <param-value>#{facesContext.externalContext.request.serverName eq 'localhost'}</param-value>
                       </context-param>

                    • 7. Re: configuring dev vs. prod modes for builds
                      gonorrhea

                      I just ran 'ant clean war' for my seam-gen'd project.


                      Here is the original tokenized line from components.xml:


                      <core:init debug="@debug@" jndi-pattern="@jndiPattern@"/>



                      and here is the resulting components.xml after the successful build:


                      <core:init debug="true" jndi-pattern="BETS/#{ejbName}/local"/>



                      and the components.properties:


                      jndiPattern \#{ejbName}/local
                      debug=#{facesContext.externalContext.request.serverName eq 'localhost'}



                      how/when during the build process do the tokenized variables (debug and jndiPattern) get replaced?  'components' is not referenced in my build.xml...


                      • 8. Re: configuring dev vs. prod modes for builds
                        gonorrhea

                        ok so according to new Yuan book:




                        You may notice that the seam-gen project uses a wildcard attribute to determine the value of the debug attribute:

                        <core:init debug="@debug@"/>



                        Wildcard values are determine at runtime based on teh settings in a components.properties file definition.


                        If this is true, then why are my wildcard/tokenized values already replaced right after 'ant war' is run???

                        • 9. Re: configuring dev vs. prod modes for builds
                          gonorrhea

                          I reproduced the locked folder behavior again when I run 'ant clean':



                          Buildfile: C:\java\projects\BETS\build.xml
                               [echo] jboss.home = C:/java/jboss-eap-4.3/jboss-as
                               [echo] ant.home = C:\java\jbdevstudio-2.0.0.CR2\eclipse\plugins\org.apache.ant_1.7.0.v200803061910
                          clean:
                             [delete] Deleting directory C:\java\projects\BETS\exploded-archives\BETS.war
                          
                          BUILD FAILED
                          C:\java\projects\BETS\build.xml:314: Unable to delete directory C:\java\projects\BETS\exploded-archives\BETS.war
                          
                          Total time: 359 milliseconds


                          • 10. Re: configuring dev vs. prod modes for builds
                            gonorrhea

                            I don't see a components.properties file in my ant explode EAR distro... ???

                            • 11. Re: configuring dev vs. prod modes for builds
                              joblini

                              Are you stopping the server (Jboss) when you do clean build?

                              • 12. Re: configuring dev vs. prod modes for builds
                                swd847

                                The seam components.properties substitution uses the same format as ant substitutions, which can be confusing.


                                I use settings in build.properties and deploy.properties:


                                build.properties:


                                
                                build.development=true
                                
                                



                                deploy.properties:


                                deploy.development=true
                                
                                




                                build.xml:


                                <condition property="project.development">
                                          <equals arg1="${build.development}" arg2="true" />
                                </condition>
                                
                                ----------
                                
                                <filter filtersfile="deploy.properties"/>
                                
                                ---------
                                
                                <copy todir="${ear.dir}/lib">
                                  <fileset dir="${lib.dir}/warlib">
                                   <include name="jboss-seam-debug.jar" if="project.development" />
                                 </fileset>
                                </copy>
                                ---------
                                
                                <copy todir="${war.dir}/WEB-INF" filtering="true">
                                     <fileset dir="${basedir}/resources/war/main/WEB-INF">
                                                    <include name="*.*" />
                                     </fileset>
                                </copy>
                                
                                



                                web.xml:


                                 <context-param>
                                  <param-name>facelets.DEVELOPMENT</param-name>
                                  <param-value>@deploy.development@</param-value>
                                 </context-param>
                                
                                



                                There are cleaner ways of doing this I think, but this works for me so I have not looked into it further.

                                • 13. Re: configuring dev vs. prod modes for builds
                                  gonorrhea

                                  Ingo Jobling wrote on Mar 27, 2009 02:11:


                                  Are you stopping the server (Jboss) when you do clean build?


                                  No.  I never do that when in dev/test cycle with 'ant explode' or 'ant restart'.  So i guess the JVM/JBoss process is locking it then...

                                  • 14. Re: configuring dev vs. prod modes for builds
                                    gonorrhea
                                    I stopped the server.  I ran 'ant clean'.  result:

                                    Buildfile: C:\java\projects\BETS\build.xml
                                      [taskdef] Could not load definitions from resource svntask.properties. It could not be found.
                                    clean:
                                       [delete] Deleting directory C:\java\projects\BETS\exploded-archives\BETS.war

                                    BUILD FAILED
                                    C:\java\projects\BETS\build.xml:342: Unable to delete directory C:\java\projects\BETS\exploded-archives\BETS.war

                                    Total time: 359 milliseconds

                                    I noticed that the foo-WAR\WEB-INF folder is read-only and I can't uncheck that permanently (it's read-only when I view folder properties later).  when i delete that WEB-INF folder from windows explorer, I can then run 'ant clean' successfully.

                                    1 2 Previous Next