Skip to content

Commit fe0ae91

Browse files
dellis1972jonpryor
authored andcommitted
[Xamarin.Android.Build.Tasks] Import Designer-fu from monodroid (#2737)
Xamarin.Android provides a variety of targets for use by the [Xamarin.Android Designer][0], which are used to help prepare a project for consumption by the Xamarin.Android Designer. Historically these targets were kept within the commercial repo. Move the `GetExtraLibraryLocationsForDesigner` and related MSBuild targets and unit tests from xamarin/monodroid@40a23fbf into the xamarin-android repo. Moving the targets will hopefully permit the Xamarin.Android Designer integration tests to use the xamarin-android OSS build artifacts and installers (e.g. PR #2733), allowing breakage caused by changes within the `xamarin-android` repo to be more quickly identified and fixed. (Currently, commercial installer creation can be significantly delayed, which increases the time it takes for the Designer integration tests to get a chance to run, and any breakage found and reported, before breakage can be fixed.) [0]: https://docs.microsoft.com/en-us/xamarin/android/user-interface/android-designer/
1 parent b12d3ba commit fe0ae91

File tree

6 files changed

+370
-46
lines changed

6 files changed

+370
-46
lines changed
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<!--
2+
***********************************************************************************************
3+
Xamarin.Android.Common.Designer.targets
4+
5+
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
6+
created a backup copy. Incorrect changes to this file will make it
7+
impossible to load or build your projects from the command-line or the IDE.
8+
9+
This file imports the version- and platform-specific targets for the project importing
10+
this file. This file also defines targets to produce an error if the specified targets
11+
file does not exist, but the project is built anyway (command-line or IDE build).
12+
13+
Copyright (C) 2016 Xamarin. All rights reserved.
14+
***********************************************************************************************
15+
-->
16+
17+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
18+
19+
<Target Name="GetExtraLibraryLocationsForDesigner"
20+
DependsOnTargets="_SetupDesignTimeBuildForCompile"
21+
Returns="ExtraJarLocation;ExtraResourceLocation">
22+
<ReadAdditionalResourcesFromAssemblyCache
23+
Condition="Exists('$(_AndroidResourcePathsCache)')"
24+
CacheFile="$(_AndroidResourcePathsCache)">
25+
<Output TaskParameter="AdditionalAndroidResourcePaths" ItemName="_AdditionalAndroidResourcePaths" />
26+
<Output TaskParameter="AdditionalJavaLibraryReferences" ItemName="_AdditionalJavaLibraryReferences" />
27+
</ReadAdditionalResourcesFromAssemblyCache>
28+
<ReadLibraryProjectImportsCache
29+
Condition="Exists('$(_AndroidLibraryProjectImportsCache)')"
30+
CacheFile="$(_AndroidLibraryProjectImportsCache)">
31+
<Output TaskParameter="ResolvedResourceDirectories" ItemName="_LibraryResourceDirectories" />
32+
<Output TaskParameter="Jars" ItemName="_LibraryJars" />
33+
</ReadLibraryProjectImportsCache>
34+
<ItemGroup>
35+
<ExtraJarLocation Include="@(_AdditionalJavaLibraryReferences)">
36+
<Source>AssemblyCache</Source>
37+
</ExtraJarLocation>
38+
<ExtraJarLocation Include="@(_LibraryJars)">
39+
<Source>LibraryImport</Source>
40+
</ExtraJarLocation>
41+
<ExtraResourceLocation Include="@(_AdditionalAndroidResourcePaths->'%(Identity)\res')">
42+
<Source>AssemblyCache</Source>
43+
</ExtraResourceLocation>
44+
<ExtraResourceLocation Include="@(_LibraryResourceDirectories)">
45+
<Source>LibraryImport</Source>
46+
</ExtraResourceLocation>
47+
</ItemGroup>
48+
</Target>
49+
50+
<Target Name="_GeneratePackageManagerJavaForDesigner"
51+
DependsOnTargets="_AddStaticResources;_ResolveAssemblies"
52+
Inputs="$(_ResolvedUserAssembliesHashFile);@(ResolvedAssemblies);@(ResolvedUserAssemblies);$(_AndroidManifestAbs);"
53+
Outputs="$(IntermediateOutputPath)android\src\mono\MonoPackageManager.java;$(_AndroidTypeMappingJavaToManaged);$(_AndroidTypeMappingManagedToJava)">
54+
<Copy
55+
SourceFiles="@(ResolvedAssemblies)"
56+
DestinationFiles="@(ResolvedAssemblies->'$(MonoAndroidIntermediateAssemblyDir)%(Filename)%(Extension)')"
57+
/>
58+
<GenerateJavaStubs
59+
ResolvedAssemblies="@(ResolvedAssemblies)"
60+
ResolvedUserAssemblies="@(ResolvedUserAssemblies)"
61+
ManifestTemplate="$(_AndroidManifestAbs)"
62+
MergedManifestDocuments="@(ExtractedManifestDocuments)"
63+
Debug="$(AndroidIncludeDebugSymbols)"
64+
NeedsInternet="$(AndroidNeedsInternetPermission)"
65+
AndroidSdkPlatform="$(_AndroidApiLevel)"
66+
AndroidSdkDir="$(_AndroidSdkDirectory)"
67+
PackageName="$(_AndroidPackage)"
68+
OutputDirectory="$(IntermediateOutputPath)android"
69+
MergedAndroidManifestOutput="$(IntermediateOutputPath)android\AndroidManifest.xml"
70+
UseSharedRuntime="$(AndroidUseSharedRuntime)"
71+
EmbedAssemblies="$(EmbedAssembliesIntoApk)"
72+
ResourceDirectory="$(MonoAndroidResDirIntermediate)"
73+
BundledWearApplicationName="$(BundledWearApplicationPackageName)"
74+
PackageNamingPolicy="$(AndroidPackageNamingPolicy)"
75+
ApplicationJavaClass="$(AndroidApplicationJavaClass)"
76+
FrameworkDirectories="$(_XATargetFrameworkDirectories);$(_XATargetFrameworkDirectories)Facades"
77+
AcwMapFile="$(_AcwMapFile)">
78+
</GenerateJavaStubs>
79+
<ConvertCustomView
80+
Condition="Exists('$(_CustomViewMapFile)')"
81+
CustomViewMapFile="$(_CustomViewMapFile)"
82+
AcwMapFile="$(_AcwMapFile)"
83+
ResourceDirectories="$(MonoAndroidResDirIntermediate);@(LibraryResourceDirectories)"
84+
ResourceNameCaseMap="$(_AndroidResourceNameCaseMap)"
85+
/>
86+
<!-- Create java needed for Mono runtime -->
87+
<GeneratePackageManagerJava
88+
ResolvedAssemblies="@(ResolvedAssemblies)"
89+
ResolvedUserAssemblies="@(ResolvedUserAssemblies)"
90+
MainAssembly="$(MonoAndroidLinkerInputDir)$(TargetFileName)"
91+
OutputDirectory="$(IntermediateOutputPath)android\src\mono"
92+
EnvironmentOutputDirectory="$(IntermediateOutputPath)android\src\mono\android\app"
93+
UseSharedRuntime="$(AndroidUseSharedRuntime)"
94+
TargetFrameworkVersion="$(TargetFrameworkVersion)"
95+
Manifest="$(IntermediateOutputPath)android\AndroidManifest.xml"
96+
Environments="@(AndroidEnvironment);@(LibraryEnvironments)"
97+
AndroidAotMode="$(AndroidAotMode)"
98+
EnableLLVM="$(EnableLLVM)"
99+
HttpClientHandlerType="$(AndroidHttpClientHandlerType)"
100+
TlsProvider="$(AndroidTlsProvider)"
101+
Debug="$(AndroidIncludeDebugSymbols)"
102+
AndroidSequencePointsMode="$(_SequencePointsMode)"
103+
EnableSGenConcurrent="$(AndroidEnableSGenConcurrent)">
104+
<Output TaskParameter="BuildId" PropertyName="_XamarinBuildId" />
105+
</GeneratePackageManagerJava>
106+
</Target>
107+
108+
<Target Name="SetupDependenciesForDesigner"
109+
DependsOnTargets="UpdateAndroidResources;_AdjustJavacVersionArguments;_GeneratePackageManagerJavaForDesigner;_GetMonoPlatformJarPath;_DetermineJavaLibrariesToCompile"
110+
Inputs="$(IntermediateOutputPath)android\src\mono\MonoPackageManager.java;$(_AndroidTypeMappingJavaToManaged);$(_AndroidTypeMappingManagedToJava)"
111+
Outputs="$(IntermediateOutputPath)android\bin\classes\mono\MonoPackageManager.class">
112+
<Javac
113+
JavaPlatformJarPath="$(JavaPlatformJarPath)"
114+
ClassesOutputDirectory="$(IntermediateOutputPath)android\bin\classes"
115+
TargetFrameworkDirectory="$(TargetFrameworkDirectory)"
116+
StubSourceDirectory="$(IntermediateOutputPath)android\src"
117+
JavaSourceFiles=""
118+
ToolPath="$(JavacToolPath)"
119+
ToolExe="$(JavacToolExe)"
120+
Jars="@(_JavaLibrariesToCompile);@(_ReferenceJavaLibs)"
121+
JavacTargetVersion="$(JavacTargetVersion)"
122+
JavacSourceVersion="$(JavacSourceVersion)"
123+
/>
124+
</Target>
125+
126+
</Project>

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AndroidUpdateResourcesTest.cs

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,51 +1465,5 @@ public void Issue2205 ([Values (false, true)] bool useAapt2)
14651465
Assert.IsTrue (b.Build (proj), "first build should have succeeded");
14661466
}
14671467
}
1468-
1469-
[Test]
1470-
public void SetupDependenciesForDesigner ()
1471-
{
1472-
var path = Path.Combine ("temp", TestName);
1473-
var lib = new XamarinAndroidLibraryProject {
1474-
ProjectName = "Library1",
1475-
OtherBuildItems = {
1476-
new AndroidItem.AndroidAsset ("Assets\\foo.txt") {
1477-
TextContent = () => "Bar",
1478-
},
1479-
},
1480-
};
1481-
var proj = new XamarinFormsAndroidApplicationProject {
1482-
ProjectName = "App1",
1483-
References = { new BuildItem ("ProjectReference", "..\\Library1\\Library1.csproj") },
1484-
};
1485-
proj.Imports.Add (new Import ("Designer.targets") {
1486-
TextContent = () => @"<?xml version=""1.0"" encoding=""utf-16""?>
1487-
<Project ToolsVersion=""4.0"" xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
1488-
<PropertyGroup>
1489-
<AndroidUseManagedDesignTimeResourceGenerator>False</AndroidUseManagedDesignTimeResourceGenerator>
1490-
<SetupDependenciesForDesignerDependsOn>
1491-
UpdateAndroidResources;
1492-
_AdjustJavacVersionArguments;
1493-
_GeneratePackageManagerJavaForDesigner;
1494-
_GetMonoPlatformJarPath;
1495-
_DetermineJavaLibrariesToCompile;
1496-
</SetupDependenciesForDesignerDependsOn>
1497-
</PropertyGroup>
1498-
<Target Name=""SetupDependenciesForDesigner"" DependsOnTargets=""$(SetupDependenciesForDesignerDependsOn)"">
1499-
</Target>
1500-
<Target Name=""_GeneratePackageManagerJavaForDesigner"" DependsOnTargets=""_AddStaticResources;_ResolveAssemblies"">
1501-
</Target>
1502-
</Project>
1503-
",
1504-
});
1505-
using (var libb = CreateDllBuilder (Path.Combine (path, lib.ProjectName)))
1506-
using (var appb = CreateApkBuilder (Path.Combine (path, proj.ProjectName))) {
1507-
libb.Save (lib);
1508-
Assert.IsTrue (appb.RunTarget (proj, "SetupDependenciesForDesigner", parameters: new [] { "DesignTimeBuild=True" }), "design-time build should have succeeded.");
1509-
//Now a full build
1510-
Assert.IsTrue (libb.Build (lib), "library build should have succeeded.");
1511-
Assert.IsTrue (appb.Build (proj), "app build should have succeeded.");
1512-
}
1513-
}
15141468
}
15151469
}

0 commit comments

Comments
 (0)