Use WIX feature element in wxi and wxs with same Id - java

I want to generate a MSI package which contains only one feature.
I have a wxi file which is generated automatically. I cannot change this process.
wxi file looks like this:
<?xml version="1.0" encoding="UTF-8" ?>
<Include>
<!-- components -->
<Feature Id="DefaultFeature" Title="Main Feature" Level="1">
<ComponentRef Id="comp0" />
<ComponentRef Id="comp1" />
<ComponentRef Id="comp2" />
<ComponentRef Id="comp3" />
<ComponentRef Id="CleanupMainApplicationFolder" />
</Feature>
</Include>
I have a wxs file which I can change:
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Product ...>
<!-- components -->
<?include bundle.wxi ?>
<UI/>
<FeatureRef Id="DefaultFeature">
<ComponentRef Id="comp999" />
</FeatureRef>
</Product>
</Wix>
When I compile the wxs to MSI package Light is stating this error:
error LGHT0095 : Multiple primary references were found for Feature 'DefaultFeature' in Product '{...}' and Product '{...}'.
How do I change my wxs file to add a component to the feature defined in wxi file?
Thanks in advance.

Use <ComponentGroup> in your include files instead of <Feature>. Then, define your features in one place, the main .wxs file with <Product> element.
For example, this is how include file might look:
<Fragment>
<Component Id="Comp1" Guid="{GUID-GOES-HERE}">
...
</Component>
<Component Id="Comp2" Guid="{GUID-GOES-HERE}">
...
</Component>
<Component Id="Comp3" Guid="{GUID-GOES-HERE}">
...
</Component>
<ComponentGroup Id="CG1">
<ComponentRef Id="Comp1"/>
<ComponentRef Id="Comp2"/>
<ComponentRef Id="Comp3"/>
</ComponentGroup>
</Fragment>
And the main product.wxs defines the feature, includes the component group in there and allows including more components:
<Feature Id="MainFeature" Title="..." Level="100">
<ComponentGroupRef Id="CG1"/>
<!-- More components can go here -->
<Component Id="..">
</Component>
</Feature>
Moreover, you can include wxs files instead of include, too. As long as the main wxs references at least one element from another wxs, the entire contents will be included.

Related

Add External Jar file in cordova 3.4.0 application

I am creating two custom plugins for android use this plugin described in my plugin.xml. My plugin.xml file like
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="com.my.mybiometric"
version="1.2">
<name>myBiometric</name>
<description>myBiometric Plugin</description>
<license>Apache 2.0</license>
<keywords>media,upload</keywords>
<engines>
<engine name="cordova-android" version=">=3.4.0" />
</engines>
<js-module src="www/js/Media2.js" name="Media2">
<clobbers target="mediaRec.startRecord" />
</js-module>
<js-module src="www/js/VoiceUpload.js" name="VoiceUpload">
<clobbers target="VoiceUpload" />
</js-module>
<!-- android -->
<platform name="android">
<config-file target="res/xml/config.xml" parent="/*">
<feature name="Media2">
<param name="android-package" value="com.my.mybiometric.AudioHandler"/>
</feature>
<feature name="VoiceUpload">
<param name="android-package" value="com.my.mybiometric.UploadHandler"/>
</feature>
</config-file>
<config-file target="AndroidManifest.xml" parent="/manifest/application">
<activity
android:name="com.my.mybiometric.myBiometric"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:configChanges="orientation|screenSize|keyboardHidden">
</activity>
</config-file>
<source-file src="platforms/android/src/com/my/plugins/AudioHandler.java" target-dir="src/com/my/mybiometric" />
<source-file src="platforms/android/src/com/my/plugins/UploadHandler.java" target-dir="src/com/my/mybiometric" />
<source-file src="platforms/android/src/com/my/plugins/AppLog.java" target-dir="src/com/my/mybiometric" />
<source-file src="platforms/android/src/com/my/plugins/MyResponseHandler.java" target-dir="src/com/my/mybiometric" />
<source-file src="platforms/android/src/com/my/plugins/Recorder.java" target-dir="src/com/my/mybiometric" />
<source-file src="platforms/android/src/com/my/plugins/VoiceBiometricClient.java" target-dir="src/com/my/mybiometric" />
<source-file src="platforms/android/src/com/my/plugins/VoiceBiometricClientUsage.java" target-dir="src/com/my/mybiometric" />
</platform>
</plugin>
after build and run the project the media2 plugin is working fine but when i call the voiceupload plugin its return the "class not found" error for voice upload i am using "android-async-http-1.4.4.jar". I add the jar file into libs folder i added manually.
How to fix this issue?
You put your jar file in your plugin in the folder platforms/android/src/libs
In plugin.xml you add the line
<source-file src="platforms/android/src/libs/android-async-http-1.4.4.jar" target-dir="libs" />
no 3.
Check my answer here
You need to go to Go to Project->Properties and make some changes as per the answer.
Hope this helps.

