Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ protected Manifest doGetManifest(

DependencyResolverResult result;
if (config.isAddClasspath() || config.isAddExtensions()) {
if (session == null) {
throw new IllegalArgumentException("Session is required when addClasspath or addExtensions is enabled. "
+ "Use getManifest(Session, Project, ManifestConfiguration) instead.");
}
result = session.getService(DependencyResolver.class).resolve(session, project, PathScope.MAIN_RUNTIME);
} else {
result = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,18 @@ void setup() {
when(dependencyResolverResult.getDependencies()).thenReturn(dependencies);
}

@Test
void getManifestWithoutSessionWhenAddClasspath() {
MavenArchiver archiver = new MavenArchiver();
Project project = getDummyProject();
ManifestConfiguration config = new ManifestConfiguration();
config.setAddClasspath(true);

assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> archiver.getManifest(project, config))
.withMessageContaining("Session");
}

@ParameterizedTest
@EmptySource
@ValueSource(
Expand Down
Loading