参数 'sourceEncoding' rpm-maven-plugin 丢失或无效
Posted
技术标签:
【中文标题】参数 \'sourceEncoding\' rpm-maven-plugin 丢失或无效【英文标题】:The parameters 'sourceEncoding' rpm-maven-plugin are missing or invalid参数 'sourceEncoding' rpm-maven-plugin 丢失或无效 【发布时间】:2015-08-11 12:18:13 【问题描述】:我正在尝试使用 rpm maven 插件但我收到以下错误:
[错误] 无法在项目 TestRpmAndDocker 上执行目标 org.codehaus.mojo:rpm-maven-plugin:2.1.3:rpm (generate-rpm):目标 org.codehaus.mojo:rpm 的参数“sourceEncoding” -maven-plugin:2.1.3:rpm 丢失或无效 -> [帮助 1] org.apache.maven.lifecycle.LifecycleExecutionException:无法在项目 TestRpmAndDocker 上执行目标 org.codehaus.mojo:rpm-maven-plugin:2.1.3:rpm (generate-rpm):目标 org.codehaus 的参数“sourceEncoding” .mojo:rpm-maven-plugin:2.1.3:rpm 丢失或无效 在 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:220) 在 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) 在 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) 在 org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:108) 在 org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76) 在 org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) 在 org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116) 在 org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361) 在 org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155) 在 org.apache.maven.cli.MavenCli.execute(MavenCli.java:584) 在 org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213) 在 org.apache.maven.cli.MavenCli.main(MavenCli.java:157) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在 java.lang.reflect.Method.invoke(Method.java:497) 在 org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) 在 org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) 在 org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) 在 org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) 原因:org.apache.maven.plugin.PluginParameterException:目标 org.codehaus.mojo:rpm-maven-plugin:2.1.3:rpm 的参数“sourceEncoding”丢失或无效 在 org.apache.maven.plugin.internal.DefaultMavenPluginManager.populatePluginFields(DefaultMavenPluginManager.java:584) 在 org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:537) 在 org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:120) 在 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) ... 19 更多
这是我的 pom:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>TestRpmAndDocker</groupId>
<artifactId>TestRpmAndDocker</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>TestRpmAndDocker</name>
<description>TestRpmAndDocker</description>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>rpm-maven-plugin</artifactId>
<version>2.1.3</version>
<executions>
<execution>
<id>generate-rpm</id>
<goals>
<goal>rpm</goal>
</goals>
</execution>
</executions>
<configuration>
<license>GPL (c) 2005, SWWDC</license>
<distribution>Trash 2005</distribution>
<group>Application/Collectors</group>
<icon>src/main/resources/icon.gif</icon>
<packager>SWWDC</packager>
<prefix>/usr/local</prefix>
<changelogFile>src/changelog</changelogFile>
<defineStatements>
<defineStatement>_unpackaged_files_terminate_build 0</defineStatement>
</defineStatements>
<mappings>
<mapping>
<directory>/usr/local/bin/landfill</directory>
<filemode>440</filemode>
<username>dumper</username>
<groupname>dumpgroup</groupname>
<sources>
<source>
<location>target/classes</location>
</source>
</sources>
</mapping>
<mapping>
<directory>/usr/local/doc/landfill</directory>
<documentation>true</documentation>
<filemode>444</filemode>
<username>dumper</username>
<groupname>dumpgroup</groupname>
<sources>
<source>
<location>target/site</location>
</source>
</sources>
</mapping>
<mapping>
<directory>/usr/local/lib</directory>
<filemode>750</filemode>
<username>dumper</username>
<groupname>dumpgroup</groupname>
<dependency>
<includes>
<include>jmock:jmock</include>
<include>javax.servlet:servlet-api:2.4</include>
</includes>
<excludes>
<exclude>junit:junit</exclude>
</excludes>
</dependency>
</mapping>
<mapping>
<directory>/usr/local/bin</directory>
<filemode>750</filemode>
<username>dumper</username>
<groupname>dumpgroup</groupname>
<sources>
<source>
<location>src/main/bin</location>
</source>
<softlinkSource>
<location>/usr/local/bin/new.sh</location>
<destination>old.sh</destination>
</softlinkSource>
</sources>
</mapping>
<mapping>
<directory>/usr/local/oldbin</directory>
<filemode>750</filemode>
<username>dumper</username>
<groupname>dumpgroup</groupname>
<sources>
<softlinkSource>
<location>/usr/local/bin</location>
</softlinkSource>
</sources>
</mapping>
<mapping>
<directory>/usr/local/conf/landfill</directory>
<configuration>true</configuration>
<filemode>640</filemode>
<username>dumper</username>
<groupname>dumpgroup</groupname>
<sources>
<source>
<location>src/main/conf</location>
</source>
</sources>
</mapping>
<mapping>
<directory>/usr/local/log/landfill</directory>
<filemode>750</filemode>
<username>dumper</username>
<groupname>dumpgroup</groupname>
</mapping>
</mappings>
<preinstallScriptlet>
<script>echo "installing now"</script>
</preinstallScriptlet>
<postinstallScriptlet>
<scriptFile>src/main/scripts/postinstall</scriptFile>
<fileEncoding>utf-8</fileEncoding>
</postinstallScriptlet>
</configuration>
</plugin>
</plugins>
</build>
【问题讨论】:
您能否发布完整的错误输出,而不仅仅是摘录。 你怎么称呼maven?mvn clean package
?您使用哪个 Maven 版本?
【参考方案1】:
我想您缺少以下 XML 片段。我建议你把它放在你的<build>
标签之前。
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
请将其更改为您使用的编码。
【讨论】:
【参考方案2】:另一种方法似乎是您可以将源编码添加到插件配置中,这对我来说比据我所知应该用作变量的属性更有意义。我不明白为什么没有记录在案。显然也需要“rpm”,尽管据我了解这破坏了以前的版本:RPM package using maven
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>rpm-maven-plugin</artifactId>
<version>2.2.0</version>
<extensions>true</extensions>
<configuration>
<sourceEncoding>UTF-8</sourceEncoding>
</configuration>
</plugin>
</plugins>
</build>
【讨论】:
以上是关于参数 'sourceEncoding' rpm-maven-plugin 丢失或无效的主要内容,如果未能解决你的问题,请参考以下文章