/** * Builds a {@link PackagingType} object. * If an appropriate object is not found in a cache, then a new one is created and registered into the cache. * @see #fromCache(String) * * @param typeName * String name of the packaging type * @return Corresponding PackagingType object * @throws IllegalArgumentException * Thrown if typeName is {@code null} or empty */ public static PackagingType of(String typeName) throws IllegalArgumentException { PackagingType packagingType = fromCache(typeName); if (packagingType != null){ return packagingType; } // this will cause packaging object to register into cache return new PackagingType(typeName); }
private Class<? extends Archive> getIfSupported(File file) { String extension = FilenameUtils.getExtension(file.getName()); if (!Validate.isNullOrEmpty(extension)) { PackagingType packagingType = PackagingType.fromCache(extension); if (packagingType != null && packagingType != PackagingType.POM) { return getArchiveRepresentation(packagingType); } } return null; }
public Archive getDefaultBuiltArchive() { String finalName = getModel().getBuild().getFinalName(); String buildDirectory = getModel().getBuild().getDirectory(); String packaging = getModel().getPackaging(); PackagingType packagingType = PackagingType.fromCache(packaging); if (packagingType == null) { throw new IllegalArgumentException("The packaging type " + packaging + " is not supported"); } if (packagingType != PackagingType.POM) { File zipFile = new File(buildDirectory + File.separator + finalName + "." + packaging); return ShrinkWrap.createFromZipFile(getArchiveRepresentation(packagingType), zipFile); } else { return null; } }