How can I transform a unity.config file in a nuget package? - unity-container

I'm trying to transform the contents of a unity.config file at the target of a nuget package. That file looks like this:
<?xml version="1.0"?>
<unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
<container>
<register type="SomeProject.Data.ISecurityManager, SomeProject.Data"
mapTo="SomeProject.MockSecurityManager, SomeProject.Data" />
</container>
</unity>
I want to update the value of "mapTo". I'm updating a bunch of stuff in the web.config with the standard web.config.install.xdt, but the key problem here seems to be that the namespace conflicts between the unity namespace and the transform namespace. So when I create an xdt with the following header for transformation:
<unity xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
Nothing in that file matches, because it's looking in a file with the actual root namespace like so:
<unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
I'm starting to lean towards a Powershell script...can anyone make this approach work?

Just try to add two namespaces for unity node to transform config. It looks like this:
<?xml version="1.0"?>
<unity xmlns="http://schemas.microsoft.com/practices/2010/unity" xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<container>
<register xdt:Transform="Replace"
xdt:Locator="Match(type)"
type="SomeProject.Data.ISecurityManager, SomeProject.Data"
mapTo="It's my test type)">
</register>
</container>
</unity>
It works fine for me. So let me know if it doesn't work for you.

Related

How to import a type incuding its package name

I'm using last version of openapi-generator-maven-plugin (6.0.1)
In order to handle some binary data properly I need to use typeMappings configuration as described here : https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-maven-plugin/README.md
So I configure my pom as following :
<configuration>
<typeMappings>
<typeMapping>string+binary=org.springframework.core.io.Resource</typeMapping>
</typeMappings>
</configuration>
But the code-generator understand it as a OrgSpringframeworkCoreIoResource class. How can I tell it not to camel case my parameter?
I finally undertand the problem : it's a 2 step configuration.
<!-- First we map the OpenAPI type to a keyword -->
<typeMappings>
<typeMapping>string+binary=Resource</typeMapping>
</typeMappings>
<!-- Then we attach the keyword to an existing type -->
<importMappings>Resource=org.springframework.core.io.Resource</importMappings>
That's way it works!

Exclude filter not working for filevault-package-maven-plugin

