Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no main manifest attribute #164

Open
ThanhDat2804 opened this issue Oct 28, 2024 · 3 comments
Open

no main manifest attribute #164

ThanhDat2804 opened this issue Oct 28, 2024 · 3 comments

Comments

@ThanhDat2804
Copy link

ThanhDat2804 commented Oct 28, 2024

when i run my obfuscated.jar it show error no main manifest attribute, in target\crud-spring-boot-thymeleaf-0.0.1-SNAPSHOT-obfuscated.jar here is my build

                    <configuration>
                        <target>
                            <taskdef name="yguard"
                                     classname="com.yworks.yguard.YGuardTask"
                                     classpathref="maven.plugin.classpath"/>

                            <yguard>
                                <inoutpair in="${project.build.directory}/${project.build.finalName}.jar"
                                           out="${project.build.directory}/${project.build.finalName}-obfuscated.jar"/>

                                <rename mainclass="com.crudapp.SpringBootCrudApplication"
                                        logfile="${project.build.directory}/renaming-log.xml">
                                    <keep>
                                        <!-- Main Spring Boot Application -->
                                        <class name="com.crudapp.SpringBootCrudApplication"/>

                                        <!-- Spring components and configurations -->
                                        <class name="com.crudapp.entity.*"/>
                                        <class name="com.crudapp.repository.*"/>
                                        <class name="com.crudapp.service.*"/>
                                        <class name="com.crudapp.service.impl.*"/>

                                        <!-- Keep Spring annotations -->
                                        <class name="org.springframework.**"/>
                                        <class name="jakarta.persistence.**"/>

                                        <!-- Optionally keep all classes in your package -->
                                        <class name="com.crudapp.**"/>
                                    </keep>
                                </rename>
                            </yguard>
                        </target>
                    </configuration>
@thomasbehr
Copy link
Member

This is from your Maven POM, right? In this case, please see the processing example POM. All the steps in the example's antrun configuration are necessary to successfully obfuscate a Spring Boot application (see the inline comment right before the antrun configuration). You probably need to adjust your configuration accordingly.

@ThanhDat2804
Copy link
Author

can i make yguard-rules.xml or something to manage rules obfuscate? I seem if i put all in POM it may be difficult to read

@thomasbehr
Copy link
Member

Well, I am not a Maven expert, thus I cannot recommend any best practices.

What is possible, though, is to move the ANT target in your antrun configuration into a separate ANT build file and call that target from your Maven POM. E.g. suppose you create an ANT build file named obfuscate.xml that looks something like this:

<project name="...">
  <target name="obfuscate">
    ...
  </target>
  ...
</project>

You can call the obfuscate target from said ANT build file like so:

<configuration>
  <target>
    <ant
     antfile="./obfuscate.xml"
     dir="${basedir}"
     target="obfuscate">
      <property
       name="build.dir"
       value="${project.build.directory}"/>
      ...
    </ant>
  </target>
</configuration>

You probably need to pass more properties to the obfuscate target depending on what properties your inline target currently uses.
See the ANT manual for more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants