Update design mappings in jetifier.

Use fallback rule for support.design and material.
Remove check when to rewrite own package in pom file. As long as the
dependency artifact:group are supposed to be rewritten it should be.
Also previsously it was not intuitive and the flag could be easily
missing.

Test: N/A
Bug: b/64833662
Change-Id: Ie111f57da67eac077ae40ba7c92e463a18fe03a3
diff --git a/jetifier/jetifier/core/src/main/resources/default.config b/jetifier/jetifier/core/src/main/resources/default.config
index c7f70fb..6cddf2e 100644
--- a/jetifier/jetifier/core/src/main/resources/default.config
+++ b/jetifier/jetifier/core/src/main/resources/default.config
@@ -828,96 +828,12 @@
             "to": "com/google/android/material/snackbar/SnackbarContentLayout{0}"
         },
         {
-            "from": "android/support/design/animation/(.*)",
-            "to": "com/google/android/material/animation/{0}"
-        },
-        {
-            "from": "android/support/design/bottomappbar/(.*)",
-            "to": "com/google/android/material/bottomappbar/{0}"
-        },
-        {
-            "from": "android/support/design/bottomnavigation/(.*)",
-            "to": "com/google/android/material/bottomnavigation/{0}"
-        },
-        {
-            "from": "android/support/design/button/(.*)",
-            "to": "com/google/android/material/button/{0}"
-        },
-        {
-            "from": "android/support/design/canvas/(.*)",
-            "to": "com/google/android/material/canvas/{0}"
-        },
-        {
-            "from": "android/support/design/card/(.*)",
-            "to": "com/google/android/material/card/{0}"
-        },
-        {
-            "from": "android/support/design/chip/(.*)",
-            "to": "com/google/android/material/chip/{0}"
-        },
-        {
-            "from": "android/support/design/circularreveal/(.*)",
-            "to": "com/google/android/material/circularreveal/{0}"
-        },
-        {
-            "from": "android/support/design/circularreveal/cardview/(.*)",
-            "to": "com/google/android/material/circularreveal/cardview/{0}"
-        },
-        {
-            "from": "android/support/design/circularreveal/coordinatorlayout/(.*)",
-            "to": "com/google/android/material/circularreveal/coordinatorlayout/{0}"
-        },
-        {
-            "from": "android/support/design/drawable/(.*)",
-            "to": "com/google/android/material/drawable/{0}"
-        },
-        {
-            "from": "android/support/design/expandable/(.*)",
-            "to": "com/google/android/material/expandable/{0}"
-        },
-        {
-            "from": "android/support/design/internal/(.*)",
-            "to": "com/google/android/material/internal/{0}"
-        },
-        {
-            "from": "android/support/design/math/(.*)",
-            "to": "com/google/android/material/math/{0}"
-        },
-        {
-            "from": "android/support/design/resources/(.*)",
-            "to": "com/google/android/material/resources/{0}"
-        },
-        {
-            "from": "android/support/design/ripple/(.*)",
-            "to": "com/google/android/material/ripple/{0}"
-        },
-        {
-            "from": "android/support/design/shape/(.*)",
-            "to": "com/google/android/material/shape/{0}"
-        },
-        {
-            "from": "android/support/design/snackbar/(.*)",
-            "to": "com/google/android/material/snackbar/{0}"
-        },
-        {
-            "from": "android/support/design/stateful/(.*)",
-            "to": "com/google/android/material/stateful/{0}"
-        },
-        {
-            "from": "android/support/design/theme/(.*)",
-            "to": "com/google/android/material/theme/{0}"
-        },
-        {
-            "from": "android/support/design/transformation/(.*)",
-            "to": "com/google/android/material/transformation/{0}"
-        },
-        {
             "from": "android/support/design/R(.*)",
             "to": "com/google/android/material/R{0}"
         },
         {
-            "from": "android/support/design/behavior/(.*)",
-            "to": "com/google/android/material/behavior/{0}"
+            "from": "android/support/design/(.*)",
+            "to": "com/google/android/material/{0}"
         },
 
         # Test
