Skip to content
This repository has been archived by the owner on Oct 6, 2022. It is now read-only.

Commit

Permalink
[EAT] : Add external dependencies in the dependency list.
Browse files Browse the repository at this point in the history
  • Loading branch information
panossot committed Jul 24, 2018
1 parent 938bb66 commit a07a462
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 14 deletions.
15 changes: 8 additions & 7 deletions DependencyTreeParser/README.md
Expand Up @@ -12,10 +12,11 @@ This subdirectory is used for finding the packages that are used / loaded by the

1. Go to the server parent directory and execute : mvn dependency:tree > output.txt
2. export DependencyTreeFilePath=path to the output.txt file
3. export MavenRepoPath=path to the local maven repository
4. export BaseDir=the path to the eap-additional-testsuite dir
5. export SourcePath=the path to the dir of sources
6. export Server=the server name of the test subset that is aimed to be used
7. export Version=the version of the server that will be tested
8. export VersionOrderDir=versionOrder
9. Then go to this current DependencyTreeParser directory and execute : mvn clean install (This command will display all the packages being used/loaded in the maven repo)
3. export ExternalDependencyPath=path to the another file listing the external dependencies (line format : new.artifact:new.id:jar:new.version)
4. export MavenRepoPath=path to the local maven repository
5. export BaseDir=the path to the eap-additional-testsuite dir
6. export SourcePath=the path to the dir of sources
7. export Server=the server name of the test subset that is aimed to be used
8. export Version=the version of the server that will be tested
9. export VersionOrderDir=versionOrder
10. Then go to this current DependencyTreeParser directory and execute : mvn clean install (This command will display all the packages being used/loaded in the maven repo)
@@ -1,6 +1,5 @@
package org.jboss.dependencytreeparser;

import java.util.ArrayList;
import java.util.HashSet;

/**
Expand All @@ -11,9 +10,12 @@ public class DependencyTree {

public static void main(String[] args) throws Exception {
try {
System.out.println("Print Dependencies : ");
DependencyTreeMethods.getArtifacts();

HashSet<String> packages = DependencyTreeMethods.listPackages();

System.out.println("Available libraries : ");
System.out.println("\n\n\nAvailable libraries : ");

for(String s : packages){
System.out.println(s);
Expand Down
Expand Up @@ -92,13 +92,16 @@ public static ArrayList<Artifact> getArtifacts() throws IOException {
art.groupId = parts[1];
art.type = parts[2];
art.version = parts[3];
art.scope = parts[4];

artifacts.add(art);
if (!parts[4].contains("optional") && !parts[4].contains("test"))
artifacts.add(art);
}else if(parts.length==6) {
art.artifactId = parts[0];
art.groupId = parts[1];
art.type = parts[2];
art.version = parts[4];
art.scope = parts[5];
}


Expand All @@ -114,9 +117,12 @@ public static ArrayList<Artifact> getArtifacts() throws IOException {

}

/* for(Artifact a:artifacts){
System.out.println(a.artifactId + " " + a.groupId + " " + a.version);
}*/
String filePath2 = System.getProperty("ExternalDependencyPath");
artifacts = addExternalLibraries(artifacts, filePath2);

for(Artifact a:artifacts){
System.out.println(a.artifactId + " " + a.groupId + " " + a.version + " " + a.type + " " + a.scope);
}

} catch(Exception e) {
e.printStackTrace();
Expand All @@ -126,6 +132,46 @@ public static ArrayList<Artifact> getArtifacts() throws IOException {
}
}

public static ArrayList<Artifact> addExternalLibraries(ArrayList<Artifact> artifacts, String filePath) throws IOException {
BufferedReader br = null;
try {
FileReader fr = new FileReader(filePath);
if(fr!=null) {
br = new BufferedReader(fr);
String line = br.readLine();

while (line != null) {
Artifact art = new Artifact();
String[] parts;
parts = line.trim().split(":");

if (parts.length==4) {
art.artifactId = parts[0];
art.groupId = parts[1];
art.type = parts[2];
art.version=parts[3];


artifacts.add(art);
}

line = br.readLine();
}

// for(Artifact a:artifacts){
// System.out.println(a.artifactId + " " + a.groupId + " " + a.version + " " + a.type + " " + a.scope);
// }
}

} catch(Exception e) {
e.printStackTrace();
}finally {
if(br!=null)
br.close();
return artifacts;
}
}

public static ArrayList<String> listClasses(){
ArrayList<String> jarClasses = new ArrayList<>();

Expand All @@ -135,7 +181,7 @@ public static ArrayList<String> listClasses(){

for(Artifact ar : artifacts) {
if(ar.type.contains("jar")) {
// System.out.println(repoPath + ar.artifactId.replaceAll("//.", "//")+"/"+ar.groupId+"/"+ar.version+"/"+ar.groupId + "-" + ar.version+".jar");
System.out.println(repoPath + "/" + ar.artifactId.replaceAll("\\.", "//")+"/"+ar.groupId+"/"+ar.version+"/"+ar.groupId + "-" + ar.version+".jar");
jarClasses.addAll(DependencyTreeMethods.listJars(repoPath + "/"+ ar.artifactId.replaceAll("\\.", "//")+"/"+ar.groupId+"/"+ar.version+"/"+ar.groupId + "-" + ar.version+".jar"));
}
}
Expand Down Expand Up @@ -193,4 +239,5 @@ class Artifact {
String artifactId;
String version;
String type;
String scope;
}

0 comments on commit a07a462

Please sign in to comment.