Jump to content

I would like some help with this problem i have with my SpringBoot - proguard project

Carlosp17

So far i've been able to obfuscate what i needed and now i'm looking for using the compiled file, in this case i need to use a war file but i'm not able to make the -outjar to export a working .war file, here is a part of my pom.xml.


I don't know what is the right way to do this, i tried using a .war as -injar, i checked that the mainClass tag is there and other things.

 

As far as i'm aware, it is not about any configuration in the proguard.conf file, because it works perfect in terms of what it obfuscates and what doesn't.

 

The problem is that, i can generate a .war file, but the mainfest.MF doesn´t have the Main-Class attribute and the org.springframework.boot.loader is not included in the .war file. If i do the same process, with jar it works completely perfect, so i don't know what may be causing this.

	<build>
		<finalName>${project.artifactId}</finalName>
		<plugins>
			<plugin>
				<groupId>com.github.wvengen</groupId>
				<artifactId>proguard-maven-plugin</artifactId>
				<version>${proguard.maven.plugin.version}</version>
				<executions>
					<execution>
						<phase>package</phase>
						<goals>
							<goal>proguard</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<proguardVersion>${proguard.version}</proguardVersion>
					<injar>${project.build.finalName}.jar</injar>
					<outjar>${project.build.finalName}-obf.war</outjar>
					<obfuscate>true</obfuscate>
					<proguardInclude>proguard.conf</proguardInclude>
					<options></options>

					<injarNotExistsSkip>true</injarNotExistsSkip>
					<libs>
						<!--Put here your libraries if required-->
						<lib>${java.home}/lib/rt.jar</lib>
						<lib>${java.home}/lib/jsse.jar</lib>
					</libs>
				</configuration>
				<dependencies>
					<dependency>
						<groupId>com.guardsquare</groupId>
						<artifactId>proguard-base</artifactId>
						<version>${proguard.version}</version>
					</dependency>
				</dependencies>
			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>${maven.compiler.plugin.version}</version>
				<configuration>
					<source>${java.version}</source>
					<target>${java.version}</target>
				</configuration>
			</plugin>

			<!-- Maven assembly must be run after proguard obfuscation so it take already obfuscated files.-->
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<executions>
					<execution>
						<goals>
							<goal>repackage</goal>
						</goals>
						<configuration>
							<mainClass>com.abc2001.app.BaseApplication</mainClass>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×