PageSourceSearch

https://docs.openrewrite.org/assets/js/b053293a.1a6a0dfa.js

js openrewrite.org collected 2026-10-02 03:07:25 UTC 16,606 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkrewrite_docs=self.webpackChunkrewrite_docs||[]).push([["11660"],{74657:function(e,r,i){i.r(r),i.d(r,{frontMatter:()=>l,toc:()=>j,default:()=>u,metadata:()=>t,assets:()=>p,contentTitle:()=>o});var t=JSON.parse('{"id":"recipes/maven/changepackaging","title":"Set Maven project packaging","description":"org.openrewrite.maven.ChangePackaging","source":"@site/docs/recipes/maven/changepackaging.md","sourceDirName":"recipes/maven","slug":"/recipes/maven/changepackaging","permalink":"/recipes/maven/changepackaging","draft":false,"unlisted":false,"editUrl":"https://github.com/openrewrite/rewrite-docs/edit/master/docs/recipes/maven/changepackaging.md","tags":[],"version":"current","frontMatter":{"title":"Set Maven project packaging","sidebar_label":"Set Maven project packaging"},"sidebar":"docs","previous":{"title":"Change Maven managed dependency groupId, artifactId and optionally the version","permalink":"/recipes/maven/changemanageddependencygroupidandartifactid"},"next":{"title":"Change Maven parent","permalink":"/recipes/maven/changeparentpom"}}'),s=i(74848),n=i(84429),a=i(84109),c=i(93703),d=i(70440),h=i(48416);let l={title:"Set Maven project packaging",sidebar_label:"Set Maven project packaging"},o="Set Maven project packaging",p={},j=[{value:"Recipe source",id:"recipe-source",level:2},{value:"Options",id:"options",level:2},{value:"Used by",id:"used-by",level:2},{value:"Example",id:"example",level:2},{value:"Parameters",id:"parameters",level:6},{value:"Before",id:"before",level:6},{value:"After",id:"after",level:6},{value:"Usage",id:"usage",level:2},{value:"See how this recipe works across multiple open-source repositories",id:"see-how-this-recipe-works-across-multiple-open-source-repositories",level:2},{value:"Data Tables",id:"data-tables",level:2},{value:"Source files that had results",id:"source-files-that-had-results",level:3},{value:"Source files that had search results",id:"source-files-that-had-search-results",level:3},{value:"Source files that errored on a recipe",id:"source-files-that-errored-on-a-recipe",level:3},{value:"Recipe performance",id:"recipe-performance",level:3}];function x(e){let r={a:"a",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",h6:"h6",header:"header",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,n.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(r.header,{children:(0,s.jsx)(r.h1,{id:"set-maven-project-packaging",children:"Set Maven project packaging"})}),"\n",(0,s.jsx)(r.p,{children:(0,s.jsx)(r.strong,{children:"org.openrewrite.maven.ChangePackaging"})}),"\n",(0,s.jsx)(r.p,{children:(0,s.jsx)(r.em,{children:"Sets the packaging type of Maven projects. Either adds the packaging tag if it is missing or changes its context if present."})}),"\n",(0,s.jsx)(r.h2,{id:"recipe-source",children:"Recipe source"}),"\n",(0,s.jsxs)(r.p,{children:[(0,s.jsx)(r.a,{href:"https://github.com/openrewrite/rewrite/blob/main/rewrite-maven/src/main/java/org/openrewrite/maven/ChangePackaging.java",children:"GitHub: ChangePackaging.java"}),",\n",(0,s.jsx)(r.a,{href:"https://github.com/openrewrite/rewrite/issues",children:"Issue Tracker"}),",\n",(0,s.jsx)(r.a,{href:"https://artifacts.codegenomeproject.org/maven/org/openrewrite/rewrite-maven/",children:"Code Genome Project"})]}),"\n",(0,s.jsxs)(r.p,{children:["This recipe is available under the ",(0,s.jsx)(r.a,{href:"https://www.apache.org/licenses/LICENSE-2.0",children:"Apache License Version 2.0"}),"."]}),"\n",(0,s.jsx)(r.h2,{id:"options",children:"Options"}),"\n",(0,s.jsxs)(r.table,{children:[(0,s.jsx)(r.thead,{children:(0,s.jsxs)(r.tr,{children:[(0,s.jsx)(r.th,{children:"Type"}),(0,s.jsx)(r.th,{children:"Name"}),(0,s.jsx)(r.th,{children:"Description"}),(0,s.jsx)(r.th,{children:"Example"})]})}),(0,s.jsxs)(r.tbody,{children:[(0,s.jsxs)(r.tr,{children:[(0,s.jsx)(r.td,{children:(0,s.jsx)(r.code,{children:"String"})}),(0,s.jsx)(r.td,{children:"groupId"}),(0,s.jsx)(r.td,{children:"The groupId of the project whose packaging should be changed. Accepts glob patterns."}),(0,s.jsx)(r.td,{children:(0,s.jsx)(r.code,{children:"org.openrewrite.*"})})]}),(0,s.jsxs)(r.tr,{children:[(0,s.jsx)(r.td,{children:(0,s.jsx)(r.code,{children:"String"})}),(0,s.jsx)(r.td,{children:"artifactId"}),(0,s.jsx)(r.td,{children:"The artifactId of the project whose packaging should be changed. Accepts glob patterns."}),(0,s.jsx)(r.td,{children:(0,s.jsx)(r.code,{children:"rewrite-*"})})]}),(0,s.jsxs)(r.tr,{children:[(0,s.jsx)(r.td,{children:(0,s.jsx)(r.code,{children:"String"})}),(0,s.jsx)(r.td,{children:"packaging"}),(0,s.jsxs)(r.td,{children:["The type of packaging to set. If ",(0,s.jsx)(r.code,{children:"null"})," specified the packaging tag will be removed"]}),(0,s.jsx)(r.td,{children:(0,s.jsx)(r.code,{children:"jar"})})]}),(0,s.jsxs)(r.tr,{children:[(0,s.jsx)(r.td,{children:(0,s.jsx)(r.code,{children:"String"})}),(0,s.jsx)(r.td,{children:"oldPackaging"}),(0,s.jsxs)(r.td,{children:[(0,s.jsx)(r.em,{children:"Optional"}),". The old packaging type. If provided, will only change if the current packaging matches"]}),(0,s.jsx)(r.td,{children:(0,s.jsx)(r.code,{children:"jar"})})]})]})]}),"\n",(0,s.jsx)(r.h2,{id:"used-by",children:"Used by"}),"\n",(0,s.jsx)(r.p,{children:"This recipe is used as part of the following composite recipes:"}),"\n",(0,s.jsxs)(r.ul,{children:["\n",(0,s.jsx)(r.li,{children:(0,s.jsx)(r.a,{href:"https://docs.moderne.io
1/user-documentation/recipes/recipe-catalog/java/server/jboss/jetty/migratejbosstojetty",children:"Migrate JBoss to Jetty"})}),"\n",(0,s.jsx)(r.li,{children:(0,s.jsx)(r.a,{href:"https://docs.moderne.io/user-documentation/recipes/recipe-catalog/java/server/jboss/tomcat/migratejbosstotomcat",children:"Migrate JBoss to Tomcat"})}),"\n",(0,s.jsx)(r.li,{children:(0,s.jsx)(r.a,{href:"/recipes/quarkus/migrate/javaee/addquarkus2mavenplugins",children:"Migrate JavaEE Maven Dependencies to Quarkus 2"})}),"\n"]}),"\n",(0,s.jsx)(r.h2,{id:"example",children:"Example"}),"\n",(0,s.jsx)(r.h6,{id:"parameters",children:"Parameters"}),"\n",(0,s.jsxs)(r.table,{children:[(0,s.jsx)(r.thead,{children:(0,s.jsxs)(r.tr,{children:[(0,s.jsx)(r.th,{children:"Parameter"}),(0,s.jsx)(r.th,{children:"Value"})]})}),(0,s.jsxs)(r.tbody,{children:[(0,s.jsxs)(r.tr,{children:[(0,s.jsx)(r.td,{children:"groupId"}),(0,s.jsx)(r.td,{children:(0,s.jsx)(r.code,{children:"*"})})]}),(0,s.jsxs)(r.tr,{children:[(0,s.jsx)(r.td,{children:"artifactId"}),(0,s.jsx)(r.td,{children:(0,s.jsx)(r.code,{children:"*"})})]}),(0,s.jsxs)(r.tr,{children:[(0,s.jsx)(r.td,{children:"packaging"}),(0,s.jsx)(r.td,{children:(0,s.jsx)(r.code,{children:"pom"})})]}),(0,s.jsxs)(r.tr,{children:[(0,s.jsx)(r.td,{children:"oldPackaging"}),(0,s.jsx)(r.td,{children:(0,s.jsx)(r.code,{children:"null"})})]})]})]}),"\n",(0,s.jsxs)(a.A,{groupId:"beforeAfter",children:[(0,s.jsxs)(c.A,{value:"pom.xml",label:"pom.xml",children:[(0,s.jsx)(r.h6,{id:"before",children:"Before"}),(0,s.jsx)(r.pre,{children:(0,s.jsx)(r.code,{className:"language-xml",metastring:'title="pom.xml"',children:"<project>\n    <groupId>org.example</groupId>\n    <artifactId>foo</artifactId>\n    <version>1.0</version>\n</project>\n"})}),(0,s.jsx)(r.h6,{id:"after",children:"After"}),(0,s.jsx)(r.pre,{children:(0,s.jsx)(r.code,{className:"language-xml",metastring:'title="pom.xml"',children:"<project>\n    <groupId>org.example</groupId>\n    <artifactId>foo</artifactId>\n    <version>1.0</version>\n    <packaging>pom</packaging>\n</project>\n"})})]}),(0,s.jsx)(c.A,{value:"diff",label:"Diff",children:(0,s.jsx)(r.pre,{children:(0,s.jsx)(r.code,{className:"language-diff",children:"--- pom.xml\n+++ pom.xml\n@@ -5,0 +5,1 @@\n    <artifactId>foo</artifactId>\n    <version>1.0</version>\n+   <packaging>pom</packaging>\n</project>\n"})})})]}),"\n",(0,s.jsx)(r.h2,{id:"usage",children:"Usage"}),"\n",(0,s.jsxs)(r.p,{children:["This recipe has required configuration parameters. Recipes with required configuration parameters cannot be activated directly (unless you are running them via the Moderne CLI). To activate this recipe you must create a new recipe which fills in the required parameters. In your ",(0,s.jsx)(r.code,{children:"rewrite.yml"})," create a new recipe with a unique name. For example: ",(0,s.jsx)(r.code,{children:"com.yourorg.ChangePackagingExample"}),".\nHere's how you can define and customize such a recipe within your rewrite.yml:"]}),"\n",(0,s.jsx)(r.pre,{children:(0,s.jsx)(r.code,{className:"language-yaml",metastring:'title="rewrite.yml"',children:"---\ntype: specs.openrewrite.org/v1beta/recipe\nname: com.yourorg.ChangePackagingExample\ndisplayName: Set Maven project packaging example\nrecipeList:\n  - org.openrewrite.maven.ChangePackaging:\n      groupId: org.openrewrite.*\n      artifactId: rewrite-*\n      packaging: jar\n      oldPackaging: jar\n"})}),"\n",(0,s.jsx)(d.A,{recipeName:"org.openrewrite.maven.ChangePackaging",displayName:"Set Maven project packaging",groupId:"org.openrewrite",artifactId:"rewrite-maven",versionKey:"VERSION_ORG_OPENREWRITE_REWRITE_MAVEN",isCoreLibrary:!0,requiresConfiguration:!0,cliOptions:' --recipe-option "groupId=org.openrewrite.*" --recipe-option "artifactId=rewrite-*" --recipe-option "packaging=jar" --recipe-option "oldPackaging=jar"',showGradle:!1,hasDataTables:!0}),"\n",(0,s.jsx)(r.h2,{id:"see-how-this-recipe-works-across-multiple-open-source-repositories",children:"See how this recipe works across multiple open-source repositories"}),"\n","\n",(0,s.jsx)(h.A,{link:"https://app.moderne.io/recipes/org.openrewrite.maven.ChangePackaging"}),"\n",(0,s.jsx)(r.p,{children:"The community edition of the Moderne platform enables you to easily run recipes across thousands of open-source repositories."}),"\n",(0,s.jsxs)(r.p,{children:["Please ",(0,s.jsx)(r.a,{href:"https://moderne.io
1/product",children:"contact Moderne"})," for more information about safely running the recipes on your own codebase in a private SaaS."]}),"\n",(0,s.jsx)(r.h2,{id:"data-tables",children:"Data Tables"}),"\n",(0,s.jsxs)(a.A,{groupId:"data-tables",children:[(0,s.jsxs)(c.A,{value:"org.openrewrite.table.SourcesFileResults",label:"SourcesFileResults",children:[(0,s.jsx)(r.h3,{id:"source-files-that-had-results",children:"Source files that had results"}),(0,s.jsx)(r.p,{children:(0,s.jsx)(r.strong,{children:"org.openrewrite.table.SourcesFileResults"})}),(0,s.jsx)(r.p,{children:(0,s.jsx)(r.em,{children:"Source files that were modified by the recipe run."})}),(0,s.jsxs)(r.table,{children:[(0,s.jsx)(r.thead,{children:(0,s.jsxs)(r.tr,{children:[(0,s.jsx)(r.th,{children:"Column Name"}),(0,s.jsx)(r.th,{children:"Description"})]})}),(0,s.jsxs)(r.tbody,{children:[(0,s.jsxs)(r.tr,{children:[(0,s.jsx)(r.td,{children:"Source path before the run"}),(0,s.jsxs)(r.td,{children:["The source path of the file before the run. ",(0,s.jsx)(r.code,{children:"null"})," when a source file was created during the run."]})]}),(0,s.jsxs)(r.tr,{children:[(0,s.jsx)(r.td,{children:"Source path after the run"}),(0,s.jsxs)(r.td,{children:["A recipe may modify the source path. This is the path after the run. ",(0,s.jsx)(r.code,{children:"null"})," when a source file was deleted during the run."]})]}),(0,s.jsxs)(r.tr,{children:[(0,s.jsx)(r.td,{children:"Parent of the recipe that made changes"}),(0,s.jsx)(r.td,{children:"In a hierarchical recipe, the parent of the recipe that made a change. Empty if this is the root of a hierarchy or if the recipe is not hierarchical at all."})]}),(0,s.jsxs)(r.tr,{children:[(0,s.jsx)(r.td,{children:"Recipe that made changes"}),(0,s.jsx)(r.td,{children:"The specific recipe that made a change."})]}),(0,s.jsxs)(r.tr,{children:[(0,s.jsx)(r.td,{children:"Estimated time saving"}),(0,s.jsx)(r.td,{children:"An estimated effort that a developer to fix manually instead of using this recipe, in unit of seconds."})]}),(0,s.jsxs)(r.tr,{children:[(0,s.jsx)(r.td,{children:"Cycle"}),(0,s.jsx)(r.td,{children:"The recipe cycle in which the change was made."})]})]})]})]}),(0,s.jsxs)(c.A,{value:"org.openrewrite.table.SearchResults",label:"SearchResults",children:[(0,s.jsx)(r.h3,{id:"source-files-that-had-search-results",children:"Source files that had search results"}),(0,s.jsx)(r.p,{children:(0,s.jsx)(r.strong,{children:"org.openrewrite.table.SearchResults"})}),(0,s.jsx)(r.p,{children:(0,s.jsx)(r.em,{children:"Search results that were found during the recipe run."})}),(0,s.jsxs)(r.table,{children:[(0,s.jsx)(r.thead,{children:(0,s.jsxs)(r.tr,{children:[(0,s.jsx)(r.th,{children:"Column Name"}),(0,s.jsx)(r.th,{children:"Description"})]})}),(0,s.jsxs)(r.tbody,{children:[(0,s.jsxs)(r.tr,{children:[(0,s.jsx)(r.td,{children:"Source path of search result before the run"}),(0,s.jsx)(r.td,{children:"The source path of the file with the search result markers present."})]}),(0,s.jsxs)(r.tr,{children:[(0,s.jsx)(r.td,{children:"Source path of search result after run the run"}),(0,s.jsxs)(r.td,{children:["A recipe may modify the source path. This is the path after the run. ",(0,s.jsx)(r.code,{children:"null"})," when a source file was deleted during the run."]})]}),(0,s.jsxs)(r.tr,{children:[(0,s.jsx)(r.td,{children:"Result"}),(0,s.jsx)(r.td,{children:"The trimmed printed tree of the LST element that the marker is attached to."})]}),(0,s.jsxs)(r.tr,{children:[(0,s.jsx)(r.td,{children:"Description"}),(0,s.jsx)(r.td,{children:"The content of the description of the marker."})]}),(0,s.jsxs)(r.tr,{children:[(0,s.jsx)(r.td,{children:"Recipe that added the search marker"}),(0,s.jsx)(r.td,{children:"The specific recipe that added the Search marker."})]})]})]})]}),(0,s.jsxs)(c.A,{value:"org.openrewrite.table.SourcesFileErrors",label:"SourcesFileErrors",children:[(0,s.jsx)(r.h3,{id:"source-files-that-errored-on-a-recipe",children:"Source files that errored on a recipe"}),(0,s.jsx)(r.p,{children:(0,s.jsx)(r.strong,{children:"org.openrewrite.table.SourcesFileErrors"})}),(0,s.jsx)(r.p,{children:(0,s.jsx)(r.em,{children:"The details of all errors produced by a re
1cipe run."})}),(0,s.jsxs)(r.table,{children:[(0,s.jsx)(r.thead,{children:(0,s.jsxs)(r.tr,{children:[(0,s.jsx)(r.th,{children:"Column Name"}),(0,s.jsx)(r.th,{children:"Description"})]})}),(0,s.jsxs)(r.tbody,{children:[(0,s.jsxs)(r.tr,{children:[(0,s.jsx)(r.td,{children:"Source path"}),(0,s.jsx)(r.td,{children:"The file that failed to parse."})]}),(0,s.jsxs)(r.tr,{children:[(0,s.jsx)(r.td,{children:"Recipe that made changes"}),(0,s.jsx)(r.td,{children:"The specific recipe that made a change."})]}),(0,s.jsxs)(r.tr,{children:[(0,s.jsx)(r.td,{children:"Stack trace"}),(0,s.jsx)(r.td,{children:"The stack trace of the failure."})]})]})]})]}),(0,s.jsxs)(c.A,{value:"org.openrewrite.table.RecipeRunStats",label:"RecipeRunStats",children:[(0,s.jsx)(r.h3,{id:"recipe-performance",children:"Recipe performance"}),(0,s.jsx)(r.p,{children:(0,s.jsx)(r.strong,{children:"org.openrewrite.table.RecipeRunStats"})}),(0,s.jsx)(r.p,{children:(0,s.jsx)(r.em,{children:"Statistics used in analyzing the performance of recipes."})}),(0,s.jsxs)(r.table,{children:[(0,s.jsx)(r.thead,{children:(0,s.jsxs)(r.tr,{children:[(0,s.jsx)(r.th,{children:"Column Name"}),(0,s.jsx)(r.th,{children:"Description"})]})}),(0,s.jsxs)(r.tbody,{children:[(0,s.jsxs)(r.tr,{children:[(0,s.jsx)(r.td,{children:"The recipe"}),(0,s.jsx)(r.td,{children:"The recipe whose stats are being measured both individually and cumulatively."})]}),(0,s.jsxs)(r.tr,{children:[(0,s.jsx)(r.td,{children:"Source file count"}),(0,s.jsx)(r.td,{children:"The number of source files the recipe ran over."})]}),(0,s.jsxs)(r.tr,{children:[(0,s.jsx)(r.td,{children:"Source file changed count"}),(0,s.jsx)(r.td,{children:"The number of source files which were changed in the recipe run. Includes files created, deleted, and edited."})]}),(0,s.jsxs)(r.tr,{children:[(0,s.jsx)(r.td,{children:"Cumulative scanning time (ns)"}),(0,s.jsx)(r.td,{children:"The total time spent across the scanning phase of this recipe."})]}),(0,s.jsxs)(r.tr,{children:[(0,s.jsx)(r.td,{children:"Max scanning time (ns)"}),(0,s.jsx)(r.td,{children:"The max time scanning any one source file."})]}),(0,s.jsxs)(r.tr,{children:[(0,s.jsx)(r.td,{children:"Cumulative edit time (ns)"}),(0,s.jsx)(r.td,{children:"The total time spent across the editing phase of this recipe."})]}),(0,s.jsxs)(r.tr,{children:[(0,s.jsx)(r.td,{children:"Max edit time (ns)"}),(0,s.jsx)(r.td,{children:"The max time editing any one source file."})]})]})]})]})]})]})}function u(e={}){let{wrapper:r}={...(0,n.R)(),...e.components};return r?(0,s.jsx)(r,{...e,children:(0,s.jsx)(x,{...e})}):x(e)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.