Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
brought back the .targets files
Browse files Browse the repository at this point in the history
We still need them for proguard.txt to ship in the nugets
  • Loading branch information
Redth committed Sep 29, 2017
1 parent ff892fa commit 249d020
Show file tree
Hide file tree
Showing 36 changed files with 156 additions and 3 deletions.
2 changes: 2 additions & 0 deletions animated-vector-drawable/nuget/template.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
</dependencies>
</metadata>
<files>
<file src="animated-vector-drawable/nuget/Xamarin.Android.Support.Animated.Vector.Drawable.targets" target="build/MonoAndroid80" />

<file src="output/Xamarin.Android.Support.Animated.Vector.Drawable.dll" target="lib/MonoAndroid80" />

<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />
Expand Down
2 changes: 2 additions & 0 deletions appcompat-v7/nuget/template.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
</dependencies>
</metadata>
<files>
<file src="appcompat-v7/nuget/Xamarin.Android.Support.v7.AppCompat.targets" target="build/MonoAndroid80" />

<file src="output/Xamarin.Android.Support.v7.AppCompat.dll" target="lib/MonoAndroid80" />

<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />
Expand Down
89 changes: 89 additions & 0 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,95 @@ Task ("component-setup").Does (() =>
}
});


Task ("nuget-setup").IsDependentOn ("buildtasks").IsDependentOn ("externals")
.Does (() =>
{

Action<FilePath, FilePath> mergeTargetsFiles = (FilePath fromFile, FilePath intoFile) =>
{
// Load the doc to append to, and the doc to append
var xOrig = System.Xml.Linq.XDocument.Load (MakeAbsolute(intoFile).FullPath);
System.Xml.Linq.XNamespace nsOrig = xOrig.Root.Name.Namespace;
var xMerge = System.Xml.Linq.XDocument.Load (MakeAbsolute(fromFile).FullPath);
System.Xml.Linq.XNamespace nsMerge = xMerge.Root.Name.Namespace;
// Add all the elements under <Project> into the existing file's <Project> node
foreach (var xItemToAdd in xMerge.Element (nsMerge + "Project").Elements ())
xOrig.Element (nsOrig + "Project").Add (xItemToAdd);

xOrig.Save (MakeAbsolute (intoFile).FullPath);
};

var templateText = FileReadText ("./template.targets");

var nugetArtifacts = ARTIFACTS.ToList ();
nugetArtifacts.Add (new ArtifactInfo (SUPPORT_PKG_NAME, "support-v4", "Xamarin.Android.Support.v4", AAR_VERSION, NUGET_VERSION, COMPONENT_VERSION));

foreach (var art in nugetArtifacts) {

var proguardFile = new FilePath(string.Format("./externals/{0}/proguard.txt", art.ArtifactId));

var targetsText = templateText;
var targetsFile = new FilePath(string.Format ("{0}/nuget/{1}.targets", art.ArtifactId, art.NugetId));
FileWriteText (targetsFile, targetsText);

// Transform all .targets files
var xTargets = System.Xml.Linq.XDocument.Load (MakeAbsolute(targetsFile).FullPath);
System.Xml.Linq.XNamespace nsTargets = xTargets.Root.Name.Namespace;

if (FileExists (proguardFile)) {
var projElem = xTargets.Element(nsTargets + "Project");

Information ("Adding {0} to {1}", "proguard.txt", targetsFile);

projElem.Add (new System.Xml.Linq.XElement (nsTargets + "ItemGroup",
new System.Xml.Linq.XElement (nsTargets + "ProguardConfiguration",
new System.Xml.Linq.XAttribute ("Include", "$(MSBuildThisFileDirectory)..\\..\\proguard\\proguard.txt"))));
}

xTargets.Save (MakeAbsolute(targetsFile).FullPath);

// Check for an existing .targets file in this nuget package
// we need to merge the generated one with it if it exists
// nuget only allows one automatic .targets file in the build/ folder
// of the nuget package, which must be named {nuget-package-id}.targets
// so we need to merge them all into one
var mergeFile = new FilePath (art.ArtifactId + "/nuget/merge.targets");

if (FileExists (mergeFile)) {
Information ("merge.targets found, merging into generated file...");
mergeTargetsFiles (mergeFile, targetsFile);
}


// Transform all template.nuspec files
var nuspecText = FileReadText(art.ArtifactId + "/nuget/template.nuspec");
//nuspecText = nuspecText.Replace ("$xbdversion$", XBD_VERSION);
var nuspecFile = new FilePath(art.ArtifactId + "/nuget/" + art.NugetId + ".nuspec");
FileWriteText(nuspecFile, nuspecText);
var xNuspec = System.Xml.Linq.XDocument.Load (MakeAbsolute(nuspecFile).FullPath);
System.Xml.Linq.XNamespace nsNuspec = xNuspec.Root.Name.Namespace;

// Check if we have a proguard.txt file for this artifact and include it in the nuspec if so
if (FileExists (proguardFile)) {
Information ("Adding {0} to {1}", "proguard.txt", nuspecFile);
var filesElems = xNuspec.Root.Descendants (nsNuspec + "files");

if (filesElems != null) {
var filesElem = filesElems.First();
filesElem.Add (new System.Xml.Linq.XElement (nsNuspec + "file",
new System.Xml.Linq.XAttribute(nsNuspec + "src", proguardFile.ToString()),
new System.Xml.Linq.XAttribute(nsNuspec + "target", "proguard/proguard.txt")));
}
}

xNuspec.Save(MakeAbsolute(nuspecFile).FullPath);
}
});

