exec ant replace a value in a .m file - file

how to write an exec task in ant to replace two values in .m file.
Because I want to replace the version number in iphone app, including my build number which i build using hudson, i remotely access the macos and get the app to be copied on to my windows
system, so i generated the build using ant exec tasks, but now i want to replace my build number into the concern file before compiling,
so how can i use exec task to replace certain values in a file.
I know propertyfile task which replaces the value in a property file, but it doesn't work for
this.

If you have a template file, you can use the <copy> task with a nested <filterset> to replace certain values. If not, you can still use <copy>, this time with a nested filter chain containing a <replaceregex> token filter. If you want to edit in place, you can move the newly created file to the old location afterwards.
The use of <exec> is almost certainly a bad idea for your application, as it would make your build rely on external applications which usually are not available on all platforms, thus breaking portability of your build.

Related

why won't my AutoCAD accoreconsole open files or execute scripts?

I am running Vanilla AutoCAD 2017
The accoreconsole.exe will start but and show the example Screen and will appears to run commands, although i am unaware of a way to open a file directly from core console so i cant really do anything with it.
Methods attempted
1. Script Pro 2.0:
From https://knowledge.autodesk.com/support/autocad/downloads/caas/downloads/content/autodesk-customization-conversion-tools.html
Script pro executes scripts successfully when using AutoCAd But then Fails when i switch to Core Console
It generates a log file that reads: Error while reading log file for C:\Users\Documents\TEST\ARCH01_FIRST FLOOR PLAN - AREA C.dwg
2.Auto Lisp
From AutoCAD using an Auto Lisp command i found on House of BIM. The command works and i tested several scripts which i first tested using the Run Script Button in AutoCad and they worked, but not when i used core console.
This generated a Temp file called accc34642 which reads m_kernelList still has 1 entry
/i core console flashes and then disappears
/I core console opens a new file from the Qnew Template file path
This seems to happen no matter whats after that in the lisp statement.
Then OPEN command in core console doesn't return a prompt or an error, it just returns twice and does nothing.
Typing in a file path generates an error
3.Widows batch files
I have only used one of these in the past successfully but i checked the ones i found a couple different websites and still no luck on getting the scripts to execute.
I also tried all this from different File Paths
The main idea of AutoCAD Console is to process 1 file and exit. That's also important to avoid memory fragmentation and errors when you process multiple files in a single instance of accoreconsole.exe
So, as already mentioned, consider a workflow where each instance process a single file and then exit. You may even consider multiple instances of accoreconsole to process multiple files at once.
Wed0,
to get started with working with accoreconsole, here are a couple links that will help you:
1) http://adndevblog.typepad.com/autocad/2012/04/getting-started-with-accoreconsole.html
2) http://through-the-interface.typepad.com/through_the_interface/2012/02/the-autocad-2013-core-console.html
for the second article, Kean goes into quite a bit of detail, but I don't especially like his approach with using .bat files. It is much nicer to use a programming language like C#.
As for opening files, it actually is possible!
I recently discovered a VERY fast method of processing dwg files using accorconsole (or AutoCAD if that is what you prefer). For example, running a search and replace operation of dbtext and mtext on a batch of dwg files runs at around 15 drawings/second on a single process. Setting up 5 or 6 in parallel will process close to 5000 drawings/minute! I thought I would share this with the community as this discovery has been a game-changer for my company when it comes to processing large batches of dwg files.
For this you have to use the .NET API(or C++, etc). I did all the code for processing in C#, and the only 2 lines in the lisp script file is to NETLOAD my dll and call the command that does the processing.
Turns out, you can work on multiple dwg files in the same instance of accoreconsole. The idea here is to just load the dwg database without actually opening the drawing (takes ~70ms), manipulate the database, then save it. For the i/ switch, you can use any dummy drawing file as it will have no effect on your batch. Then in C# in your command method, you would do something like this:
string[] dwgFiles = Directory.GetFiles("C:\\MyDWGFiles");
foreach(string drawingFilePath in dwgFiles)
{
using(Database database = new Database(false, true))
{
database.ReadDwgFile(drawingFilePath, FileShare.ReadWrite,
true String.Empty);
using(Transaction transaction =
database.TransactionManager.StartTransaction())
{
//DO STUFF HERE
transaction.Commit();
database.SaveAs(drawingFilePath, DwgVersion.Current);
}
}
}
Let me know if you have any questions or need more detail,
I don't believe it is possible to open files from within core console. I am relatively certain core console has to be initialized with the path as an argument of the drawing you wish it to open. Once it is open you can then do work with that file. So, you would essentially have to open a single instance of core console for each file you want to do work on.
Hope that helps.
The best way as drive AutoCAD commands as dwg files is use the concept mencioned by "Autodesk Knowledge Network": Out-of-Process .NET
a. https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2016/ENU/AutoCAD-NET/files/GUID-C8C65D7A-EC3A-42D8-BF02-4B13C2EA1A4B-htm.html),
and this alternative is supported by Autodesk; the accoreconsole is not.
With this features, you may execute AutoCAD software, open Projects, batch iterates on files and manipulate data. Recently, I developed one plugin that has two requirements:
b. be executed without user-intervention and,
c. interates on all Dwg files to execute a process per-file;
Like link above, I instantiated AutoCAD and send commands like a lisp sintaxe to call the customized command (as "("CUSTOM_CMD", "PARAMS1", "PARAMS2" ...)" );
My custom command was like this:
[CommandMethod("CUSTOM_CMD")]
public static void CustomCmd
{
//stuff iterate on DWGs
}
3.Comments: It's importante to use Thread Safe Collection (for example ConcurrentBag) to memory Dwg Collection to ensure non interference between Next Moving contiguous Dwgs iteraction's running.

