diff --git a/src/main/java/org/openrewrite/jenkins/AddJellyXmlDeclaration.java b/src/main/java/org/openrewrite/jenkins/AddJellyXmlDeclaration.java new file mode 100644 index 0000000..700dddf --- /dev/null +++ b/src/main/java/org/openrewrite/jenkins/AddJellyXmlDeclaration.java @@ -0,0 +1,84 @@ +/* + * Copyright 2024 the original author or authors. + *
+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *
+ * https://www.apache.org/licenses/LICENSE-2.0 + *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openrewrite.jenkins;
+
+import org.openrewrite.ExecutionContext;
+import org.openrewrite.Recipe;
+import org.openrewrite.text.PlainText;
+import org.openrewrite.text.PlainTextVisitor;
+
+/**
+ * Recipe to add an XML declaration to Jelly files.
+ */
+public class AddJellyXmlDeclaration extends Recipe {
+ private static final String JELLY_DECLARATION = "";
+
+ /**
+ * Returns the display name of the recipe.
+ *
+ * @return the display name of the recipe
+ */
+ @Override
+ public String getDisplayName() {
+ return "Add XML declaration to Jelly files";
+ }
+
+ /**
+ * Returns the description of the recipe.
+ *
+ * @return the description of the recipe
+ */
+ @Override
+ public String getDescription() {
+ return "Ensure the XML declaration `` is present in all `.jelly` files.";
+ }
+
+ /**
+ * Returns a visitor that adds the XML declaration to Jelly files.
+ *
+ * @return a PlainTextVisitor that adds the XML declaration
+ */
+ @Override
+ public PlainTextVisitor
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openrewrite.jenkins;
+
+import org.junit.jupiter.api.Test;
+import org.openrewrite.DocumentExample;
+import org.openrewrite.test.RecipeSpec;
+import org.openrewrite.test.RewriteTest;
+
+import static org.openrewrite.test.SourceSpecs.text;
+
+class AddJellyXmlDeclarationTest implements RewriteTest {
+
+ @Override
+ public void defaults(RecipeSpec spec) {
+ spec.recipe(new AddJellyXmlDeclaration());
+ }
+
+ @DocumentExample
+ @Test
+ void addJellyXmlDeclaration() {
+ rewriteRun(
+ //language=xml
+ text(
+ """
+ Simple Example
+ Simple Example
+ Hello, World!
+ Hello, World!
+ Hello, World!
+