Task ("nuget").IsDependentOn ("nuget-setup").IsDependentOn ("nuget-base").IsDependentOn ("libs");


Task ("component").IsDependentOn ("component-docs").IsDependentOn ("component-setup").IsDependentOn ("component-base").IsDependentOn ("libs");

Task ("clean").IsDependentOn ("clean-base").Does (() =>
Expand Down
2 changes: 2 additions & 0 deletions cardview-v7/nuget/template.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
</dependencies>
</metadata>
<files>
<file src="cardview-v7/nuget/Xamarin.Android.Support.v7.CardView.targets" target="build/MonoAndroid80" />

<file src="output/Xamarin.Android.Support.v7.CardView.dll" target="lib/MonoAndroid80" />

<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />
Expand Down
2 changes: 2 additions & 0 deletions customtabs/nuget/template.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
</dependencies>
</metadata>
<files>
<file src="customtabs/nuget/Xamarin.Android.Support.CustomTabs.targets" target="build/MonoAndroid80" />

<file src="output/Xamarin.Android.Support.CustomTabs.dll" target="lib/MonoAndroid80" />

<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />
Expand Down
2 changes: 2 additions & 0 deletions design/nuget/template.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
</dependencies>
</metadata>
<files>
<file src="design/nuget/Xamarin.Android.Support.Design.targets" target="build/MonoAndroid80" />

<file src="output/Xamarin.Android.Support.Design.dll" target="lib/MonoAndroid80" />

<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />
Expand Down
2 changes: 2 additions & 0 deletions exifinterface/nuget/template.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
</dependencies>
</metadata>
<files>
<file src="exifinterface/nuget/Xamarin.Android.Support.Exif.targets" target="build/MonoAndroid80" />

<file src="output/Xamarin.Android.Support.Exif.dll" target="lib/MonoAndroid80" />

<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />
Expand Down
2 changes: 2 additions & 0 deletions gridlayout-v7/nuget/template.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
</dependencies>
</metadata>
<files>
<file src="gridlayout-v7/nuget/Xamarin.Android.Support.v7.GridLayout.targets" target="build/MonoAndroid80" />

<file src="output/Xamarin.Android.Support.v7.GridLayout.dll" target="lib/MonoAndroid80" />

<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />
Expand Down
2 changes: 2 additions & 0 deletions leanback-v17/nuget/template.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
</dependencies>
</metadata>
<files>
<file src="leanback-v17/nuget/Xamarin.Android.Support.v17.Leanback.targets" target="build/MonoAndroid80" />

<file src="output/Xamarin.Android.Support.v17.Leanback.dll" target="lib/MonoAndroid80" />

<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />
Expand Down
2 changes: 2 additions & 0 deletions mediarouter-v7/nuget/template.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
</dependencies>
</metadata>
<files>
<file src="mediarouter-v7/nuget/Xamarin.Android.Support.v7.MediaRouter.targets" target="build/MonoAndroid80" />

<file src="output/Xamarin.Android.Support.v7.MediaRouter.dll" target="lib/MonoAndroid80" />

<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />
Expand Down
2 changes: 2 additions & 0 deletions palette-v7/nuget/template.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
</dependencies>
</metadata>
<files>
<file src="palette-v7/nuget/Xamarin.Android.Support.v7.Palette.targets" target="build/MonoAndroid80" />

<file src="output/Xamarin.Android.Support.v7.Palette.dll" target="lib/MonoAndroid80" />

<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />
Expand Down
2 changes: 2 additions & 0 deletions percent/nuget/template.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
</dependencies>
</metadata>
<files>
<file src="percent/nuget/Xamarin.Android.Support.Percent.targets" target="build/MonoAndroid80" />

<file src="output/Xamarin.Android.Support.Percent.dll" target="lib/MonoAndroid80" />

<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />
Expand Down
2 changes: 2 additions & 0 deletions preference-leanback-v17/nuget/template.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
</dependencies>
</metadata>
<files>
<file src="preference-leanback-v17/nuget/Xamarin.Android.Support.v17.Preference.Leanback.targets" target="build/MonoAndroid80" />

<file src="output/Xamarin.Android.Support.v17.Preference.Leanback.dll" target="lib/MonoAndroid80" />

<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />
Expand Down
2 changes: 2 additions & 0 deletions preference-v14/nuget/template.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
</dependencies>
</metadata>
<files>
<file src="preference-v14/nuget/Xamarin.Android.Support.v14.Preference.targets" target="build/MonoAndroid80" />

<file src="output/Xamarin.Android.Support.v14.Preference.dll" target="lib/MonoAndroid80" />

<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />
Expand Down
2 changes: 2 additions & 0 deletions preference-v7/nuget/template.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
</dependencies>
</metadata>
<files>
<file src="preference-v7/nuget/Xamarin.Android.Support.v7.Preference.targets" target="build/MonoAndroid80" />

<file src="output/Xamarin.Android.Support.v7.Preference.dll" target="lib/MonoAndroid80" />

<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />
Expand Down
2 changes: 2 additions & 0 deletions recommendation/nuget/template.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
</dependencies>
</metadata>
<files>
<file src="recommendation/nuget/Xamarin.Android.Support.Recommendation.targets" target="build/MonoAndroid80" />

<file src="output/Xamarin.Android.Support.Recommendation.dll" target="lib/MonoAndroid80" />

<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />
Expand Down
2 changes: 2 additions & 0 deletions recyclerview-v7/nuget/template.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
</dependencies>
</metadata>
<files>
<file src="recyclerview-v7/nuget/Xamarin.Android.Support.v7.RecyclerView.targets" target="build/MonoAndroid80" />

<file src="output/Xamarin.Android.Support.v7.RecyclerView.dll" target="lib/MonoAndroid80" />

<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />
Expand Down
2 changes: 2 additions & 0 deletions renderscript-v8/nuget/template.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<iconUrl>https://raw.githubusercontent.com/xamarin/AndroidSupportComponents/master/icons/v8-renderscript_128x128.png</iconUrl>
</metadata>
<files>
<file src="renderscript-v8/nuget/Xamarin.Android.Support.v8.RenderScript.targets" target="build/MonoAndroid80" />

<file src="output/Xamarin.Android.Support.v8.RenderScript.dll" target="lib/MonoAndroid80" />

<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />
Expand Down
2 changes: 2 additions & 0 deletions support-annotations/nuget/template.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<iconUrl>https://raw.githubusercontent.com/xamarin/AndroidSupportComponents/master/icons/support-annotations_128x128.png</iconUrl>
</metadata>
<files>
<file src="support-annotations/nuget/Xamarin.Android.Support.Annotations.targets" target="build/MonoAndroid80" />

<file src="output/Xamarin.Android.Support.Annotations.dll" target="lib/MonoAndroid80" />

<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />
Expand Down
2 changes: 2 additions & 0 deletions support-compat/nuget/template.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
</dependencies>
</metadata>
<files>
<file src="support-compat/nuget/Xamarin.Android.Support.Compat.targets" target="build/MonoAndroid80" />

<file src="output/Xamarin.Android.Support.Compat.dll" target="lib/MonoAndroid80" />

<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />
Expand Down
2 changes: 2 additions & 0 deletions support-core-ui/nuget/template.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
</dependencies>
</metadata>
<files>
<file src="support-core-ui/nuget/Xamarin.Android.Support.Core.UI.targets" target="build/MonoAndroid80" />

<file src="output/Xamarin.Android.Support.Core.UI.dll" target="lib/MonoAndroid80" />

<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />
Expand Down
2 changes: 2 additions & 0 deletions support-core-utils/nuget/template.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
</dependencies>
</metadata>
<files>
<file src="support-core-utils/nuget/Xamarin.Android.Support.Core.Utils.targets" target="build/MonoAndroid80" />

<file src="output/Xamarin.Android.Support.Core.Utils.dll" target="lib/MonoAndroid80" />

<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />
Expand Down
2 changes: 2 additions & 0 deletions support-dynamic-animation/nuget/template.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
</dependencies>
</metadata>
<files>
<file src="support-dynamic-animation/nuget/Xamarin.Android.Support.Dynamic.Animation.targets" target="build/MonoAndroid80" />

<file src="output/Xamarin.Android.Support.Dynamic.Animation.dll" target="lib/MonoAndroid80" />

<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />
Expand Down
2 changes: 2 additions & 0 deletions support-emoji-appcompat/nuget/template.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
</dependencies>
</metadata>
<files>
<file src="support-emoji-appcompat/nuget/Xamarin.Android.Support.Emoji.AppCompat.targets" target="build/MonoAndroid80" />

<file src="output/Xamarin.Android.Support.Emoji.AppCompat.dll" target="lib/MonoAndroid80" />

<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />
Expand Down
2 changes: 2 additions & 0 deletions support-emoji-bundled/nuget/template.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
</dependencies>
</metadata>
<files>
<file src="support-emoji-bundled/nuget/Xamarin.Android.Support.Emoji.Bundled.targets" target="build/MonoAndroid80" />

<file src="output/Xamarin.Android.Support.Emoji.Bundled.dll" target="lib/MonoAndroid80" />

<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />
Expand Down
2 changes: 2 additions & 0 deletions support-emoji/nuget/template.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
</dependencies>
</metadata>
<files>
<file src="support-emoji/nuget/Xamarin.Android.Support.Emoji.targets" target="build/MonoAndroid80" />

<file src="output/Xamarin.Android.Support.Emoji.dll" target="lib/MonoAndroid80" />

<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />
Expand Down
2 changes: 2 additions & 0 deletions support-fragment/nuget/template.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
</dependencies>
</metadata>
<files>
<file src="support-fragment/nuget/Xamarin.Android.Support.Fragment.targets" target="build/MonoAndroid80" />

<file src="output/Xamarin.Android.Support.Fragment.dll" target="lib/MonoAndroid80" />

<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />
Expand Down
2 changes: 2 additions & 0 deletions support-media-compat/nuget/template.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
</dependencies>
</metadata>
<files>
<file src="support-media-compat/nuget/Xamarin.Android.Support.Media.Compat.targets" target="build/MonoAndroid80" />

<file src="output/Xamarin.Android.Support.Media.Compat.dll" target="lib/MonoAndroid80" />

<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />
Expand Down
2 changes: 2 additions & 0 deletions support-tv-provider/nuget/template.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
</dependencies>
</metadata>
<files>
<file src="support-tv-provider/nuget/Xamarin.Android.Support.TV.Provider.targets" target="build/MonoAndroid80" />

<file src="output/Xamarin.Android.Support.TV.Provider.dll" target="lib/MonoAndroid80" />

<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />
Expand Down
2 changes: 2 additions & 0 deletions support-v13/nuget/template.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
</dependencies>
</metadata>
<files>
<file src="support-v13/nuget/Xamarin.Android.Support.v13.targets" target="build/MonoAndroid80" />

<file src="output/Xamarin.Android.Support.v13.dll" target="lib/MonoAndroid80" />

<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />
Expand Down
2 changes: 2 additions & 0 deletions support-v4/nuget/template.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
</dependencies>
</metadata>
<files>
<file src="support-v4/nuget/Xamarin.Android.Support.v4.targets" target="build/MonoAndroid80" />

<file src="output/Xamarin.Android.Support.v4.dll" target="lib/MonoAndroid80" />

<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
<Compile Include="VectorDrawableCheckBuildToolsVersionTask.cs" />
</ItemGroup>
<ItemGroup>
<None Include="..\nuget\template.targets">
<Link>template.targets</Link>
<None Include="..\nuget\merge.targets">
<Link>merge.targets</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion support-vector-drawable/nuget/template.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</metadata>
<files>
<file src="support-vector-drawable/buildtask/bin/Release/Xamarin.Android.Support.Tasks.VectorDrawable.dll" target="build/MonoAndroid80" />
<file src="support-vector-drawable/nuget/template.targets" target="build/MonoAndroid80/Xamarin.Android.Support.Vector.Drawable.targets" />
<file src="support-vector-drawable/nuget/Xamarin.Android.Support.Vector.Drawable.targets" target="build/MonoAndroid80/Xamarin.Android.Support.Vector.Drawable.targets" />

<file src="output/Xamarin.Android.Support.Vector.Drawable.dll" target="lib/MonoAndroid80" />

Expand Down
2 changes: 2 additions & 0 deletions transition/nuget/template.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
</dependencies>
</metadata>
<files>
<file src="transition/nuget/Xamarin.Android.Support.Transition.targets" target="build/MonoAndroid80" />

<file src="output/Xamarin.Android.Support.Transition.dll" target="lib/MonoAndroid80" />

<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />
Expand Down
Loading

0 comments on commit 249d020

Please sign in to comment.