Skip to content

new feateure: allow additional packaging type to set extension #149

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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 @@ -106,12 +106,20 @@ public String toString() {
* Thrown if typeName is {@code null} or empty
*/
public static PackagingType of(String typeName) throws IllegalArgumentException {
return of(typeName, typeName, "");
}

public static PackagingType of(String typeName, String extension) throws IllegalArgumentException {
return of(typeName, extension, "");
}

public static PackagingType of(String typeName, String extension, String classifier) throws IllegalArgumentException {
PackagingType packagingType = fromCache(typeName);
if (packagingType != null){
return packagingType;
}
// this will cause packaging object to register into cache
return new PackagingType(typeName);
return new PackagingType(typeName, extension == null ? typeName : extension, classifier == null ? "" : classifier);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,17 @@ public void random() {
Assert.assertEquals("random", PackagingType.of("random").toString());
}

@Test
public void bundle() {
final PackagingType packagingType = PackagingType.of("bundle", "jar");
Assert.assertEquals("bundle", packagingType.toString());
Assert.assertEquals("jar", packagingType.getExtension());
Assert.assertEquals("", packagingType.getClassifier());

final PackagingType packagingType2 = PackagingType.of("bundle2", null, null);
Assert.assertEquals("bundle2", packagingType2.toString());
Assert.assertEquals("bundle2", packagingType2.getExtension());
Assert.assertEquals("", packagingType2.getClassifier());
}

}