GuvnorM2Repository { protected static String loadFileTextFromJar(final File jarFile, String path, String fileName) { if (jarFile != null && fileName != null && !fileName.isEmpty()) { try (ZipFile zip = new ZipFile(jarFile)) { for (Enumeration e = zip.entries(); e.hasMoreElements(); ) { ZipEntry entry = (ZipEntry) e.nextElement(); if (entry.getName().startsWith(path) && entry.getName().endsWith(fileName)) { return zipEntryToString(zip, entry); } } } catch (ZipException e) { log.error(e.getMessage()); } catch (IOException e) { log.error(e.getMessage()); } } return null; } GuvnorM2Repository(); @Inject  GuvnorM2Repository(ArtifactRepositoryService factory); @PostConstruct void init(); String getM2RepositoryDir(String repositoryName); String getM2RepositoryRootDir(String repositoryName); String getRepositoryURL(String repositoryName); void deployArtifact(final InputStream jarStream,
                               final GAV gav,
                               final boolean includeAdditionalRepositories); void deployArtifact(final InputStream jarStream,
                               final GAV gav,
                               final boolean includeAdditionalRepositories,
                               final Predicate<ArtifactRepository> filter); void deployPom(final InputStream pomStream,
                          final GAV gav); void deployParentPom(final GAV gav); Collection<File> listFiles(); List<File> listFiles(final String filters); List<File> listFiles(final String filters,
                                List<String> fileFormats); List<Artifact> listArtifacts(final String filters,
                                        List<String> fileFormats); String getPomText(final String path); String getKModuleText(final String path); String getKieDeploymentDescriptorText(final String path); GAV loadGAVFromJar(final String jarPath); static String loadPomFromJar(final InputStream jarInputStream); static String loadPomPropertiesFromJar(final InputStream jarInputStream); String generatePOM(final GAV gav); static String generatePomProperties(final GAV gav); String getPomXmlPath(final GAV gav); String getPomPropertiesPath(final GAV gav); String generateParentPOM(final GAV gav); boolean containsArtifact(final GAV gav); boolean containsArtifact(final GAV gav,
                                    final Predicate<ArtifactRepository> filter); File getArtifactFileFromRepository(final GAV gav);  }
@Test public void testLoadFileTextFromJar() { File jarFile = new File("src/test/resources/org/guvnor/m2repo/backend/server/evaluation-12.1.1.jar"); assertNotNull(GuvnorM2Repository.loadFileTextFromJar(jarFile, GuvnorM2Repository.META_INF, GuvnorM2Repository.KIE_DEPLOYMENT_DESCRIPTOR_XML)); assertNotNull(GuvnorM2Repository.loadFileTextFromJar(jarFile, GuvnorM2Repository.META_INF, GuvnorM2Repository.KMODULE_XML)); assertNull(GuvnorM2Repository.loadFileTextFromJar(jarFile, GuvnorM2Repository.META_INF, "kie-descriptor.xml")); assertNull(GuvnorM2Repository.loadFileTextFromJar(jarFile, GuvnorM2Repository.META_INF, "modu.xml")); assertNull(GuvnorM2Repository.loadFileTextFromJar(jarFile, GuvnorM2Repository.META_INF, "")); assertNull(GuvnorM2Repository.loadFileTextFromJar(jarFile, GuvnorM2Repository.META_INF, "")); assertNull(GuvnorM2Repository.loadFileTextFromJar(jarFile, GuvnorM2Repository.META_INF, null)); assertNull(GuvnorM2Repository.loadFileTextFromJar(jarFile, GuvnorM2Repository.META_INF, null)); }