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

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

Related

Access process i18n property files before compilation

I have a following situation: in some of my i18n property files there are properties containing a special word:
prop.example=specialword just for example
prop.test=just for test specialword
I want to have a possibility of having a property somewhere in my Config.groovy that would contain a specific value for this specialword so that if I specify:
specialword=Value of special word
in a Config.groovy then I want my i18n properties to be resolved like:
prop.example=Value of special word just for example
prop.test=just for test Value of special word
for that purpose, when building the project, I want to access property files in order to look for occurences of specialword and to replace them with value of specialwordvalue from Config.groovy.
Is that possible somehow? Perhaps, someone faced similar situation? I would really appreciate any help.
Thanks, Cheers
Instead of trying to change the way the properties are compiled, you would be better off passing the special value as an argument to your message code (as discussed in the comments to your question).
For instance:
<g:message code="my.key.code" args="[someVariableWithAValueFromConfig]" />
If your message code doesn't use the argument it will simply be ignored. This seems like the best approach to the problem you are trying to solve.

How to set explain option?

If you issue this command to informix server, the server will just generate explain and won't run the query. Great feature if your query doesn't end at all.
SET EXPLAIN ON AVOID_EXECUTION;
If you issue this command to informix then the Explain file will be generated at that location .
SET EXPLAIN FILE TO 'c:\temp\sql.out';
But, I need both options on and I can't figure out the syntax for doing that. If I execute both statements then the latter overrides the former.
Execute first the SET EXPLAIN FILE TO 'c:\temp\sql.out';, this way you set the target.
Then you change to avoid execution : SET EXPLAIN ON AVOID_EXECUTE;;

How do I perform if/else operations in a jenkins workflow build?

I'm sure there's an easy answer for this but I was unable to find it elsewhere.
I have a Jenkins workflow job with parameters. What I want is to skip a build job depending on the value of a parameter. Something like:
if(param["MYPARAM"]){
build("jorb1")
}
build("jorb2")
Does anyone know how I'd accomplish this?
Turns out the answer is really easy. Hopefully this will help someone else. If statements do work in the DSL configuration. I guess its based on groovy (which I have zero experience with). Anyway my guess was just about right other than specifying the params incorrectly. Below is an example of checking a string parameter:
if(params["MYPARAM"]=="some_value"){
build("jorb1")
}
build("jorb2")

How do I fix 'Setup project with custom action file not found' exception?

I am trying to create a setup project for a Windows Service. I've followed the directions at http://support.microsoft.com/kb/816169 to create the setup project with no trouble.
I want to be able to get a value during the installation in order to update the app.config with the user's desired settings. I added a Textboxes (A) dialog to retrieve the values. I set the Edit1Property property to "TIMETORUN", and in my Primary Output action's CustomActionData property I put in the following: /TimeToRun="[TIMETORUN]\". So far so good. Running the setup I can retrieve the TimeToRun value from the Context.Parameters collection without issue.
In order to locate the app.config I need to also pass in the value of the TARGETDIR Windows Installer Property to my custom action. This is where things begin to fall apart. In order to achieve this, the above CustomActionData must be altered like so: /TimeToRun="[TIMETORUN]\" /TargetDir="[TARGETDIR]\". Now when I run the setup I get the following error message:
Error 1001. Exception occurred while initializing the installation.
System.IO.FileNotFoundException: Could not load file or assembly 'file:///C:\Windows\SysWOW64\Files' or one of its dependencies. The system cannot
find the file specified.
If you google this problem you will inevitably find people having tremendous success by simply adding the trailing slash to the /TargetDir="[TARGETDIR]\" portion of the CustomActionData. This unfortunately does not solve my issue.
I tried so many different variations of the CustomActionData string and none of them worked. I tried logging to a file from my overridden Install method to determine where the breakage was, but no log file is created because it's not even getting that far. As the error indicates, the failure is during the Initialization step.
I have a hunch that it could be one of the dependencies that the setup project is trying to load. Perhaps somehow something is being appended to the CustomActionData string and isn't playing well with the TARGETDIR value (which contains spaces, i.e. "C:\Program Files\My Company\Project Name"). Again, this is another hunch that I cannot seem to confirm due to my inability to debug the setup process.
One further thing to mention, and yes it's another hunch, could this be an issue with Setup Projects on 64-bit version of Windows? I'm running Windows 7 Professional.
I'll provide names of the dependencies in case it helps:
Microsoft .NET Framework
Microsoft.SqlServer.DtsMsg.dll
Microsoft.SqlServer.DTSPipelineWrap.dll
Microsoft.SqlServer.DTSRuntimeWrap.dll
Microsoft.SQLServer.ManagedDTS.dll
Microsoft.SqlServer.msxml6_interop.dll
Microsoft.SqlServer.PipelineHost.dll
Microsoft.SqlServer.SqlTDiagM.dll
As you may glean from the dependencies, the Windows Service is scheduling a call to a DTSX package.
Sorry for the long rant. Thanks for any help you can provide.
The answer is so maddeningly simple. If the last argument in the CustomActionData is going to contain spaces and thus you have to surround it with quotes and a trailing slash, you must also have a space following the trailing slash, like this:
/TimeToRun="[TIMETORUN]\" /TargetDir="[TARGETDIR]\ "
The solution and explanation can be found here.
Had a similar issue. In my case, it was odd because my installer had ran successfully once, then I uninstalled my app via Add/Remove Programs successfully, did some coding (did NOT touch my CustomActionData string), and rebuilt my project and setup project. It was when I re-ran my MSI that I got this error.
The coding I had done was to bring in more values of more parameters I had been specifying in my CustomActionData string. That syntax for getting the parameter values (i.e. string filepath = Context.Paramenters["filepath"]), which was in my Installer class, was actually fine, but as I found out, the syntax of the later parameters I was now trying to get from my CustomActionData string had not been correct, from the very beginning. I had failed to add a second quote around one of those parameters, so nothing else could be obtained.
I was using the "Textboxes (A)" and "Textboxes (B)" windows in the User Interface section. A has 1 box, EDITA1, where I get the path to a file, and B has 2 boxes, EDITB1 and EDITB2, for some database parameters. My CustomActionData string looked like this:
/filepath="[EDITA1]" /host="[EDITB1] /port="[EDITB2]"
It should have been:
/filepath="[EDITA1]" /host="[EDITB1]" /port="[EDITB2]"
(closing quote on [EDITB1])

Appending JVM parameter to the parameter specified explicitly in plugin configuration?

Sometimes I need the parameter to be appended, instead of overriding the one in configuration:
for instance
mvn test -DargLine="-Dportal.test=huge"
should be added to
<argLine>-XX:+CMSClassUnloadingEnabled</argLine>
so the result would equal to
<argLine>-XX:+CMSClassUnloadingEnabled -Dportal.test=huge</argLine>
Could please anybody tell me if it is possible and how ?
EDIT: Please don't answer with " Why would you want to do that" kind of annoying questions.
I have never used argLine but maybe this is what you are looking for.. i.e.:
<argLine>-DskipTests=true ${argLine}</argLine>
(I used skip tests as an example :))

Resources