Proguard说它找不到任何课程 [英] Proguard is saying it can't find any classes

查看:111
本文介绍了Proguard说它找不到任何课程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有spring mvc应用程序和maven的proguard。

I'm using proguard with a spring mvc application and maven.

我的pom.xml的构建部分如下所示:

My pom.xml's build section looks like:

<build>
        <finalName>myapp</finalName>
        <plugins>
           <plugin>
                <groupId>com.pyx4me</groupId>
                <artifactId>proguard-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>proguard</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <obfuscate>true</obfuscate>
                    <!--<options>-->
                        <!--<option>-keep public class</option>-->
                    <!--</options>-->
                    <injar>${project.build.finalName}</injar>
                    <injar>${project.build.finalName}</injar>
                    <inFilter>com.myapp.*</inFilter>
                </configuration>
            </plugin>
         </plugins>

我也试过:

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

当我跑步时:

mvn clean install

构建失败消息:

[proguard] Reading program war [/Users/me/dev/git/myproject/myapp/target/myapp.war] (filtered)
 [proguard] Error: The input doesn't contain any classes. Did you specify the proper '-injars' options?

ERROR] Failed to execute goal com.pyx4me:proguard-maven-plugin:2.0.4:proguard (default) on project myapp: Obfuscation failed (result=1) -> [Help 1]

它似乎已经正确地拿起了我的jar作为show之前的消息:

It seems to have picked up my jar correctly as the messages before show:

[INFO] --- proguard-maven-plugin:2.0.4:proguard (default) @ myapp ---
[INFO] execute ProGuard [-injars, '/Users/me/dev/gitserver/myproject/myapp/target/myapp.war'(!META-INF/maven/**,com.myapp.*), -outjars, '/Users/me/dev/git/myproject/myapp/target/myapp_pg.war', -libraryjars, ....

另外,你建议我使用哪些选项?这是一个春天的mvc所以我有这样的注释:

Also, what options do you suggest I use? This is a spring mvc so I have annotations like:


  1. @Autowired

  2. @Service

  3. @Repository

  4. @Controller

  1. @Autowired
  2. @Service
  3. @Repository
  4. @Controller

所以这些类/字段中的任何一个都不应该重命名我想象。

So any of those classes/fields should not be renamed I would imagine.

(我的目标只是让那些反编译的人头疼,这样他们就不能反编译和使用代码。混淆会让他们使用它,但他们无法做到除非重新编写代码库,否则请进入代码库。我没有任何花哨的算法,所以我在这方面没有什么可隐瞒的。)

(My goal is just to make it a headache to someone who decompiles, such that they can't just decompile and use the code. Obfuscating will let them use it, but they won't be able to maintain the codebase unless they re-write it. I don't have any fancy algorithms so I have nothing really to hide in that respect.)

更新

让我在这里说清楚,我的spring mvc因为某种原因使用maven(我是maven的新手),当做一个mvn clean install时会产生一个myapp.war文件和一个爆炸的战争myapp /(这是我想在生产中部署的,而不是myapp.war文件)

Let me be clear here, my spring mvc using maven for some reason (I'm new to maven) when doing a mvn clean install produces both a myapp.war file and a exploded war myapp/ (this is what I want to deploy in production, not the myapp.war file)

我的myapp文件夹有:

My myapp folder has:

/target/myapp/
/target/myapp/meta-inf (empty folder)
/target/myapp/web-inf
/target/myapp/web-inf/classes (com.myapp. ...)
/target/myapp/web-inf/lib/
/target/myapp/web-inf/ web.xml, application.xml (for spring)
/target/myapp/web-inf/views/

那么proguard应该在/ target / myapp / web-inf / classes文件夹中混淆吗?
如何告诉它这样做?

So proguard should be obfuscating in the /target/myapp/web-inf/classes folder right? How do I tell it to do so?

更新2

我现在得到这个:

好的,我没有得到:未能执行目标... proguard ..无法重命名/ Users / me / dev / git / project1 / myapp / target / myapp / web-inf / classes(有关我在pom.xml中更改的内容,请参阅我的更新部分)

OK, I am not getting: failed to execute goal ...proguard .. Can't rename /Users/me/dev/git/project1/myapp/target/myapp/web-inf/classes (see my updates section for what I changed in my pom.xml)

我改变了我的pom.xml包含:

I changed my pom.xml with:

            <configuration>
                <obfuscate>true</obfuscate>

                <injar>${project.build.finalName}/WEB-INF/classes/</injar>
                <inFilter>com/myapp/**</inFilter>
            </configuration>


推荐答案

ProGuard过滤器处理文件名,所以

ProGuard filters work on file names, so

.....(!META-INF/maven/**,com.myapp.*)

可能与任何类文件都不匹配。你可能想要

probably won't match any class files. You probably want

.....(!META-INF/maven/**,com/myapp/**)

参见 ProGuard手册>用法>文件过滤器

这篇关于Proguard说它找不到任何课程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