diff --git a/jetifier/jetifier/core/src/main/resources/default.generated.config b/jetifier/jetifier/core/src/main/resources/default.generated.config
index 71bac38..bcd622e 100644
--- a/jetifier/jetifier/core/src/main/resources/default.generated.config
+++ b/jetifier/jetifier/core/src/main/resources/default.generated.config
@@ -796,96 +796,12 @@
       "to": "com/google/android/material/snackbar/SnackbarContentLayout{0}"
     },
     {
-      "from": "android/support/design/animation/(.*)",
-      "to": "com/google/android/material/animation/{0}"
-    },
-    {
-      "from": "android/support/design/bottomappbar/(.*)",
-      "to": "com/google/android/material/bottomappbar/{0}"
-    },
-    {
-      "from": "android/support/design/bottomnavigation/(.*)",
-      "to": "com/google/android/material/bottomnavigation/{0}"
-    },
-    {
-      "from": "android/support/design/button/(.*)",
-      "to": "com/google/android/material/button/{0}"
-    },
-    {
-      "from": "android/support/design/canvas/(.*)",
-      "to": "com/google/android/material/canvas/{0}"
-    },
-    {
-      "from": "android/support/design/card/(.*)",
-      "to": "com/google/android/material/card/{0}"
-    },
-    {
-      "from": "android/support/design/chip/(.*)",
-      "to": "com/google/android/material/chip/{0}"
-    },
-    {
-      "from": "android/support/design/circularreveal/(.*)",
-      "to": "com/google/android/material/circularreveal/{0}"
-    },
-    {
-      "from": "android/support/design/circularreveal/cardview/(.*)",
-      "to": "com/google/android/material/circularreveal/cardview/{0}"
-    },
-    {
-      "from": "android/support/design/circularreveal/coordinatorlayout/(.*)",
-      "to": "com/google/android/material/circularreveal/coordinatorlayout/{0}"
-    },
-    {
-      "from": "android/support/design/drawable/(.*)",
-      "to": "com/google/android/material/drawable/{0}"
-    },
-    {
-      "from": "android/support/design/expandable/(.*)",
-      "to": "com/google/android/material/expandable/{0}"
-    },
-    {
-      "from": "android/support/design/internal/(.*)",
-      "to": "com/google/android/material/internal/{0}"
-    },
-    {
-      "from": "android/support/design/math/(.*)",
-      "to": "com/google/android/material/math/{0}"
-    },
-    {
-      "from": "android/support/design/resources/(.*)",
-      "to": "com/google/android/material/resources/{0}"
-    },
-    {
-      "from": "android/support/design/ripple/(.*)",
-      "to": "com/google/android/material/ripple/{0}"
-    },
-    {
-      "from": "android/support/design/shape/(.*)",
-      "to": "com/google/android/material/shape/{0}"
-    },
-    {
-      "from": "android/support/design/snackbar/(.*)",
-      "to": "com/google/android/material/snackbar/{0}"
-    },
-    {
-      "from": "android/support/design/stateful/(.*)",
-      "to": "com/google/android/material/stateful/{0}"
-    },
-    {
-      "from": "android/support/design/theme/(.*)",
-      "to": "com/google/android/material/theme/{0}"
-    },
-    {
-      "from": "android/support/design/transformation/(.*)",
-      "to": "com/google/android/material/transformation/{0}"
-    },
-    {
       "from": "android/support/design/R(.*)",
       "to": "com/google/android/material/R{0}"
     },
     {
-      "from": "android/support/design/behavior/(.*)",
-      "to": "com/google/android/material/behavior/{0}"
+      "from": "android/support/design/(.*)",
+      "to": "com/google/android/material/{0}"
     },
     {
       "from": "android/support/test/(.*)",
diff --git a/jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/transform/pom/PomDocument.kt b/jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/transform/pom/PomDocument.kt
index 31a376c..1bf7b24 100644
--- a/jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/transform/pom/PomDocument.kt
+++ b/jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/transform/pom/PomDocument.kt
@@ -82,10 +82,7 @@
      * Changes are not saved back until requested.
      */
     fun applyRules(context: TransformationContext) {
-        if (context.rewritingSupportLib) {
-            rewriteOwnArtifactInfo(context)
-            hasChanged = true
-        }
+        tryRewriteOwnArtifactInfo(context)
 
         if (dependenciesGroup == null) {
             // Nothing to transform as this file has no dependencies section
@@ -117,7 +114,7 @@
         return PomDependency(groupIdNode.text, artifactIdNode.text, version.text)
     }
 
-    private fun rewriteOwnArtifactInfo(context: TransformationContext) {
+    private fun tryRewriteOwnArtifactInfo(context: TransformationContext) {
         val groupIdNode = document.rootElement
                 .getChild("groupId", document.rootElement.namespace)
         val artifactIdNode = document.rootElement
@@ -136,12 +133,13 @@
             groupIdNode.text = newDependency.groupId
             artifactIdNode.text = newDependency.artifactId
             version.text = newDependency.version
+            hasChanged = true
         }
     }
 
     private fun mapDependency(
-            dependency: PomDependency,
-            context: TransformationContext
+        dependency: PomDependency,
+        context: TransformationContext
     ): PomDependency {
         val rule = context.config.pomRewriteRules.firstOrNull { it.matches(dependency) }
         if (rule != null) {