Fix jenkins .jar generated files #29

Merged
louis_royer merged 5 commits from fix-jenkins into master 4 years ago

4
Jenkinsfile vendored

@ -7,10 +7,10 @@
sh 'javac -cp "./src" -d "./bin" $(find . -iname "*.java" -type f) -Xlint:deprecation -encoding UTF8'
sh 'echo "BUILDING CLIENT"'
sh 'echo Main-Class: clientP2P/ClientP2P > MANIFEST.MF'
sh 'jar -cvmf MANIFEST.MF client.jar $(find . \\( -iname "*.class" -and ! -iwholename "*/clientP2P/*.class" \\) -type f)'
sh 'jar -cvmf MANIFEST.MF client.jar $(find . \\( -iname "*.class" -and ! -iwholename "*/serverP2P/*.class" \\) -type f)'
sh 'echo "BUILDING SERVER"'
sh 'echo Main-Class: javaProjet2020/Server > MANIFEST.MF'
sh 'jar -cvmf MANIFEST.MF server.jar $(find . \\( -iname "*.class" -and ! -iwholename "*/serverP2P/*.class" \\) -type f)'
sh 'jar -cvmf MANIFEST.MF server.jar $(find . \\( -iname "*.class" -and ! -iwholename "*/clientP2P/*.class" \\) -type f)'
sh 'tar -zcvf sources.tar.gz src/'
}
}

@ -72,13 +72,14 @@ public class ClientManagementUDP implements Runnable {
*/
public void run() {
try {
System.out.println("Enter all servers: type \"stop\" when finished");
Scanner scanner = new Scanner(System.in);
String[] list = listDirectory();
System.out.println("Files present on the server:");
for(String listItem: list) {
System.out.println(listItem);
}
System.out.println("Name of the file to download:");
Scanner scanner = new Scanner(System.in);
String f = scanner.nextLine();
download(f);
System.out.println("File sucessfully downloaded");

@ -1,16 +1,25 @@
package clientP2P;
import clientP2P.ClientManagementUDP;
import clientP2P.ClientManagementTCP;
import tools.HostList;
import tools.Directories;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.ListIterator;
public class ClientP2P {
private String host;
private int port;
private Directories directories;
private List<String> hostList;
private HostList tool = new HostList();
public ClientP2P() {
directories = new Directories("P2P_JAVA_PROJECT_CLIENT");
host = "localhost";
hostList = tool.getServList();
port = 40001;
System.out.println("Client will try to contact server at " + host + " on port " + port + ". It will save files in " + directories.getDataHomeDirectory());
directories.askOpenDataHomeDirectory(null);
@ -27,8 +36,22 @@ public class ClientP2P {
case "udp":
case "2" :
System.out.println("Starting with UDP");
ClientManagementUDP cmudp = new ClientManagementUDP(c.directories.getDataHomeDirectory(), c.host, c.port);
t = new Thread(cmudp);
/* ListIterator<String> it = c.hostList.listIterator();
do {
String str = it.next();
ClientManagementUDP cmudp = new ClientManagementUDP(c.directories.getDataHomeDirectory(), str, c.port);
t = new Thread(cmudp);
} while (it.hasNext());
*/
for (String str : c.hostList){
ClientManagementUDP cmudp = new ClientManagementUDP(c.directories.getDataHomeDirectory(), str, c.port);
t = new Thread(cmudp);
/**
t.setName("client P2P-JAVA-PROJECT");
t.start();
*/
}
//ClientManagementUDP cmudp = new ClientManagementUDP(c.directories.getDataHomeDirectory(), c.host, c.port);
break;
case "TCP":
case "tcp":
@ -39,7 +62,6 @@ public class ClientP2P {
t = new Thread(cmtcp);
break;
}
t.setName("client P2P-JAVA-PROJECT");
t.start();
}

@ -0,0 +1,37 @@
package tools;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.ListIterator;
public class HostList{
/** Helper to get the server list from the user
* @author Louis Royer
* @author Flavien Haas
* @author JS Auge
* @version 1.0
*/
/**
* Let the user enter all server and puts it in a list
* @return list of servers
*/
public List<String> getServList(){
List<String> serverList = new ArrayList<String>();
Scanner scanner = new Scanner(System.in);
String servName = "";
do {
System.out.println("Name of the next server: (or \"stop\" when finished)");
servName = scanner.nextLine();
if (servName != "stop"){
serverList.add(servName);
}
} while (servName != "stop");
return serverList;
}
}
Loading…
Cancel
Save