Loading ant properties from other build files - ant

I want to run an ant target 'run_junit' in my build.xml which uses the properties defined in multiple build files say junit.xml in various sub directories. I want to load all the properties from all the junit.xml files in various sub dirs before invoking this particular target.
I tried following
import the junit.xml files - This cannot be imported within a target. I do not want to import the files always.
read the junit.xml files within a target say 'load_properties' but property set in one target is not available in another target.
Can someone suggest me a way to achieve this ?
Thanks

If you want to use the properties in multiple targets, you would have to import them globally.
To Include another ANT file:
<include file="${path_to_file}/file.xml"/>
To Import properties from another file:
<property file="file_name.properties"/>
Note: These are all global definitions

Related

Module map location and compiler settings with mixed Objective-C/Swift frameworks

Background: I'm converting a large old mixed language codebase to a framework. I'm having problems, so I thought I'd start with a minimal test project to see how things work. I ran into more problems. This is Swift 5.0 with Xcode 10.2.1.
I created a new iOS framework project called TestFramework. TestFramework has the following source files:
OCTest.[hm], with a single private class
OCPublic.[hm], with a single public class. It calls OCTest.
STest.swift, with a single public class. It calls both OCPublic and OCTest.
I also have the following two umbrella headers, in the same folder as the source files:
TestFramework.h, which is the one Xcode created automatically. I only added #import "OCPublic.h".
TestFramework_Private.h. It has two lines:
#include "TestFramework.h"
#include "OCTest.h"
They all reside in the TestFramework folder, along with Info.plist and everything else Xcode creates automatically.
I managed to make this compile, build a framework package with carthage build --archive and use the resulting framework successfully in a test app with the following module maps and build settings:
TestFramework/module.modulemap exists and is empty.
TestFramework/module.private.modulemap exists with these lines:
module TestFramework_Private {
umbrella header "TestFramework_Private.h"
export *
}
Both MODULEMAP_FILE and MODULEMAP_PRIVATE_FILE in build settings are unset.
SWIFT_INCLUDE_PATHS is $(PROJECT_DIR)/TestFramework.
DEFINES_MODULE is true.
If I add any content (framework module TestFramework { … }) to module.modulemap or try to make MODULEMAP_FILE or MODULEMAP_PRIVATE_FILE point to their files (with the values TestFramework/module.modulemap and TestFramework/module.private.modulemap) I get various build errors (can't find TestFramework_Private, redefinition of module TestFramework, etc.)
If I remove the empty main module map, I get No such module 'TestFramework_Private' where STest.swift tries to import it.
If I try to move the private things into a separate folder and change SWIFT_INCLUDE_PATHS and MODULEMAP_PRIVATE_FILE I get more build errors.
Are there some values for the MODULEMAP* settings that should work, with or without content inside the main module map? What should I do if I wanted to move things into different folders?
It seems at least some of my problems were caused by this:
When building a framework that has module maps in both the source and the install directories that define the same module, the compiler will show a redefinition message. (28638816)
Workaround: Rename the module map file in the source directory to a non-default name (the default name is module.modulemap or module.map), and set the Module Map File build setting to the renamed module map.
Renaming my module map file to anything other than module.modulemap — the name used in, for example, all over Clang documentation — made it possible to point MODULEMAP_FILE at it, and allowed me to move the headers to a different location etc.

How to select only specific c files in iOS to compile using xCode

I have a project containing C files, header files and other files with different extensions like:
Parent folder/C foolder/... all c Files.
Parent folder/Header folder/ ... all header files
Now, what I want is to compile only few c files from c folder and same for header. After looking at few links at stackoverflow like this post about how to exclude files with .m extensions by adding
-fno-objc-arc compiler flag, but doesn't explains how to exclude .c files.
This is accomplished within Xcode by defining which source files are associated with a particular build target.
Each Xcode project can have multiple targets and source files can be associated with one or more targets.
Header files are not associated in the same way, but get their association by whatever source files include/import them.
You can set the target when you add the file to Xcode (reference) and you can change it later via the source file's properties (reference).

Prefix Header import in another project

I've a framework project let say ProjectA which is included in another iPhone project ProjectB, so ProjectB is dependent on ProjectA.
ProjectA has a prefix header file in which I've imported one header file of a clss written in ProjectA itself, so this import will be placed in all the classes of ProjectA.
Now what I need is, that imported header has to take place in all the class files inside ProjectB which is dependent on ProjectA.
Please give me suggestions on how to accomplish this.
Thanks in advance.
Edit the code file for ProjectB...
Alternatively, go to the build settings, search for 'prefix' and edit the path which tells the project where the .pch file that it should use is.

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.

Importing properties from different build files for Ant

I have 2 build files into separate projects,
build_common.xml,
build.xml which is the main build file.
I am trying to import a property from build_common.xml without importing the whole file. Is there a way to do that if I know the path to the build_common.xml?
Thanks
If you only want to import certain properties, they probably SHOULD be in separate files (broken apart by common use). That said, maybe one of your ant tasks could use grep, or some other collection of utilities to transform build_common.xml into a NEW file, that only contains what you want, and then import THAT?
I really don't think it's the BEST way to approach the problem, but I think it could work.

Resources