ant task equivalent to -D<property>=<value>?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

ant task equivalent to -D<property>=<value>?

mvad
I am attempting to pass a system property to one of my custom modules.  This works as expected when running checkstyle from the command with the usage provided on this page:
http://checkstyle.sourceforge.net/cmdline.html
specifically using the java argument "-Dmyvariable=mystring"


However, I have been unable to find an ant task equivalent to passing in these system properties:


Things that I have tried (none of which worked):

1) adding "-Dmyvariable=mystring" as an argument to the ant call

2) http://checkstyle.sourceforge.net/anttask.html
Unless I am misunderstanding, the URL above suggests that adding
<property key="myvariable" value="mystring"/> under <cs:checkstyle>
should have the same effect?

3) <sysproperty>?  Though none of the checkstyle xml elements recognize it, so I am unsure where it could be added.


Any help is appreciated,
Michael
Reply | Threaded
Open this post in threaded view
|

Re: ant task equivalent to -D<property>=<value>?

Oliver Burn
Look at http://checkstyle.hg.sourceforge.net/hgweb/checkstyle/checkstyle/file/e67b3c4c6345/ant-phase-verify.xml for an example of how to do it with ant. See lines 27 to 30.

On Fri, Aug 31, 2012 at 3:34 AM, mvad <[hidden email]> wrote:
I am attempting to pass a system property to one of my custom modules.  This
works as expected when running checkstyle from the command with the usage
provided on this page:
http://checkstyle.sourceforge.net/cmdline.html
specifically using the java argument "-Dmyvariable=mystring"


However, I have been unable to find an ant task equivalent to passing in
these system properties:


Things that I have tried (none of which worked):

1) adding "-Dmyvariable=mystring" as an argument to the ant call

2) http://checkstyle.sourceforge.net/anttask.html
Unless I am misunderstanding, the URL above suggests that adding
<property key="myvariable" value="mystring"/> under <cs:checkstyle>
should have the same effect?

3) <sysproperty>?  Though none of the checkstyle xml elements recognize it,
so I am unsure where it could be added.


Any help is appreciated,
Michael



--
View this message in context: http://checkstyle.2069334.n4.nabble.com/ant-task-equivalent-to-D-property-value-tp4654115.html
Sent from the CheckStyle - User mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Checkstyle-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/checkstyle-user


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Checkstyle-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/checkstyle-user
Reply | Threaded
Open this post in threaded view
|

Re: ant task equivalent to -D<property>=<value>?

mvad
Ok, this example is similar to my #2 attempt, though it may be different from what I am looking for.

In my java code, I am calling System.getProperty(<property-name>) to retrieve the value passed in, which works correctly when running checkstyle from the java command line using "-Dmyvariable=mystring".

In the case of your example, should I be expecting the java statement:
System.getProperty("checkstyle.cache.file")
to return a File object or some kind of non-null value?  My testing indicates not.