java.io.IOException: The input doesn't contain any classes. Did you specify the proper '-injars' opt

來源:互聯網
上載者:User

標籤:maven   打包   version   proguard   ioexceptio   

問題情境

在使用Maven + Proguard打包項目進行混淆時,提示以下錯誤:

[proguard] ProGuard, version 4.4 [proguard] Reading input... [proguard] java.io.IOException: The input doesn‘t contain any classes. Did you specify the proper ‘-injars‘ options? [proguard]     at proguard.InputReader.execute(InputReader.java:91) [proguard]     at proguard.ProGuard.readInput(ProGuard.java:195) [proguard]     at proguard.ProGuard.execute(ProGuard.java:78) [proguard]     at proguard.ProGuard.main(ProGuard.java:499)
問題分析

缺少injars配置項!
-injars {class_path} 指定要處理的應用程式jar,war,ear和目錄

解決方案

添加injars配置項,由於是Web項目,所以這裡指定的是war

<injar>${project.build.finalName}.war</injar>

完整樣本:

            <plugin>                <groupId>com.pyx4me</groupId>                <artifactId>proguard-maven-plugin</artifactId>                <version>2.0.4</version>                <executions>                    <execution>                        <phase>package</phase>                        <goals>                            <goal>proguard</goal>                        </goals>                    </execution>                </executions>                <configuration>                    <obfuscate>true</obfuscate>                    <proguardInclude>${basedir}/proguard.conf</proguardInclude>                    <!-- 添加依賴,這裡你可以按你的需要修改 -->                    <libs>                        <lib>${java.home}/lib/rt.jar</lib>                        <lib>lib/jsp-api.jar</lib>                        <lib>lib/servlet-api.jar</lib>                    </libs>                    <addMavenDescriptor>false</addMavenDescriptor>                    <injar>${project.build.finalName}.war</injar>                    <outjar>${project.build.finalName}-pg.war</outjar>                    <outputDirectory>${project.build.directory}</outputDirectory>                </configuration>                <dependencies>                     <!-- 使用4.4版本來混淆 -->                    <dependency>                        <groupId>net.sf.proguard</groupId>                        <artifactId>proguard</artifactId>                          <version>4.4</version>                        <scope>runtime</scope>                    </dependency>                </dependencies>            </plugin>

java.io.IOException: The input doesn't contain any classes. Did you specify the proper '-injars' opt

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.