Maven pom systemProperty path to file syntax - file

Have follwong chunk from pom.xml:
<systemProperty>
<name>axis2.config</name>
<value>file:${project.build.directory}/../../axis2.properties</value>
</systemProperty>
what does syntax for value tag mean?
/../ - is id cd .. and forwards to parent directory?

short: ../ means parent direcory
long version:
file: specifies, that the following
content should be interpreted as a
file path.
${project.build.directory} is a
variable which will be replaced by
the runtime with the actual project
build directory
/ are folder separators
.. means parent folder
axis2.properties is the name of the
properties file
if you want to display the path for debugging purposes you might want to have a look at this:
http://www.avajava.com/tutorials/lessons/how-do-i-display-the-value-of-a-pom-xml-element.html
or
maven ant echoproperties task

Yes, it's a relative path to the project build directory, and go upper (in parent) two times.
In other words: it's the parent directory of the directory that contain your project build directory ;)
Source: Maven Properties Guide

Related

Compiling C file from vim in a "path agnostic" way

Suppose I launch vim from a large project root folder and want to compile a specific example (I ll use zephyr RTOS for example). This root folder is located under /home/<user>/zephyr/
Let's say I run vim samples/basic/blinky/src/main.c.
Now if I want to compile it, I would go, from another terminal to samples/basic/blinky/build/ and run make
If I want to build it without leaving vim, I could run :make -C samples/basic/blinky/build/
I would like to automate this process, pressing any key, let's say f5.
So if I have, for example, two vertical splits, v1 and v2.
In v1 I have samples/basic/blinky/src/main.c and in v2 I have samples/drivers/rtc/src/main.c.
Pressing f5 from v1 would lead to run the equivalent of :make -C samples/basic/blinky/build/, and from v2 would lead to run the equivalent of :make -C samples/drivers/rtc/build/
The common pattern is that the build folder is located in ../build/ from the current c file directory.
I don't want to "permanently" use :cd or :lcd to change working directory, even for the current split/window because:
My ctags tags file is located in the root folder, so I want to be able to jump to any function that samples/basic/blinky/src/main.c uses but are not necessarily defined in the same file.
If I want to open a new file, I want to access it using its path from the root folder and not the current file path
My current solution is to have a function in my ~/.vimrc which temporally changes the working directory to the current file equivalent build folder, so that I can run :make and then changes back the working directory to the root folder.
It looks like this:
nnoremap <F5> :call MakeTst()<CR>
function! MakeTst(...)
:cd %:p:h
:cd ../build/
:make
:cd /home/<user>/zephyr/
endfunction
While this works, the downside is that the root folder is hardcoded inside the ~/.vimrc.
How can I achieve the same result without hardcoding the root folder path?
You gave the answer yourself: in your function. As long as your file
structure keeps that pattern, you can use filename modifiers to make it
generic:
:nnoremap <F5> :make -C %:p:h/../build
This will always build in the directory build at the same level of the
directory where the current file sits. Just like your example:
a/b/c/src/file.c
a/b/c/build
It breaks in a case like this:
a/b/c/src/include/features.h
As it would try to build in:
a/b/c/src/build
There is a workaround though. If your build is always at the same
level of src, then you can perform a text substitution with the :s
modifier:
:nnoremap <F5> :make -C %:p:s!.*\zssrc.*!build!
This simple pattern .*\zssrc.* searches for the last src in your
path and replaces it (and anything after it) with build. It does
nothing if there is no src in the path.

How to get the relative path segment for Apache Camel File2

I'm trying to build a file based integration where files are dumped in one of the subdirectories of a main directory for processing. I need to get the name of the sub-directory to know which client the file is for. So if I have:
/uploads/foo/bar.txt
I need to process that file and know that it's for client "foo". I'm not sure how to get that part and set it as a header for the processor that processes the bar.txt file. I've got it picking up files and processing, now I need to add in this piece.
Anyone have ideas for me?
You can get most of this information in the header of the exchange. In your situation as you are consuming the file the following items are avlable:
CamelFileName: Name of the consumed file as a relative file path with
offset from the starting directory configured on the endpoint.
CamelFileNameOnly: Only the file name (the name with no leading
paths).
CamelFileAbsolute: A boolean option specifying whether the consumed
file denotes an absolute path or not. Should normally be false for
relative paths. Absolute paths should normally not be used but we
added to the move option to allow moving files to absolute paths. But
can be used elsewhere as well.
CamelFileAbsolutePath: The absolute path to the file. For relative
files this path holds the relative path instead.
CamelFilePath: The file path. For relative files this is the starting directory + the relative filename. For absolute files this is the absolute path.
CamelFileRelativePath: The relative path.
CamelFileParent: The parent path.
CamelFileLength: A long value containing the file size.
CamelFileLastModified: A Date value containing the last modified
timestamp of the file.
You can query these headers for the information you are looking for using the following example as guidelines:
<log message ="${header.CamelFileAbsolutePath}"/>
See the file component documents at the Camel website for more details.

how to refer all the jar files in a directory in my batch file

