how to pass in ant.build.clonevm? - ant

I'd like to pass properties(-Dname=val) down to junit&java tasks from the Ant command line. The problem is the -3rd party- build file doesn't pass those properties down.
I was thinking ant.build.clonevm could help, but the manual says
Note that this has to be a system property, so it cannot be specified
on the Ant command line.
So, can I use this for the above purpose, and how? If not, any other alternatives?
Thanks for any hints.

Use the ANT_OPTS environment variable instead.
set ANT_OPTS=-Dxxx=value
xxx is your property

Related

Is there a way to order properties in a maven archetype? [duplicate]

Anybody knows is it possible to make substitution for default value of one requredProperty to another in archetype-metadata.xml ?
So, I try to do something like this:
<requiredProperty key="name"/>
<requiredProperty key="groupId">
<defaultValue>com.mycompamy.${name}</defaultValue>
</requiredProperty>
But when I start to generate project from artifact in interactive mode, maven asks me about groupId property first. But not for name as I expected.
Is it possible to change this behaviour?
Your problem is caused by required property loading order. Maven loads every custom required property in alphabetical order. You probably cant change it. But there are 2 ways which will solve your problem:
Renaming ur variables like this:
"0_name"
"1_groupId"
Now it will ask you about name firstly.
Use full maven command, passing only name parameter
mvn archetype:generate -DarchetypeGroupId=?? -DarchetypeArtifactId=?? -DgroupId=?? -DartifactId=?? -Dversion=?? -Dpackage=?? -Dname=??
Replace ?? with valid parameters
Hope it will helps you.
EDIT: now i see an asked time. Pretty offtopic but maybe it will help someone else

How to change a tfs build variable in script

I'm using TFS2015 update 1. I want to pass information from one build step to the next, how is this possible?
That seems like a very simple task, but I can't figure out how that's suppose to work. Passing a variable to a build step is easy, but passing information from one step to the next seems to be impossible. I hope I'm wrong.
You can call the task.setvariable Logging Command, which sets a variable in the variable service of taskcontext. The first task can set a variable, and following tasks are able to use the variable. The variable is exposed to the following tasks as an environment variable.
Example:
##vso[task.setvariable variable=testvar;]testvalue

Set a system property with ant

I have an ant script which has a taskdef and the task creates an https internet connection and somethin with that SSL stuff is wrong. Thus I want to set the system property javax.net.debug=all to get some more information.
In java I would do this using the -D option, but in ant this is used for ant properties which is not the same as a system property.
If this wouldn't be a taskdef but instead a java task, I could use the sysproperty property, but it is no java-task.
Googling for this is frustratingly complicated because ant properties and system properties in ant are so similar that most search results are about the other (or about the java-task).
Obviously I am not the only one with the problem, but other people's questions that I have found (like here) are unanswered or went for hack (like here).
One way to set such a property is the ANT_OPTS system variable. You have to be very carefully to not simply skim over answers on google that state that options can be set that way, because it sounds so much like not what it does:
The documentation says:
ANT_OPTS - command-line arguments that should be passed to the JVM.
For example, you can define system properties or set the maximum Java
heap size here.
Who what have expected that? ANT_OPTS are options for the JVM and not for ant like the name suggests. The var which is used for ant options is called ANT_ARGS.
Now I can launch ant like this: ANT_OPTS="-Djavax.net.debug=all" ant myTarget and can see tons of log output.
(However this leaves the question open whether such a variable can be set using XML).
You can declare system properties in the xml with <sysproperty key="key" value="value"/>.
http://www.java2s.com/Code/Java/Ant/SetsystempropertiesinAntbuildscript.htm
You can use scripting:
<script language="javascript">
java.lang.System.setProperty('myKey', 'myValue');
</script>

Is there a way to initialize variables with erl?

I'd like to do things like L=lists, X=very_long_module_name. There's some modules I use a lot and I'd rather type X:function() than very_long_module_name:function(). The .erlang file seems to be able to run commands but it doesn't keep any variable assignments. For all know you can only use .erlang to add more things to path.
maybe you could use macros? i.e. -DL=lists and then ?L:function() ?

How to add a set path only for that batch file executing?

Basically, I know I can go through my control panel and modify the path variable. But, I'm wondering if there is a way to through batch programming have a temporary path included? That way it is only used during that batch file execution. I don't want to have people go in and modify their path variables just to use my batch file.
Just like any other environment variable, with SET:
SET PATH=%PATH%;c:\whatever\else
If you want to have a little safety check built in first, check to see if the new path exists first:
IF EXIST c:\whatever\else SET PATH=%PATH%;c:\whatever\else
If you want that to be local to that batch file, use setlocal:
setlocal
set PATH=...
set OTHERTHING=...
#REM Rest of your script
Read the docs carefully for setlocal/endlocal , and have a look at the other references on that site - Functions is pretty interesting too and the syntax is tricky.
The Syntax page should get you started with the basics.
There is an important detail:
set PATH="C:\linutils;C:\wingit\bin;%PATH%"
does not work, while
set PATH=C:\linutils;C:\wingit\bin;%PATH%
works. The difference is the quotes!
UPD also see the comment by venimus
That's right, but it doesn't change it permanently, but just for current command prompt.
If you wanna to change it permanently you have to use for example this:
setx ENV_VAR_NAME "DESIRED_PATH" /m
This will change it permanently and yes, you can overwrite it in another batch script.

Resources