Instantly share code, notes, and snippets.

View build.xml
...
<target name="deploy.new.custom.metadata.type" depends="convert.object.to.metadata.type">
<tempfile property="temp.package.xml" prefix="add.metadata.package." suffix=".xml" deleteonexit="true"/>
<echo file="${temp.package.xml}"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>Team_View_Plus_Views_CM__mdt</members>
<name>CustomObject</name>
</types>
<version>${sf.version}</version>
View build.xml
...
<target name="convert.object.to.metadata.type">
<xslt failOnNoResources="true" destdir="src" style="convert_to_metadata_object.xslt" extension=".metadata" useImplicitFileset="false" force="true">
<fileset dir="${sf.working.dir}" includes="objects${fs}Team_View_Plus_Views__c.object"/>
</xslt>
<move todir="src" overwrite="true">
<fileset dir="src" includes="objects${fs}Team_View_Plus_Views__c.metadata"/>
<filterchain>
<linecontainsregexp negate="true">
<regexp pattern="^\s*$"/>
View convert_obj_to_cmdt.xslt
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:sf="http://soap.sforce.com/2006/04/metadata" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
<!-- remove all the content -->
View MyPackagePage.page
<apex:page>
<div>
<h1>This is the Managed Package page</h1>
</div>
<iframe id="customPageIFrame" src="c__UserCustomPage" width="500" height="500"/>
</apex:page>
View MyPackagePage.page
<apex:page>
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" />
<div>
<h1>This is the Managed Package page</h1>
</div>
<div id="baseUrlLink" style="display: none;">
<apex:outputLink value="/">BASE URL</apex:outputLink>
View MyPackagePage.page
<apex:page>
<div>
<h1>This is the Managed Package page</h1>
</div>
<apex:iframe src="UserCustomPage" width="500" height="500"/>
</apex:page>
View UserCustomPage.page
<apex:page showHeader="false" sidebar="false">
<h1>This is the custom page not in the package</h1>
</apex:page>
View MyPackagePage.page
<apex:page controller="MyPackageController">
<div>
<h1>This is the Managed Package page</h1>
</div>
<iframe src="{!customPageURL}" width="500" height="500"/>
</apex:page>
View MyPackageController.cls
public class MyPackageController {
public String getCustomPageURL() {
return System.URL.getSalesforceBaseURL().toExternalForm() + '/UserCustomPage';
}
}
View build.xml
...
<target name="undeploy.content" depends="reset.content">
<property name="temp.dir" value="temp"/>
<xslt in="${temp.dir}${file.separator}package.xml" out="${temp.dir}${file.separator}destructiveChanges.xml" style="xslt${file.separator}destructive.changes.xslt" force="true"/>
<xslt in="${temp.dir}${file.separator}package.xml" out="${temp.dir}${file.separator}empty.package.xml" style="xslt${file.separator}empty.package.xslt" force="true"/>
<zip destfile="${temp.dir}${file.separator}undeploy.zip">
<fileset file="${temp.dir}${file.separator}destructiveChanges.xml"/>
<mappedresources>
<fileset file="${temp.dir}${file.separator}empty.package.xml"/>