yWorks/yGuard

error on spring boot Multiple package projects

rolkey opened this issue · 2 comments

            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.8</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <id>obfuscate</id>
                        <configuration>
                            <tasks>
                                <property
                                        name="project.build.prefix"
                                        value="${project.build.directory}/${project.build.finalName}"/>
                                <property
                                        name="project.jar"
                                        value="${project.build.prefix}.jar"/>

                                <!--
                                  check if the project jar / project build artefact already
                                  exists
                                  -->
                                <available
                                        file="${project.jar}"
                                        property="project.jar.exists"/>
                                <fail unless="project.jar.exists">${project.jar} does not exist.</fail>

                                <!-- backup the project jar -->
                                <property
                                        name="project.jar.unobf"
                                        value="${project.build.prefix}_unobf.jar"/>
                                <move
                                        file="${project.jar}"
                                        tofile="${project.jar.unobf}"
                                        verbose="true"/>

                                <!-- extract the application classes for obfuscation -->
                                <property
                                        name="project.classes.unobf"
                                        value="${project.build.prefix}_classes_unobf.jar"/>
                                <jar destfile="${project.classes.unobf}">
                                    <mappedresources>
                                        <zipfileset src="${project.jar.unobf}">
                                            <include name="BOOT-INF/classes/**"/>
                                        </zipfileset>
                                        <mapper
                                                type="glob"
                                                from="BOOT-INF/classes/*"
                                                to="*"/>
                                    </mappedresources>
                                </jar>

                                <!-- obfuscate the application classes -->
                                <property
                                        name="runtime.classpath"
                                        refid="maven.runtime.classpath"/>
                                <property
                                        name="project.classes.obf"
                                        value="${project.build.prefix}_classes_obf.jar"/>
                                <taskdef
                                        name="yguard"
                                        classname="com.yworks.yguard.YGuardTask"
                                        classpathref="maven.test.classpath"/>
                                <yguard>
                                    <inoutpair
                                            in="${project.classes.unobf}"
                                            out="${project.classes.obf}"/>

                                    <externalclasses>
                                        <pathelement path="${runtime.classpath}"/>
                                    </externalclasses>

                                    <rename
                                            mainclass="${mainclass}"
                                            logfile="${project.build.directory}/${project.build.finalName}_renamelog.xml">
                                    </rename>
                                </yguard>

                                <!--
                                  recreate the project jar / project build artefact
                                  use the zip task for easy copying of the manifest file from
                                  the original project jar / project build artefact
                                  -->
                                <zip
                                        compress="false"
                                        destfile="${project.jar}">
                                    <zipfileset src="${project.jar.unobf}">
                                        <include name="**"/>
                                        <exclude name="BOOT-INF/classes/**"/>
                                    </zipfileset>
                                    <zipfileset
                                            src="${project.classes.obf}"
                                            prefix="BOOT-INF/classes">
                                        <include name="**"/>
                                        <exclude name="META-INF/**"/>
                                    </zipfileset>
                                </zip>
                            </tasks>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
  • error is
 o.s.b.SpringApplication - [reportFailure,818] - Application run failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.rolkey.drg.RolkeyDrg11Application]; nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'a' for bean class [com.rolkey.drg.A.A.A.A] conflicts with existing, non-compatible bean definition of same name and class [com.rolkey.drg.A.A.A]

This is the same issue as Obfuscated Spring Boot Web jar cannot be run. See especially this comment.

Thank you very mach!! Document is very clearly.