Parsing xml property to ant-build.xml file

I have a xml file "versionreferance.xml". below is the coding
<?xml version="1.0" encoding="utf-8"?>
<!-- Update "revision" value to -1 when the next build is intended to have its revision as 0. This needs to be done for patch/release builds-->
<BuildVersions>
<property name="major" value="1" />
<property name="minor" value="0" />
<property name="patch" value="0" />
<property name="revision" value="93" />
</BuildVersions>
The other is my ant-build.xml file.
<?xml version="1.0" encoding="UTF-8"?>
<project name="xmlproperty-demo" default="init">
<xmlproperty file="versionreferance.xml" collapseAttributes="true" />
<echo>Major : ${BuildVersions.major}</echo>
<echo>Minor : ${BuildVersions.minor}</echo>
<echo>Patch : ${BuildVersions.patch}</echo>
<echo>Revision : ${BuildVersions.revision}</echo>
</project>
I am not getting the value in the output.
I want to get the path path dynamically of versionReference.xml , which will be in different place than antbuild.xml
Development\Build\VersionReference.xml
Development\Src\JAAS API\antbuild.xml
It should be dynamically. I am able to get the values form below code. But it's not dynamic.
<?xml version="1.0" encoding="UTF-8"?>
<project name="xmlproperty-demo" default="init">
<xmlproperty file="C:\\Development\\Build\\versionreferance.xml" collapseAttributes="true" />
<echo>Major : ${BuildVersions.major}</echo>
<echo>Minor : ${BuildVersions.minor}</echo>
<echo>Patch : ${BuildVersions.patch}</echo>
<echo>Revision : ${BuildVersions.revision}</echo>
</project>
I want to get the values only in this format.
<?xml version="1.0" encoding="utf-8"?>
<!-- Update "revision" value to -1 when the next build is intended to have its revision as 0. This needs to be done for patch/release builds-->
<BuildVersions>
<property name="major" value="1" />
<property name="minor" value="0" />
<property name="patch" value="0" />
<property name="revision" value="93" />
</BuildVersions>
I highly recommend using the free, third-party XmlTask library:
build.xml
<taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask" />
<xmltask>
<fileset file="versionreferance.xml"/>
<copy path="/BuildVersions/property[#name = 'major']/#value" property="BuildVersions.major"/>
<copy path="/BuildVersions/property[#name = 'minor']/#value" property="BuildVersions.minor"/>
<copy path="/BuildVersions/property[#name = 'patch']/#value" property="BuildVersions.patch"/>
<copy path="/BuildVersions/property[#name = 'revision']/#value" property="BuildVersions.revision"/>
</xmltask>
<echo>Major : ${BuildVersions.major}</echo>
<echo>Minor : ${BuildVersions.minor}</echo>
<echo>Patch : ${BuildVersions.patch}</echo>
<echo>Revision : ${BuildVersions.revision}</echo>
Output
run:
[echo] Major : 1
[echo] Minor : 0
[echo] Patch : 0
[echo] Revision : 93
If you add <echoproperties/> after the <xmlproperty> line you should see the properties are loaded but not as you expect. They will be something like:
BuildVersions.property=,,,
BuildVersions.property.name=major,minor,patch,revision
BuildVersions.property.value=1,0,0,93
This is because the properties are based off the node names, and in your case you have four instances of a "property" child node that are not unique. Your best bet may be to change the xml such as:
<BuildVersions>
<major>1</major>
....
</BuildVersions>
When you say xmlproperty with collapseAttributes="true" on xml file, it will flatten nested elements.
Details: https://ant.apache.org/manual/Tasks/xmlproperty.html
So just saying ${BuildVersions.major} doesn't give or print value as 1. Since you have same named xml element 'prooerty' you won't be able to get single propertie's value
For eg, in your case ${BuildVersions.property.name} will print 'major,minor,patch,revision'
Either you can redesign your versionreferance.xml to respect xmlproperty to work . Or you can make it as property file & say <property file="your.properties.file"/> & access them as normal properties!
If VersionReference.xml is going to be exactly where you mentioned in your question corresponding to your antbuild.xml.
I would suggest you to change your Absolute Path (as mentioned in question) with "..\..\Build\VersionReference.xml" which corresponds to the basedir="." in your project
This should work fine.
And considering your string format requirement.
I think the default comma(,) seperated value can then be replaced by dot(.) or manipulated as per your requirement by the following syntax
<propertyregex property="propB"
input="${propA}"
regexp=","
replace="."
global="true" />
Please find more info on this link :
Replacing characters in Ant property
Hope this helps.

