@Test public void testMavenClasspath() throws Exception { Path testPom = Paths.get("src/test/resources/pom-classpath-test.xml"); String pomData = new String(Files.readAllBytes(testPom)); String classpath = mavenClasspathHelper.generateClasspathFromPom(pomData); assertNotNull(classpath); assertTrue(classpath.contains("jackson-annotations")); assertTrue(classpath.contains("jackson-databind")); assertTrue(classpath.contains("jackson-core")); }
public String generateClasspathFromPom(String pom) throws Exception { if (pom == null || pom.isEmpty()) { return null; } if (LOG.isDebugEnabled()) { LOG.debug("Generating classpath from pom:\n" + pom); } Path workingDirectory = createWorkingDirectory(); Path pomFile = Paths.get(workingDirectory.toString(), "pom.xml"); Files.write(pomFile, pom.getBytes()); List<String> cmd = new LinkedList<String>(); cmd.add("mvn"); cmd.add("org.apache.maven.plugins:maven-dependency-plugin:3.0.0:build-classpath"); cmd.add("-DincludeScope=runtime"); String result = executeMavenProcess(workingDirectory.toString(), cmd); if (result != null) { result = parseClasspathFromMavenOutput(result); } else { LOG.error("MavenProcess returned unexpected result: " + result); throw new InspectionException("Unable to generate classpath from pom file"); } try { deleteWorkingDirectory(workingDirectory); } catch (IOException ioe) { LOG.warn("Cleanup of working directory failed to complete: " + ioe.getMessage(), ioe); } return result; }
MavenClasspathHelper { public String generateClasspathFromPom(String pom) throws Exception { if (pom == null || pom.isEmpty()) { return null; } if (LOG.isDebugEnabled()) { LOG.debug("Generating classpath from pom:\n" + pom); } Path workingDirectory = createWorkingDirectory(); Path pomFile = Paths.get(workingDirectory.toString(), "pom.xml"); Files.write(pomFile, pom.getBytes()); List<String> cmd = new LinkedList<String>(); cmd.add("mvn"); cmd.add("org.apache.maven.plugins:maven-dependency-plugin:3.0.0:build-classpath"); cmd.add("-DincludeScope=runtime"); String result = executeMavenProcess(workingDirectory.toString(), cmd); if (result != null) { result = parseClasspathFromMavenOutput(result); } else { LOG.error("MavenProcess returned unexpected result: " + result); throw new InspectionException("Unable to generate classpath from pom file"); } try { deleteWorkingDirectory(workingDirectory); } catch (IOException ioe) { LOG.warn("Cleanup of working directory failed to complete: " + ioe.getMessage(), ioe); } return result; } }
MavenClasspathHelper { public String generateClasspathFromPom(String pom) throws Exception { if (pom == null || pom.isEmpty()) { return null; } if (LOG.isDebugEnabled()) { LOG.debug("Generating classpath from pom:\n" + pom); } Path workingDirectory = createWorkingDirectory(); Path pomFile = Paths.get(workingDirectory.toString(), "pom.xml"); Files.write(pomFile, pom.getBytes()); List<String> cmd = new LinkedList<String>(); cmd.add("mvn"); cmd.add("org.apache.maven.plugins:maven-dependency-plugin:3.0.0:build-classpath"); cmd.add("-DincludeScope=runtime"); String result = executeMavenProcess(workingDirectory.toString(), cmd); if (result != null) { result = parseClasspathFromMavenOutput(result); } else { LOG.error("MavenProcess returned unexpected result: " + result); throw new InspectionException("Unable to generate classpath from pom file"); } try { deleteWorkingDirectory(workingDirectory); } catch (IOException ioe) { LOG.warn("Cleanup of working directory failed to complete: " + ioe.getMessage(), ioe); } return result; }  }
MavenClasspathHelper { public String generateClasspathFromPom(String pom) throws Exception { if (pom == null || pom.isEmpty()) { return null; } if (LOG.isDebugEnabled()) { LOG.debug("Generating classpath from pom:\n" + pom); } Path workingDirectory = createWorkingDirectory(); Path pomFile = Paths.get(workingDirectory.toString(), "pom.xml"); Files.write(pomFile, pom.getBytes()); List<String> cmd = new LinkedList<String>(); cmd.add("mvn"); cmd.add("org.apache.maven.plugins:maven-dependency-plugin:3.0.0:build-classpath"); cmd.add("-DincludeScope=runtime"); String result = executeMavenProcess(workingDirectory.toString(), cmd); if (result != null) { result = parseClasspathFromMavenOutput(result); } else { LOG.error("MavenProcess returned unexpected result: " + result); throw new InspectionException("Unable to generate classpath from pom file"); } try { deleteWorkingDirectory(workingDirectory); } catch (IOException ioe) { LOG.warn("Cleanup of working directory failed to complete: " + ioe.getMessage(), ioe); } return result; }  String generateClasspathFromPom(String pom); Integer cleanupTempFolders(); long getProcessCheckInterval(); void setProcessCheckInterval(long processCheckInterval); long getProcessMaxExecutionTime(); void setProcessMaxExecutionTime(long processMaxExecutionTime); String getBaseFolder(); void setBaseFolder(String baseFolder); }
MavenClasspathHelper { public String generateClasspathFromPom(String pom) throws Exception { if (pom == null || pom.isEmpty()) { return null; } if (LOG.isDebugEnabled()) { LOG.debug("Generating classpath from pom:\n" + pom); } Path workingDirectory = createWorkingDirectory(); Path pomFile = Paths.get(workingDirectory.toString(), "pom.xml"); Files.write(pomFile, pom.getBytes()); List<String> cmd = new LinkedList<String>(); cmd.add("mvn"); cmd.add("org.apache.maven.plugins:maven-dependency-plugin:3.0.0:build-classpath"); cmd.add("-DincludeScope=runtime"); String result = executeMavenProcess(workingDirectory.toString(), cmd); if (result != null) { result = parseClasspathFromMavenOutput(result); } else { LOG.error("MavenProcess returned unexpected result: " + result); throw new InspectionException("Unable to generate classpath from pom file"); } try { deleteWorkingDirectory(workingDirectory); } catch (IOException ioe) { LOG.warn("Cleanup of working directory failed to complete: " + ioe.getMessage(), ioe); } return result; }  String generateClasspathFromPom(String pom); Integer cleanupTempFolders(); long getProcessCheckInterval(); void setProcessCheckInterval(long processCheckInterval); long getProcessMaxExecutionTime(); void setProcessMaxExecutionTime(long processMaxExecutionTime); String getBaseFolder(); void setBaseFolder(String baseFolder); static final String WORKING_FOLDER_PREFIX; }