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 @@ -86,6 +86,9 @@ private MappingUtils() {
* @return expression the expression to be evaluated
*/
public static String evaluateFileNameMapping(String expression, Artifact artifact) throws InterpolationException {
if (artifact == null) {
throw new IllegalArgumentException("artifact cannot be null");
}

RegexBasedInterpolator interpolator = new RegexBasedInterpolator("\\@\\{(", ")?([^}]+)\\}@");
interpolator.addValueSource(new ObjectBasedValueSource(artifact));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

/**
* Tests the mapping of file names.
Expand Down Expand Up @@ -117,4 +118,11 @@ void mappingWithOptionalClassifier() throws Exception {
"maven-test-lib-1.0-classifier.jar",
MappingUtils.evaluateFileNameMapping(mappingWithOptionalClassifier2, jar));
}

@Test
void mappingWithNullArtifact() {
assertThrows(
IllegalArgumentException.class,
() -> MappingUtils.evaluateFileNameMapping("@{artifactId}@.@{extension}@", null));
}
}