参数' sourceEncoding' rpm-maven-plugin缺失或无效

时间:2015-05-28 19:51:22

标签: java maven rpm rpm-maven-plugin

我正在尝试使用rpm maven插件,但是我收到以下错误:

  

[错误]无法在项目TestRpmAndDocker上执行目标org.codehaus.mojo:rpm -maven-plugin:2.1.3:rpm(generate-rpm):参数' sourceEncoding'目标org.codehaus.mojo:rpm-maven-plugin:2.1.3:rpm丢失或无效 - > [帮助1]   org.apache.maven.lifecycle.LifecycleExecutionException:无法执行目标org.codehaus.mojo:rpm-maven-plugin:2.1.3:rpm(generate-rpm)项目TestRpmAndDocker:参数' sourceEncoding'目标org.codehaus.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)       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)       at 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:参数' sourceEncoding'目标org.codehaus.mojo:rpm-maven-plugin:2.1.3:rpm丢失或无效       在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>

2 个答案:

答案 0 :(得分:11)

我想您缺少以下XML片段。我建议你把它放在<build>标记之前。

<properties>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

请将此更改为您使用的编码。

答案 1 :(得分:0)

另一种选择似乎是您可以将源编码添加到插件配置中,这对我来说比据我所知应该用作变量的属性更有意义。我不明白的是为什么没有记录下来。显然也需要“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>