Ant referencing classes in zip - ant

Just had a quick question, in my ant build.xml, when I am stating where my jar's that need to be included are located, is it possible to include a .zip file with the classes i need in there as well? Only reason I am asking is because I have received classes that I am dependent on from an outside source and they are just zipped up. I was thinking something like this could be possible.
<path id="test.lib">
<fileset dir="{basedir}/../path/to/lib/files" includes="testzip.zip" />
</path>
I just wasn't sure if the classes had to be in jar format. Thanks for the help!

They do not. The zip extension is fine.

Related

How to Ant build with project lombok library?

Has anyone build project (containing project Lombok annotations) with ant build?
I have added lombok.jar in classpath, but still not working.
Possible problems:
You're not actually including the jar file in classpath. Worth checking it twice.
You are including the jar, but annotation processing is off. This
would happen if you're compiling with javac5 or earlier. Use javac6
and make sure there's nothing like -proc:none being passed as
argument.

Ant <import> vs. <include> tasks

I now see Ant has both an <include> task and an <import> task.
According to the descriptions:
Include
Include another build file into the current project.
and
Import
Imports another build file into the current project.
So, why use one over the other?
Here's my actual problem:
In our current build system, we are concatenating a bunch of JavaScripts and then minimizing them. The JavaScripts are located in a dozen different directories, and we are taking batches from each directory and concatenating them into five or six super minimized JavaScripts. Some of these files are copied into multiple super JavaScripts.
In order to make debugging easier, and the build a bit more flexible, I want to copy all of the files into the target/work/resources2 directory with each sub-directory under there representing a different super minimized JavaScript. For debugging purposes, we'll include the non-minimized super JavaScript and the originals. The build script isn't complex, but the whole section is taking up a lot of lines. I was thinking of putting the <copy> stuff into a separate XML file, so the whole thing looks like this:
<target name="process-resources"
description="Concatenate and minimize the JavaScripts (using Maven lifecycle names for our targets">
<!-- The following include the copying stuff -->
<here.be.dragons file="${basedir}/reservations.xml"/>
<here.be.dragons file="${basedir}/date.xml"/>
<here.be.dragons file="${basedir}/select.xml"/>
<for param="concat.dir">
<fileset dir="${work.dir]/resources2"/>
<sequential>
<here.I.am.concatenating.and.minimizing/>
</sequential>
</for>
</target>
I see there are four possibilities:
Use <ant/> to call the files that do the copying
Use <import/> (which might not work because it might not be able to be included inside a target)
Use <include/> (which might not work because it might not be able to be included inside a target)
Use the Entity Include.
I am never crazy about using <ant/> or <antcall> although this might be a good time to do this. The Entity Include idea will work, but that's something most people don't understand, and I am afraid it will cause confusion for people who have to support what I'm doing. The <import> and <include> may not be able to be used in this situation, but I'm still curious what the differences are.
The documentation of import explains the difference:
How is import different from include?
The short version: Use import if you intend to override a target, otherwise use include.
When using import the imported targets are available by up to two names. Their "normal" name without any prefix and potentially with a prefixed name (the value of the as attribute or the imported project's name attribute, if any).
When using include the included targets are only available in the prefixed form.
When using import, the imported target's depends attribute remains unchanged, i.e. it uses "normal" names and allows you to override targets in the dependency list.
When using include, the included targets cannot be overridden and their depends attributes are rewritten so that prefixed names are used. This allows writers of the included file to control which target is invoked as part of the dependencies.
It is possible to include the same file more than once by using different prefixes, it is not possible to import the same file more than once.

.mm .h .c Files from copied phonegap project not shown in Xcode

I have a phonegap project and split the code in global files (that are similar for android and ios) and ios/android specific files. Then I have an ant script where I merge the files into one project again.
The problem is I have a plugin "xzing barcode scanner". The files lay within the projectname/Plugins folder of the IOS project. The files are also merged to the target directory, but in xcode they´re not shown. And when I run the app I get the error that the plugin isn`t known.
This part of the ant scirpt copies the file
<copy todir="${targetdir}/${projectName}.xcodeproj">
<fileset dir="${projectroot}/${projectName}.xcodeproj"/>
</copy>
<copy todir="${targetdir}/${projectName}">
<fileset dir="${projectroot}/${projectName}"/>
</copy>
The contents of the Plugin Folder:
CDVBarcodeScanner.mm
zxing_all_in_one.h
zxing_all_in_one.c
README
All Files are copied to the target directory (targetdir/projectname/Plugins), but somehow not merged into the project in xcode.
Anyone knows how to fix this?
Your files do not seem to be referenced to your XCode project.
I think a simple way you may try would be to copy your files manually like this (I don't know why but this kind of issue was solved for me like this XD...):
Use your Finder to go to your folder Plugin and move the "hidden" files (CDVBarcodeScanner.mm, zxing_all_in_one.h, zxing_all_in_one.c, and README) somewhere else, on your Desktop for instance.
Open XCode and create an empty file for the folder Plugin (--> Through XCode: right click on the folder Plugin, New File...->iOS->Other->Empty) and save the file as CDVBarcodeScanner.mm (for example)
Open the file CDVBarcodeScanner.mm (for example), that you put on your Desktop for example, with a simple text editor and copy the content to your new created file in XCode
Do the same for the remaining files:
zxing_all_in_one.h
zxing_all_in_one.c
README
Hope this solution will work for you. Let me know of your results.

Too many cod-parts in jad file

I created a blackberry application but I am having problems publishing it on my web site. I have uploaded the jad, jar, alx and cod file (from which I extracted the whole content). I also added the missing MIME types. But when I try to download the application by requesting the jad file, I get a 500 error with the details saying that the file myproject-30.cod is missing.
So I looked at the list of cod file... sure enough, they go from 0 to 29. No 30, 31 or above. However, in the jad file, there are references for cod files for up to 110.
My question is: how can I configure eclipse to produce the jar file properly? Or, alternatively, how can I modify the jad file to delete references to the 30+ cod files? Or maybe it is that the cod file is missing files?
You may try with blackberry ant tools, task will look like this:
<target name="produce_ota">
<mkdir dir="${ota.dir}" />
<jadtool input="your_app_name.jad" destdir="${ota.dir}">
<fileset dir="${build.dir}" includes="*.cod" />
</jadtool>
</target>
This will produce all needed cod parts and jad file to ${ota.dir} assuming there will be built application in ${build.dir} directory.
Check out slashdev.ca tutorial - Blackberry development with Ant & Eclipse
For some reason, the JAD file was not recreated by the rapc compile tool. Basically, it was created a couple of week ago and that's it, so clearly it was not up-to-date. To force the eclipse plugin to recreate the file, I simply deleted it. The new file is now working fine.

Team Build, copy file target issue

I have this team build target setup to after compile
<Target Name="AfterCompile">
<Copy SourceFiles="$(SolutionRoot)\Development_VS2008\MyCompanyName.SharePoint.12" DestinationFolder="c:\testing"></Copy>
</Target>
I want the folder structure copied from source to destination...
Amazingly I am getting this error
Could not copy the file "C:\TFS\NightlyBuild\Sources\Development_VS2008\MyCompanyName.SharePoint.12\"
to the destination file "c:\testing\", because the destination is a folder instead of a file.
To copy the source file into a folder, consider using the DestinationFolder parameter instead of DestinationFiles.
As you can see I am indeed using the destinationfolder parameter, does anyone know what I am doing wrong?
I think it might be just because SourceFiles is a directory rather than the files you want to copy. Try this:
<Target Name="AfterCompile">
<ItemGroup>
<FilesToCopy Include="$(SolutionRoot)\Development_VS2008\MyCompanyName.SharePoint.12\**\*.*"/>
</ItemGroup>
<Copy SourceFiles="#(FilesToCopy)" DestinationFolder="c:\testing\%(RecursiveDir)"/>
</Target>
This error happened to me not under Team Foundation project, but standalone one, and when I add new .dll file with build action ContentWithTargetPath. I wanted this library to be included in my output directory. Record for this action appears in one of the ItemGroup section in .csproj file like:
<ContentWithTargetPath Include="Resources\Libraries\libName.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</ContentWithTargetPath>
But for some reason this is not enough to ContentWithTargetPath option works fine (I saw the explanation about it somewhere in StackOverflow, but don't remember where). You should manually add TargetPath subsection to ContentWithTargetPath like this:
<ContentWithTargetPath Include="Resources\Libraries\libName.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<TargetPath>libName.dll</TargetPath>
</ContentWithTargetPath>
TargetPath subsection doesn't appear by IntelliSense while editing the .csproj file in Visual Studio, as well as it doesn't appear in libName.dll's properties window, so you should add this subsection by hand. This scenario comes out even in my Visual Studio Community 2017.
PS. You can edit .csproj file while in Visual Studio - unload this project and choose "Edit YourProjectName.csproj" option (right mouse click on unloaded project). Edit and save .csproj file, then reload the project.
You need something such as this:
<CreateItem Include="someFolder\**\*.*">
<Output ItemName="files" TaskParameter="Include" />
</CreateItem>
<Copy SourceFiles="#(files)" DestinationFiles="#(files->'C:\folder\%(relativedir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
Or alternatively I've found the easiest way (if you want to be a bit more stringent about what to include/ exclude) is with some custom MSBuild tasks I've written: http://www.aaron-powell.com/blog.aspx?cat=AaronPowell.MSBuild.Tasks
You provide a source directory, a destination direction (support for network shares is provided) and file names/ extensions to exclude.
It's mainly because Team Build makes a real mess (particularly with web apps) when it run and it's not really possible to use the standard MSBuild copy tasks.
We are experiencing a lot of problems with postbuild xcopy commands. And we decided to avoid xcopy commands.
We are now including the files (which we want to copy) into project, and we are setting copy local property to "Copy if newer" and target directory (directory structure must be same in project)
It helps a lot.
Maybe it also fit your situation.
Copy task doesn't support copying directories apparently (as it's based on 'copy'), and xcopy will fails sometimes due to long filenames in source (>256 characters).
I did this (with robocopy):
<Exec WorkingDirectory="$(MSBuildProjectDirectory)"
Command='robocopy $(MSBuildProjectDirectory)\Main $(DropLocation) /S /COPY:DATS /NP /NFL /NDL /v' ContinueOnError="true" />
I had exactly the same message:
Error 103 Could not copy the file "obj\Release\xxxx.dll" to the destination file "bin\Release\xxxx.dll", because the destination is a folder instead of a file. To copy the source file into a folder, consider using the DestinationFolder parameter instead of DestinationFiles. xxxx
It happened (I don´t know why) that I had in the release folder another folder with the same name of the assembly (including extension), so Visual Studio could not create the assembly there. It is not a configuration in the project or solution, so I just deleted the folder (that I don´t know how it was created) and it worked.

Resources