Skip to content

Jar entries are duplicated in BOOT-INF/lib with layered jars and Maven #23801

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

Closed
Ahli opened this issue Oct 21, 2020 · 9 comments
Closed

Jar entries are duplicated in BOOT-INF/lib with layered jars and Maven #23801

Ahli opened this issue Oct 21, 2020 · 9 comments
Assignees
Labels
type: regression A regression from a previous release
Milestone

Comments

@Ahli
Copy link

Ahli commented Oct 21, 2020

In my project, a generated executable jar contains every jar within the BOOT-INF/lib directory twice with identical file names. This pretty much doubles the size of the final jar.

The issue is not present in 2.4.0-M1 of the Maven-Plugin.
The issue is present since 2.4.0-M2. So, M4 still contains it.

The produced executable jar is functional. Just the file size is doubled.

My library usage:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <version>2.4.0-M4</version> <!-- M2-M4 add lib jars twice; M1 is fine -->
    <executions>
        <execution>
            <goals>
                <goal>repackage</goal>
            </goals>
            <configuration>
                <!--<finalName>${jarName}</finalName>-->
                <layout>JAR</layout>
                <classifier>spring-boot</classifier>
                <mainClass>${mainClass}</mainClass>
            </configuration>
        </execution>
    </executions>
</plugin>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 21, 2020
@philwebb
Copy link
Member

I'm having trouble replicating this issue. Could you please share a sample project that shows the problem?

@philwebb philwebb added the status: waiting-for-feedback We need additional information before we can continue label Oct 21, 2020
@Ahli
Copy link
Author

Ahli commented Oct 21, 2020

Project where I encounter this issue: https://github.com/Ahli/Galaxy-Observer-UI/tree/master/tools/interfaceBuilder

I will try and reduce this to a small standalone project demonstrating the issue.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Oct 21, 2020
@philwebb
Copy link
Member

I'm manged to build that project after running mvn install -DskipTests I don't see any duplicates. Running unzip -l target/compile.jar | sort | uniq -c shows a count of 1 for all jars.

Is there any trick to getting the duplicate entries? What operating system are you using?

@philwebb philwebb added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Oct 21, 2020
@Ahli
Copy link
Author

Ahli commented Oct 21, 2020

My environment: Win 10 20H2, JDK 15, Maven 3.5.3, IntelliJ IDEA 2020.3EAP

Here are the jars generated for me (placed in a single zip): https://www.dropbox.com/s/vz1gj1brakt33pr/spring_issue23801.zip?dl=1

Using 7zip, the jars inside BOOT-INF\lib\ are listed as duplicates. Extracting the zip asks for these files to be overwritten. The expected jar size would be approx 56mb (as created with M1). The jar it generates is approx 112mb.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Oct 21, 2020
@philwebb
Copy link
Member

I think I see the duplicates. They're in compile-spring-boot.jar not compile.jar.

@philwebb
Copy link
Member

A standard project from start.spring.io with the following plugin config replicates it:

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<executions>
					<execution>
						<goals>
							<goal>repackage</goal>
						</goals>
						<configuration>
						  <classifier>spring-boot</classifier>
					  </configuration>
					</execution>
			  </executions>
			</plugin>
		</plugins>
	</build>

@philwebb philwebb added type: blocker An issue that is blocking us from releasing and removed status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged labels Oct 21, 2020
@philwebb philwebb added this to the 2.4.x milestone Oct 21, 2020
@Ahli
Copy link
Author

Ahli commented Oct 21, 2020

The issue is not present when layering is disabled.

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <version>2.4.0-M4</version>
    <executions>
        <execution>
            <goals>
                <goal>repackage</goal>
            </goals>
            <configuration>
                <layers>
                    <enabled>false</enabled> <!-- prevents duplicated jars in BOOT-INF/lib/ in 2.4.0-M2 to M4 -->
                </layers>
                <layout>JAR</layout>
                <classifier>spring-boot</classifier>
                <mainClass>${mainClass}</mainClass>
            </configuration>
        </execution>
    </executions>
</plugin>

Layering was enabled by default between M1 and M2 (between 29th June and 14th August 2020).

Commit History: https://github.com/spring-projects/spring-boot/commits/master/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven
Commit that enabled layering by default: 41f5ba9#diff-9621a7691c90b1bf3c0b6cdebd10f29dbd8a3fd27aef00b8357b44725ed90804

@snicoll snicoll changed the title Spring-Boot-Maven-Plugin adds BOOT-INF/lib jars twice into executable jar since 2.4.0-M2 Jar entries are duplicated in BOOT-INF/lib with layered jars and Maven Oct 22, 2020
@wilkinsona
Copy link
Member

All of the launcher classes are also packaged twice. Once beneath / and once beneath /BOOT-INF/classes/.

@wilkinsona
Copy link
Member

wilkinsona commented Oct 22, 2020

The launcher classes and the contents of BOOT-INF/lib are also duplicated with 2.3.4. This is the configuration I used:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <executions>
        <execution>
            <goals>
                <goal>repackage</goal>
            </goals>
            <configuration>
                <layers>
                    <enabled>true</enabled>
                </layers>
                <classifier>spring-boot</classifier>
            </configuration>
        </execution>
    </executions>
</plugin>

The duplication of the launcher classes seems to be unrelated to layers as it also occurs with layers disabled.

@wilkinsona wilkinsona modified the milestones: 2.4.x, 2.3.x Oct 22, 2020
@philwebb philwebb self-assigned this Oct 22, 2020
@philwebb philwebb added type: regression A regression from a previous release and removed type: blocker An issue that is blocking us from releasing labels Oct 23, 2020
@philwebb philwebb modified the milestones: 2.3.x, 2.3.5 Oct 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: regression A regression from a previous release
Projects
None yet
Development

No branches or pull requests

4 participants