I have a content package with nodes I would like to exclude when this package is installed on AEM 6.5. The exclude configuration is defined in filter.xml (META-INF/vault/filter.xml).
Below is a representation of my filter.xml
<?xml version="1.0" encoding="UTF-8"?>
<workspaceFilter version="1.0">
<filter root="/apps/amzn-biz">
<exclude pattern="/apps/amzn-biz/i18n(.*)"/>
</filter>
<filter root="/apps/sling"/>
</workspaceFilter>
My pom.xml has below configuration
<!-- ====================================================================== -->
<!-- V A U L T P A C K A G E P L U G I N S -->
<!-- ====================================================================== -->
<plugin>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>filevault-package-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<group>amzn-biz</group>
<acHandling>merge_preserve</acHandling>
<packageType>content</packageType>
<embeddeds>
<embedded>
<groupId>com.amazon.business</groupId>
<artifactId>amzn-biz-foundation.core</artifactId>
<target>/apps/amzn-biz/install</target>
</embedded>
</embeddeds>
<subPackages>
<subPackage>
<groupId>com.adobe.cq</groupId>
<artifactId>core.wcm.components.all</artifactId>
<filter>true</filter>
</subPackage>
<subPackage>
<groupId>com.adobe.cq</groupId>
<artifactId>core.wcm.components.examples</artifactId>
<filter>true</filter>
</subPackage>
</subPackages>
</configuration>
</plugin>
<plugin>
<groupId>com.day.jcr.vault</groupId>
<artifactId>content-package-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<verbose>true</verbose>
<failOnError>true</failOnError>
</configuration>
</plugin>
I have tried multiple things by changing my exclude patterns to ./i18n. but it has not worked for me.
I have also tried adding filterSource to filevault-package-maven-plugin configuration but then i get the error Project contains filter.xml in META-INF/vault but also specifies a filter source.
You have to remove the nodes from the content package. You should not have any content in your content package, that is not explicitly covered by a filter-rule.
Your problem is weird backward-compatibility. At least in CQ5 were no filter-modes (mode="replace|merge|update") yet. In those days the rule was, that all content covered by a filter-rule is replaced. All other content is merged. When the filter-modes were introduced, they became non-intuitive but backward-compatible. In your case the i18n folder is merged.
Rule of thumb: A content package that is imported and exported again should be identical. (this would not be the case for you)
For more details see the table at https://jackrabbit.apache.org/filevault/filter.html#Usage_for_Import.2FInstallation for more information. For your i18n folder it says:
nodes which are ancestors of covered rules: deserialized from content package (for backwards compatibility reasons), nodes which are
not ancestors of covered rules: not touched. One should not rely on
this behaviour, i.e. all items in the content package should always be
covered by some filter rule to make the behaviour more explicit.
The issue may be relating to <packageType>content</packageType> instead of filter.xml. This type cannot have sub-packages nor embedded bundles. If <embeddeds> and <subPackages> are needed for the project, use <packageType>mixed</packageType> will reduce chance of unexpected build and installation behaviors.
The list of package types and behaviors are as following:
application: Package consists pure application content (aka. /apps/*). Does not contain any subpackages nor OSGi configuration or bundles.
content: Package consists only of content and user defined configuration. Does not contain any subpackages nor OSGi configuration or bundles.
container: Package only contains sub packages and OSGi configuration and bundles.
mixed: Catch all type for a combination of the above.
More details can be found at http://jackrabbit.apache.org/filevault-package-maven-plugin/generate-metadata-mojo.html#packageType

CubeMX code generation

I have a cubeMx code generation problem. I generated the whole project with cubeMX but after some modifications I got the following compiler error:
warning: cannot find entry symbol Reset_Handler; defaulting to
08000000
I figured out that the source of the error is first line of my .cproject file.
Before (compiler => OK):
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
After(compiler => error!):
<?xml version="1.0" encoding="UTF-8"?>
Can somebody help me to solve this problem?
Reset_Handler is defined in an assembly language file that is generated by CubeMx:
Drivers/CMSIS/Device/ST/STM32Fxxx/Source/Templates/gcc/startup_stm32fxxx.s
(xxx depending on your board type)
You should make sure this is being built as part of your project.
Hope this helps!
It is still a bug in CubeMX but I found a better more reliable solution to the problem. Navigate to Properties menu / Paths and Symbols / Source Location. Instead of adding the whole project library as a source location with no filter, add every folder one by one (with the add folder button). In this case CubeMX won't fail when generating source locations. My .cpoject file looks like this:
<sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="Common"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="Display"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Drivers"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Inc"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Middlewares"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Src"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="Tasks"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="font"/>
</sourceEntries>
Meanwhile it turns out that this is a bug in cubeMX version 4.14.0.
There is a walkaround until it is fixed.
SOLUTION
revert the sourceEntries to this in .cproject file
<sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
</sourceEntries>
See more details here:
Official ST forum
OpenSTM32 forum
UPDATE
Better solution found see above! (accepted answer)
Good luck,
Dave

Group testNG tests without annotations

I'm responsible for allowing unit tests for one of ETL components.I want to acomplish this using testNG with generic java test class and number of test definitions in testng.xmlpassing various parameters to the class.Oracle and ETL guys should be able to add new tests without changing the java code, so we need to use xml suite file instead of annotations.
Question
Is there a way to group tests in testng.xml?(similarly to how it is done with annotations)
I mean something like
<group name="first_group">
<test>
<class ...>
<parameter ...>
</test>
</group>
<group name="second_group">
<test>
<class ...>
<parameter ...>
</test>
</group>
I've checked the testng.dtd as figured out that similar syntax is not allowed.But is therea workaround to allow grouping?
Thanks in advance
You can specify groups within testng.xml and then run testng using -groups
<test name="Regression1">
<groups>
<run>
<exclude name="brokenTests" />
<include name="checkinTests" />
</run>
</groups>
....
No, this is not possible at the moment.
As a rule of thumb, I don't like adding information in XML that points into Java code, because refactorings might silently break your entire build.
For example, if you rename a method or a class name, your tests might start mysteriously breaking until you remember you need to update your XML as well.
Feel free to bring this up on the testng-users mailing-list and we can see if there's interest for such a feature.
--
Cedric

Conditionally including Flex libraries (SWCs) in mxmlc/compc ant tasks

I have been struggling trying to figure out how to conditionally include Flex libraries in an ant build based on a property that is set on the command line. I have tried a number of approaches with the <condition/> task, but so far have not gotten it to work. Here is where I am currently.
I have an init target that includes condition tasks like this:
<condition property="automation.libs" value="automation.qtp">
<equals arg1="${automation}" arg2="qtp" casesensitive="false" trim="true"/>
</condition>
The purpose of this task is to set a property that determines the name of the patternset to be used when declaring the implicit fileset on a mxmlc or compc task. The pattern set referenced above is defined as:
<patternset id="automation.qtp">
<include name="automation*.swc"/>
<include name="qtp.swc"/>
</patternset>
The named patternset is then referenced by the mxmlc or compc task like this:
<compc>
<compiler.include-libraries dir="${FLEX_HOME}/frameworks/libs" append="true">
<patternset refid="${automation.libs}"/>
</compiler.include-libraries>
</compc>
This doesn't appear to work. At least the SWC size does not indicate that the additional automation libraries have been compiled in. I want to be able to specify a command line property that determine which patternset to use for various types of builds.
Does anyone have any ideas about how to accomplish this? Thanks!
If you can't get <patternset> to work correctly, you might want to take a look at the <if> <then> and <else> tasks provided by ant-contrib. We ended up doing something like this:
<target name = "build">
<if>
<equals arg1="automation.qtp" arg2="true"/>
<then>
<!--
- Build with QTP support.
-->
</then>
<else>
<!--
- Build without QTP support.
-->
</else>
</if>
</target>
There is some duplication of build logic between the if and else branch, but you can factor some of that out if you wrap <mxmlc> with a macrodef.
The mxmlc task supports loading configuration files <load-config filename="path/to/flex-config.xml" />. So, generate the config xml on the fly, by combining the echoxml task and if-then-else.
<echoxml file="path/to/flex-config.xml">
<flex-config>
<compiler>
<library-path append="true">
<path-element>${lib.qtp}</path-element>
</library-path>
</compiler>
</flex-config>
</echoxml>
If your needs are more complicated, you could even generate several xml configs and <load-config ... /> them all.
Personally, I find any logic very terse and ugly to write using Ant's conditions or if-then-else, XML is not a pretty language to use for programming. Luckily, it's possible to use more flexible approach - write a script to produce the config xml, before calling mxmlc. E.g. use the script task with your favorite scripting language
<script language="javascript">
<![CDATA[
// Create your XML dynamically here.
// Write that XML to an external file.
// Later, feed that file to mxmlc using `<load-config ... />`.
]]>
</script>

Resources