How to ignore "id" in Short Variable rule using PMD

I am using PMD plugin (version 4.0.2) for Eclipse (Eclipse Kepler Java EE). I have configured a naming rule: ShortVariable.
This works fine except for parameters like "id" and "e". I want PMD to ignore these. So I searched for a way to ignore certain parameters. I found this link (although it's for phpmd) and tried it, yet I can't seem to get it working. My config file looks like this (XML):
<?xml version="1.0"?>
<ruleset name="My PMD ruleset"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
<description>
My PMD
</description>
<rule ref="rulesets/java/naming.xml/ShortVariable">
<property name="exceptions" value="id" />
</rule>
</ruleset>
When I try to import this ruleset using the eclipse plugin, it shows no possible rules to import.
Any ideas?
I found a solution to my problem here.
The resulting xml looks like this:
<?xml version="1.0"?>
<ruleset name="My PMD ruleset"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
<description>
My PMD
</description>
<rule ref="rulesets/java/naming.xml/ShortVariable">
<properties>
<property name="xpath">
<value>
//VariableDeclaratorId[(string-length(#Image) < 3) and (not (#Image='id'))]
[not(ancestor::ForInit)]
[not((ancestor::FormalParameter) and (ancestor::TryStatement))]
</value>
</property>
</properties>
</rule>
</ruleset>
To be able to ignore more variable names, repeat the following part:
and (not (#Image='myVariableToIgnore'))
The folowing XML is valid for PHP tool PHPMD 2.2.3
<?xml version="1.0"?>
<!DOCTYPE ruleset>
<ruleset
name="My PMD ruleset for symfony 2.5"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd"
>
<rule ref="rulesets/unusedcode.xml" />
<rule ref="rulesets/codesize.xml" />
<rule ref="rulesets/cleancode.xml" />
<rule ref="rulesets/controversial.xml" />
<rule ref="rulesets/design.xml" />
<rule ref="rulesets/naming.xml">
<exclude name="ShortVariable" />
</rule>
<rule ref="rulesets/naming.xml/ShortVariable">
<properties>
<property name="exceptions" value="id,em" />
</properties>
</rule>
</ruleset>
Update xml
<rule ref="category/java/codestyle.xml/ShortVariable">
<properties>
<property name="xpath">
<value>
//VariableDeclaratorId[(string-length(#Image) < 3) and (not (#Name='id'))]
[not(ancestor::ForInit)]
[not((ancestor::FormalParameter) and (ancestor::TryStatement))]
</value>
</property>
</properties>
</rule>

Custom config.ini in Eclipse RCP product

My eclipse RCP (3.7) application is currently in a good shape, in which product can be exported successfully for multiple platforms and runs just fine. What I need is to change some properties in config.ini file, in particular osgi.instance.area.default and osgi.configuration.area.
In the configuration tab of eclipse product editor, I check Use an existing config.ini file and select the config.ini I created inside the same project hosting the product (and the core feature) definition.
To create the custom config.ini, I just took the one generated in a previous export, and added above properties.
What happens is that after exporting the product, config.ini is still auto-generated in configuration/config.ini, without my edits. What am I missing?
This is how my product definition looks like:
<?xml version="1.0" encoding="UTF-8"?>
<?pde version="3.5"?>
<product name="MyApp" id="it.myapp.product" application="it.myapp.application" version="1.0.0.qualifier" useFeatures="true" includeLaunchers="true">
<configIni use="default">
<linux>/it.myapp.app/config.ini</linux>
<macosx>/it.myapp.app.app/config.ini</macosx>
<solaris>/it.myapp.app.app/config.ini</solaris>
<win32>/it.myapp.app/config.ini</win32>
</configIni>
<launcherArgs>
<programArgs>-nl it</programArgs>
<vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac>
</launcherArgs>
<windowImages />
<splash
location="it.myapp"
startupProgressRect="6,378,485,13"
startupMessageRect="7,397,445,22"
startupForegroundColor="000000" />
<launcher name="myapp">[...]</launcher>
<vm>
</vm>
<plugins>
<plugin id="com.ibm.icu"/>
[...]
<plugin id="org.sat4j.pb"/>
</plugins>
<features>
<feature id="it.myapp.feature"/>
</features>
<configurations>
<plugin id="it.myapp" autoStart="false" startLevel="5" />
<plugin id="org.eclipse.core.runtime" autoStart="true" startLevel="4" />
<plugin id="org.eclipse.equinox.common" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.equinox.ds" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.equinox.simpleconfigurator" autoStart="true" startLevel="1" />
</configurations>
</product>
You are not missing anything - this just does not work. I experienced the same. You can try upgrading to a more recent version of Eclipse which hopefully has this function working.
See: https://bugs.eclipse.org/bugs/show_bug.cgi?id=284732
I suggest to work around this by using root-properties:
Eclipse RCP root-properties

How to set the output file name in Alfresco?

I was creating custom content model
in datalistModel.xml
<type name="dl:car">
<title>Car List</title>
<parent>dl:dataListItem</parent>
<properties>
<property name="dl:carName">
<title>Car Name</title>
<type>d:text</type>
<mandatory>false</mandatory>
</property>
<property name="dl:carCompany">
<title>Company Name</title>
<type>d:text</type>
<mandatory>false</mandatory>
</property>
</properties>
</type>
in share-datalist-form-config.xml
<!-- dl:contact type create car form -->
<config evaluator="model-type" condition="dl:car">
<forms>
<!-- Create item form -->
<form>
<field-visibility>
<!-- dl:contact type -->
<show id="dl:carName" />
<show id="dl:carCompany" />
</field-visibility>
<create-form template="../data-lists/forms/dataitem.ftl" />
</form>
</forms>
</config>
When I create a new car content in repository browser(I later configured menu to add content type 'Car'), the file name is 91b65385-86c6-4923-859d-6ecb3326319c.
<create-content>
<content id="plain-text" mimetype="text/plain" label="create-content.text" itemid="cm:content" icon="text"/>
<content id="html" mimetype="text/html" label="create-content.html" itemid="cm:content"/>
<content id="xml" mimetype="text/xml" label="create-content.xml" itemid="cm:content"/>
<content id="car" mimetype="text/xml" icon="xml" label="create-content.car" itemid="dl:car"/>
</create-content>
How can I make the file name to carName instead of 91b65385-86c6-4923-859d-6ecb3326319c
Any kind help is appreciated.
Take a look at the default 'share-datalist-form-config.xml'
You will see that almost every type specify <show id="cm:title" />
You could also just put <show id="name" /> or <show id="cm:name" /> to show the name attribute.
In order to put the title you will need to put the cm:titled aspect in your model.
Just check the 'datalistModel.xml' how the defaults are defined
And check this blog post to know a bit more how to create custom datalists.

Categories

Resources