Proguard is saying it can't find any classes

前端 未结 2 693
一个人的身影
一个人的身影 2021-01-02 19:29

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

My pom.xml\'s build section looks like:


        myapp<         


        
2条回答
  •  难免孤独
    2021-01-02 20:05

    Can you post your entire pom?

    Normally, Maven compiles to /target/classes (Even for WAR files) and the WAR plugin does the copy to web-inf/classes right before the package phase. You should not be manually compiling classes to web-inf/lib with Maven.

    EDIT: OK this has take quite a bit of research, but I've found an answer for you. First, according to the ProGuard documentation, you should not have ANY classes in your war project:

    Notably, class files that are in the WEB-INF/classes directory in a war should be packaged in a jar and put in the WEB-INF/lib directory

    You need to refactor your project so your web classes are built in a separate jar. Once you have built that jar project, you must add it as a dependency in your war project.

    Once I created that setup, I was successfully able to build a war project with the following configuration:

    
            
                
                    com.pyx4me
                    proguard-maven-plugin
                    
                        
                            package
                            
                                proguard
                            
                        
                    
                    
                        com/example/**
                        
                            ${java.home}/lib/rt.jar
                            ${java.home}/lib/jsse.jar
                        
                        
                            
                            
                            
                        
                    
                
            
        
    

    Note the "com.example.echo.EchoServlet". Since progaurd was going to change the name of my classes, I had to "keep" this servlet name so I could reference it in the WAR project's web.xml. If you use annotation based servlet configuration, I imagine this won't be necessary.

提交回复
热议问题