Re: Delayed properties resolving

Daniel Tihelka <[email protected]>
Newsgroups gmane.comp.java.cruise-control.user
Organization KKY
Message-ID <[email protected]>
Hallo Antoine,

thank you very much for your hint. I have tried it using properties file 
included into subprojects. It is working, however, not nice solution - you 
have settings in 2+ files, which makes it harder to administrate :-( ...

I include the listing of simple project I have tried.

Thank you very much again.
Dan


properties.base.xml
----------------

<?xml version="1.0"?>
<cruisecontrol>

    <!-- Define all default values -->
    <property name="prop.about1" value="default value for 1st 'about' 
property" />
    <property name="prop.about2" value="default value for 2nd 'about' 
property" />
    <property name="prop.about3" value="default value for 3rd 'about' 
property" />

    <!-- include sub-projects -->
    <include.projects file="${cruise.projects.dir}/properties.project1.xml" />
    <include.projects file="${cruise.projects.dir}/properties.project2.xml" />

</cruisecontrol>


properties.txt
----------------

#
# There are just complicated definitions. No default values must occure here!
#
prop.text1 = this is text about ${prop.about1} and ${prop.about2}. What do 
yout think about it?
prop.text2 = this is another text just about ${prop.about3}. Really cool.
prop.text3 = texts "${prop.about1}" and "${prop.about3}" are not very 
interesting, though.



properties.project1.xml
----------------

<?xml version="1.0"?>
<cruisecontrol>

  <!-- Define the project -->
  <project name="properties1" buildafterfailed="true">

    <!-- Run all the time -->
    <modificationset>
      <alwaysbuild />
    </modificationset>

    <!-- Re-define some default values -->
    <property name="prop.about1" value="3 pigs" />
    <property name="prop.about3" value="my little ponny" />

    <!-- Include propertis from file  -->
    <property file="${cruise.projects.dir}/properties.txt" />

    <!-- Just print properties ...  -->
    <schedule interval="60" >
      <composite>
        <exec  command="echo"  args="prop.text1: ${prop.text1}" />
        <exec  command="echo"  args="prop.text2: ${prop.text2}" />
        <exec  command="echo"  args="prop.text3: ${prop.text3}" />
      </composite>
    </schedule>

  </project>
</cruisecontrol>



properties.project2.xml
----------------

<?xml version="1.0"?>
<cruisecontrol>

  <!-- Define the project -->
  <project name="properties2" buildafterfailed="true">

    <!-- Run all the time -->
    <modificationset>
      <alwaysbuild />
    </modificationset>

    <!-- Re-define some default values -->
    <property name="prop.about2" value="all the special ways of handling 
properties in CruiseControl" />

    <!-- Include propertis from file  -->
    <property file="${cruise.projects.dir}/properties.txt" />

    <!-- Just print properties ...  -->
    <schedule interval="60" >
      <composite>
        <exec  command="echo"  args="prop.text1: ${prop.text1}" />
        <exec  command="echo"  args="prop.text2: ${prop.text2}" />
        <exec  command="echo"  args="prop.text3: ${prop.text3}" />
      </composite>
    </schedule>

  </project>
</cruisecontrol>



Output is:
----------------

...

2010-03-19 11:00:05,196 [Thread-13974] INFO  ProjectController - properties1 
Controller: build progress event: now building
2010-03-19 11:00:05,226 [Thread-13976] INFO  ScriptRunner     - prop.text1: 
this is text about 3 pigs and default value for 2nd about property. What do 
yout think about it?
2010-03-19 11:00:05,258 [Thread-13979] INFO  ScriptRunner     - prop.text2: 
this is another text just about my little ponny. Really cool.
2010-03-19 11:00:05,357 [Thread-13982] INFO  ScriptRunner     - prop.text3: 
texts 3 pigs and my little ponny are not very interesting, though.
2010-03-19 11:00:05,277 [Project properties2 thread] INFO  Project          - 
Project properties2:  in build queue

...

2010-03-19 11:00:05,398 [Thread-13984] INFO  Project          - Project 
properties2:  now building
2010-03-19 11:00:05,398 [Thread-13984] INFO  ProjectController - properties2 
Controller: build progress event: now building
2010-03-19 11:00:05,420 [Thread-13986] INFO  ScriptRunner     - prop.text1: 
this is text about default value for 1st about property and all the special 
ways of handling properties in CruiseControl. What do yout think about it?
2010-03-19 11:00:05,442 [Thread-13989] INFO  ScriptRunner     - prop.text2: 
this is another text just about default value for 3rd about property. Really 
cool.
2010-03-19 11:00:05,464 [Thread-13992] INFO  ScriptRunner     - prop.text3: 
texts default value for 1st 'about' property and default value for 3rd 'about' 
property are not very interesting, though.
2010-03-19 11:00:05,465 [Thread-13984] INFO  ProjectController - properties2 
Controller: build result event: build successful        

...



On Monday 08 March 2010 01:29:02 Antoine Levy Lambert wrote:
> Hello Dan,
> 
> I understand what you want now. If you define cmnd.opts inside proj1.xml
> and proj2.xml instead of in the top most config.xml,
> you should be fine. It is true that it is a repetition.
> 
> A way to avoid this repetition would be to use an entity include, or to
> define projects which are similar using a plugin definition.
> 
> see http://confluence.public.thoughtworks.org/display/CC/ConfigFiles
> 
> Regards,
> 
> Antoine
> 
> Dan Tihelka wrote:
> >> I am not sure what is the problem with the current behavior of
> >> CruiseControl. Do you want to change property values during builds ?
> >>
> >> Or do you have some key/values pairs defined in external property files
> >> which you change externally ?
> >
> > Not exactly. The setting is "fixed" in project XML files, but imagine the
> > following situation:
> >
> > <!-- TOM-MOST projects definition file -->
> > <cruisecontrol>
> >
> >   <!-- default property values, shared by more projects -->
> >   <property name="prop1"  value="val1_default"/>
> >   <property name="prop2"  value="val2_default"/>
> >   <property name="prop3"  value="val3_default"/>
> >   <property name="prop4"  value="val4_default"/>
> >
> >   <!-- defines default command behaviour:
> >        binary -a val1_default -b val2_default -c val3_default -d
> > val4_default -->
> >   <property name="cmnd.opts"  value="-a ${prop1} -b ${prop4} -c ${prop3}
> > -d ${prop4}"/>
> >
> >   <include.projects file="proj1.xml" />
> >   <include.projects file="proj2.xml" />
> >
> > </cruisecontrol>
> >
> >
> >
> > <!-- proj1.xml -->
> > <cruisecontrol>
> >
> >   <!-- needs to redefine some properties
> >   <property name="prop2"  value="val2_new"/>
> >
> >   <!-- require to execute command:
> >         binary -a val1_default -b val2_new -c val3_default -d
> > val4_default
> >
> >         but executes the default command:
> >         binary -a val1_default -b val2_default -c val3_default -d
> > val4_default -->
> >    <schedule>
> >         <exec  command="binary" args="${cmnd.opts}" />
> >    </schedule>
> >
> > </cruisecontrol>
> >
> >
> >
> > <!-- proj2.xml -->
> > <cruisecontrol>
> >
> >   <!-- needs to redefine some properties
> >   <property name="prop1"  value="val1_new"/>
> >   <property name="prop4"  value="val4_new"/>
> >
> >   <!-- require to execute command:
> >         binary -a val1_new -b val2_default -c val3_default -d val4_new
> >
> >         but executes the default command:
> >         binary -a val1_default -b val2_default -c val3_default -d
> > val4_default -->
> >    <schedule>
> >         <exec  command="binary" args="${cmnd.opts}" />
> >    </schedule>
> >
> > </cruisecontrol>
> >
> >
> > Is it more clear?
> > Kind regards,
> > Dan T.
> >
> >> I have hacked CruiseControl to read properties from LDAP, giving the
> >> possibility to create one property per attribute found in a LDAP
> >> directory context.
> >>
> >> I am using this mechanism to define branch specific parameters, for
> >> instance the name of the UT WebSphere Server and the name of the
> >> Selenium WebSphere server.
> >>
> >> I did not submit this change in JIRA yet but would be interested to.
> >> Since this one is using only JNDI it does not require external
> >> libraries.
> >>
> >> Regards,
> >>
> >> Antoine
> >>
> >> Daniel Tihelka wrote:
> >>> Dear CruiseControl users and developers.
> >>>
> >>> No idea or just not interesting feature? I want have to know ...
> >>>
> >>> If you are interested, just write me few notes of your opinion about
> >>> the best way of implementing it, or where I should start to examine
> >>> possibilities, and I will try to implement it (to Dan Rollo: taking
> >>> care for all the tests this time ;-) ).
> >>>
> >>> Should I open new JIRA issue?
> >>>
> >>> Thank you very much,
> >>> Dan T.
> >>>
> >>>> So, what to do with it?
> >>>>
> >>>> - there already is a way of achieving it. Please, if you know the way,
> >>>> let me
> >>>
> >>> know ...
> >>>
> >>>> - change the behavior of CC to resolve the properties at the last
> >>>> moment,
> >>>
> >>> just before they are used. However, it may change the behavior of CC,
> >>> and someone may rely on it. Therefore, I expect it is hardly acceptable
> >>>
> >>>> - add new optional attribute to <property /> tag, something like
> >>>
> >>> "delayresolving=true", with default to "false" if not set; that would
> >>> cause the resolving of properties to the last moment before they are
> >>> required; the original behavior will stay unaffected
> >>>
> >>>> - ??? any better/cool idea?
> 
> ---------------------------------------------------------------------------
> --- Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> Cruisecontrol-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/cruisecontrol-user
>

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev

_______________________________________________
Cruisecontrol-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cruisecontrol-user
signature.asc (application/pgp-signature, 198 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.11 (GNU/Linux)

iEYEABECAAYFAkujT34ACgkQuYlVhxo/P1EpvgCfcLxzVcSjqI4sjylD6QTMImNZ
I+YAni2INF5g7bns3gCffRhXmgKhGkHl
=sv8w
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.