Using bukhantsov.org command line query output with options

I am trying to use the tool here business objects query builder output
And there are virtually no examples, so I'm struggling to make it work. It produces no errors, but outputs no file in the directory where the batch file is, that I can see.
Here is the code inside querybuilder.bat:
set lib=c:\Program Files\Business Objects\Common\4.0\java\lib
java -cp "querybuilder.jar;poi-3.8-20120326.jar;%lib%\*" org.bukhantsov.querybuilder.Program %*
Here is the code inside what I am running, which I've named RunQuery_ALLACTIVE.bat, except of course with my Server, Username, and Password changed for the purpose of this post.
I have this all on one line, with no line breaks.
querybuilder.bat -cms:SERVER -username:OURUSERNAME -password:OURPASSWORD -query:"SELECT * FROM CI_INFOOBJECTS where SI_SCHEDULE_STATUS = 9 order by SI_NAME" -auth:windowsad -excel "Output.xls"
Can't tell if the - options go on different LINES ?
Can't tell if I'm supposed to put output file in quotes, or if it should be an existing file or not?
can't tell if for Windows AD (which we use), I would put "Windows AD" or WindowsAD, I'm assuming no spaces obviously.
Tons of unanswered questions on this tool - it LOOKS cool, but has anyone actually successfully used it? Can't really find comments or history on the 'net..
To answer your questions:
The options go on the same line, not on different ones
As Joe said, you'll need to specify the output file as -excel:"Output.xls"
If you want to use Windows AD, you'll probably need to specify secWinAD (case-sensitive).
If you're not sure about the command line options, I suggest you build up gradually: first only specify the required options, then add the optional ones one by one so you know which one is giving you problems.
Also, I noticed that the download page contains a version compiled for XI3.x and BI4. Make sure you use the correct version, corresponding to the version of BusinessObjects you're using. Also, verify the path in the batch file to see if it points to a valid folder containing the JAR files for the BusinessObjects environment.
Update:
I just noticed that the same author/developer created another application (GUI, not command line) that might be a bit easier to use. Have a look here.

Batch File task in windows - Find and replace across multiple files

I have to write a batch file which finds and replaces values of version and build with their new values given by the user as an input.
The user initially gives 3 values: Apps, version and build values (the new values).
The search is then made across multiple .property files in a folder. The Apps value is searched across multiple files and wherever there is a match, the version and build of that file will be replaced by the values given by the user.
To Find and replace across multiple files easily, use FART!

Is there any way to tell IntelliJ IDEA not to look at files during a search/replace or during refactorings?

Basically my question is the topic ^
I have 4 files that are massive. I need to put them in resources under my maven project structure. Whenever I do a string-based refactoring or search/replace... I basically want the IDE to ignore these files altogether.
Yes, I know I can exclude them and do the replacements manually... but like I said, I want to remove any possibility that they can be modified through the IDE (without having to write-protect them I guess, or revert them all the time if the version control says they've been modified).
Is there any way I can exclude these files?
There are two questions there:
1) How to exclude these files in string based refactoring such as search and replace
You can set up a custom scope when you do a find and replace. This custom scope is saved so you don't have to set it up every time you do a find and replace.
Open the find-and-replace window or the find-in-path window and you will see the scope section in the window with "Custom" as the last option. You can select the files that you want to include/exclude here.
2) How to prevent files from being modified in the IDE without write protecting them
This I'm not sure about. You can add them to a separate change list so that they will always be grouped away from your main set of changes or add them to the vc ignore list. But this doesn't stop the IDE from modifying them. Perhaps you should find out what is editing those files and stop that process?
You can mark the directory as Excluded in "Project Structure->Modules"
You can mark this directory as for "Generated Sources Root"

Easiest way to have a true "file tasks" in ANT

I am still learning how to use ANT well, and I wanted to understand if there is some reasonable way to do file tasks in it, similar to Rake and Make:
http://martinfowler.com/articles/rake.html#FileTasks
"With a file you are referring to actual files rather than task names. So 'build/dev/rake.html' and 'dev/rake.xml' are actual files. The html file is the output of this task and the xml file is the input. You can think of a file task as telling the build system how to make the output file - indeed this is exactly the notion in make - you list the output files you want and tell make how to make them.
An important part of the file task is that it's not run unless you need to run it. The build system looks at the files and only runs the task if the output file does not exist or it's modification date is earlier than the input file. File tasks therefore work extremely well when you're thinking of things at a file by file basis."
So in other words, let's say I want to run a custom binary and I only want that binary to run if any of the files have changed. This is related to this question, but I don't want to run the binary at all, not only pass a part of the fileset (i.e. there is only one in the fileset and I don't want the tool to run at all).
The ideal solution would also not be a loooong thing, but rather could be easily applied to any target -- perhaps using some ANT JavaScript or custom task?
Use ant-contrib outofdate task. It has exactly the properties you are asking for. Here is ant-contrib website.
Here is a template on how to integrate it into your build:
<taskdef
resource="net/sf/antcontrib/antlib.xml"
>
<classpath>
<pathelement location="${ant-contrib.jar}"/>
</taskdef>
<outofdate>
<sourcefiles path="dev/rake.xml"/>
<targetfiles path="build/dev/rake.html"/>
<sequential>
... do your work here ...
... will only run if rake.html is older than rake.xml ...
</sequential>
</outofdate>

Resources