I have created a batch file "run.bat":
set CLASSPATH=%CLASSPATH%.;.\Jars\app.jar;.\Jars\a.jar;.\Jars\b.jar;.\Jars\c.jar;.\Jars\d.jar;
java mypackage.mysubpackage.Start
pause
I have kept all the class files related to my application in "app.jar" and
Start is the class from where the application begins execution. I have this "run.bat" file and all the jars that my "app.jar" wants to refer in the same directory.
I kept all these jars in the "Jars" folder and referring to it in my "run.bat" file as shown above. However, to refer to each and every jar file by my "run.bat" I need to specify the path as ".\Jars\jarname.jar". When I am using ".\Jars\*.jar" the jars are not referred by "run.bat".
Can anyone provide an alternative for it?
Actually you have done only half the work using *.jar. You also need to pass them to java as the classpath: java -cp $CLASSPATH mypackage.mysubpackage.Start. (on windows I think the use of a variable in a script is %CLASSPATH%)
Later edit: take a look at BigMike's comments on your question. If you're using a java version < 1.6, you might need to use a loop to build a complete %CLASSPATH% including each jar's full name individually, because I'm guessing that Windows' shell doesn't do expansions just like *nix systems.
You can try to use for loop to create class path in batch, such as the below.
#echo off
for %%jar in (.\Jars\*.jar) do call :add_jar %%jar
java -cp %CLASSPATH%;%JARS% mypackage.mysubpackage.Start
pause
exit /b
:add_jar
set JARS=%JARS%;%1
exit /b
You could try something that is given in the below link http://docs.oracle.com/javase/6/docs/technotes/tools/windows/classpath.html
Understanding class path wildcards section:
"A class path entry that contains * will not match class files. To match both classes and JAR files in a single directory foo, use either foo;foo/* or foo/;foo. The order chosen determines whether the classes and resources in foo are loaded before JAR files in foo, or vice versa.
Subdirectories are not searched recursively. For example, foo/ looks for JAR files only in foo, not in foo/bar, foo/baz, etc."
So in your case you should do :
set CLASSPATH=%CLASSPATH%.;.\Jars;.\Jars\*
and not
set CLASSPATH=%CLASSPATH%.;.\Jars;.\Jars\*.jar
provided all the jars you require are present in .\Jars folder
set CLASSPATH=%CLASSPATH%.;C:\data\Ideas\tool\Deliverables\webservice\batchjar;C:\data\Ideas\tool\Deliverables\webservice\batchjar*
this helps me

Exclude folder under dynamic links in Installshield

Is there a way to exclude a folder that is located under a dynamic link in InstallShield?
So I have a dynamic link that starts at PATH A, and the following is a small example directory structure:
PATH A
--- PATH B
--- PATH C (which contains files)
--- PATH D (which contains files)
--- PATH E (which contains files)
--- PATH F
--- PATH G (which contains files)
Currently I have a dynamic link that starts at PATH A, includes sub directories, and uses a *.* wild card with some explicit file exclusions.
What I want to do now is to completely exclude a directory, for example completely exclude PATH F from the above example directory structure.
There is no - way.
I've been trying to do this since InstallShield 6. They're at InstallShield 15 now, and you still can't do it. If you use Subversion and are concerned about about .svn directories, you could solve the problem the way I did: have your build process do an svn export to an intermediate directory before building.

How do I work with spaces in my wix source path?

wxs file the File tag Source attribute; the path has a space in it.
<File Id="_uploads.UserImport.EDS_UserImport.xls" Name="EDS_UserImport.xls" Source="C:\Documents and Settings\kle\Desktop\OspreyMSIGenerator\OspreyMSIGenerator\Published\EDSContainer\uploads\UserImport\EDS_UserImport.xls"></File>
I get this error
candle.exe : error CNDL0103 : The system cannot find the file 'and' with type 'Source'.
I can't be sure that my paths won't have spaces in it. How do I support spaces in the Source path?
Try upgrading to the latest stable wix release. I tested this with Wix 3.0.5419.0 and file paths with spaces are accepted without errors.
On a related note: File elements should not contain absolute paths like in your example, because you would only be able to build the setup on a single developer's PC. Use paths relative to the location of the wxs file instead, like this:
<File Source="..\bin\foo.exe" />
Or make use of a variable that contains the location of the files like this:
<File Source="$(var.BinFolder)foo.exe" />
You can then pass the location of the bin folder by invoking candle like this:
candle.exe -dBinFolder=c:\someFolder\bin\ foo.wxs
edit: as shown by Rob in his own answer, you can also use the light.exe -b switch to specify one or more base directories where the files to install can be found.
#wcoenen provides one mechanism. However, I prefer to use the light.exe -b switch. Then your code can look like:
<File Id="_uploads.UserImport.EDS_UserImport.xls" Name="EDS_UserImport.xls" Source="SourceDir\Published\EDSContainer\uploads\UserImport\EDS_UserImport.xls"></File>
and your command-line to light.exe would have:
-b "C:\Documents and Settings\kle\Desktop\OspreyMSIGenerator\OspreyMSIGenerator"
You can have multiple -b switches and greatly reduce the complexity of your Source attribute.
Also, the File/#Id and File/#Name can be left off if you are fine with them defaulting to the file name (in this case, "EDS_UserImport.xls").

Resources