From ec356cba299bbe00857f7dc3e3f56f0938160821 Mon Sep 17 00:00:00 2001 From: qxo <49526356@qq.com> Date: Sat, 18 Mar 2023 12:28:08 +0800 Subject: [PATCH] [ARCHETYPE-638] - fix: maven-archetype pom.xml should add request encoding This commit remove below warning: [WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent! --- .../archetype/creator/FilesetArchetypeCreator.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/archetype-common/src/main/java/org/apache/maven/archetype/creator/FilesetArchetypeCreator.java b/archetype-common/src/main/java/org/apache/maven/archetype/creator/FilesetArchetypeCreator.java index 6c0a03df3..871a5c271 100644 --- a/archetype-common/src/main/java/org/apache/maven/archetype/creator/FilesetArchetypeCreator.java +++ b/archetype-common/src/main/java/org/apache/maven/archetype/creator/FilesetArchetypeCreator.java @@ -138,7 +138,8 @@ public void createArchetype( ArchetypeCreationRequest request, ArchetypeCreation try { File archetypePomFile = createArchetypeProjectPom( project, request.getProjectBuildingRequest(), - configurationProperties, outputDirectory ); + configurationProperties, outputDirectory, + defaultEncoding ); File archetypeResourcesDirectory = new File( outputDirectory, getTemplateOutputDirectory() ); @@ -391,10 +392,15 @@ else if ( !properties.containsKey( Constants.PACKAGE ) ) * Create the archetype project pom.xml file, that will be used to build the archetype. */ private File createArchetypeProjectPom( MavenProject project, ProjectBuildingRequest buildingRequest, - Properties configurationProperties, File projectDir ) + Properties configurationProperties, File projectDir, + String defaultEncoding ) throws TemplateCreationException, IOException { Model model = new Model(); + if ( StringUtils.isNotBlank( defaultEncoding ) ) + { + model.getProperties().put( "project.build.sourceEncoding", defaultEncoding ); + } model.setModelVersion( "4.0.0" ); // these values should be retrieved from the request with sensible defaults model.setGroupId( configurationProperties.getProperty( Constants.ARCHETYPE_GROUP_ID, project.getGroupId() ) );