Commit 10bb9cf8 authored by mkoscher's avatar mkoscher
Browse files

Merge branch 'buildProcess' into 'master'

build Process

See merge request mkoscher/cc-assignmen-1!6
parents 3e2bf5fb 6a13631e
......@@ -6,7 +6,7 @@
<groupId>org.example</groupId>
<artifactId>cc-assignment-1</artifactId>
<version>1.0-SNAPSHOT</version>
<version>0.1.0</version>
<packaging>jar</packaging>
<properties>
......@@ -44,24 +44,21 @@
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
<goal>shade</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>
Main
</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>assignment.Main</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
......
package assignment;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
......@@ -20,6 +22,7 @@ public class Crawler {
public Report analyze(Document webpage, int depth) {
Document subWebpage;
List<Report> subReports = new ArrayList<>();
Report subReport;
Report report = new Report();
report.setUrl(webpage.baseUri());
......@@ -40,13 +43,14 @@ public class Crawler {
}
report.setSubReports(subReports);
//Print Report to Console
printReports(report);
return report;
}
private void printReports(Report report){
printReportLineForDepth("Report for depht: 0" , 0);
public void printReports(Report report){
System.out.println("");
System.out.println("Report for depht: 0" );
System.out.println("-------------------------------------------- ");
System.out.println("-------------------------------------------- ");
printReports(report, 0);
}
......@@ -141,7 +145,6 @@ public class Crawler {
if (file.exists() && file.isFile()){
return true;
}
return false;
}
return false;
}
......@@ -166,7 +169,6 @@ public class Crawler {
}
return true;
} catch (IOException ioe) {
LOGGER.log(Level.INFO, ioe.getMessage());
return true;
}
}
......
package assignment;
import org.apache.commons.cli.*;
import org.jsoup.nodes.Document;
......@@ -6,13 +8,15 @@ public class Main {
Options options = new Options();
CommandLine cmd = null;
Option urlArg = Option.builder().longOpt("url").argName("u").hasArg().desc("URL to parse").build();
Option depthArg = Option.builder().longOpt("depth").argName("d").hasArg().desc("Depth to parse").build();
Integer depth = 1;
Option depthArg = Option.builder().longOpt("depth").argName("d").hasArg().desc("Depth to parse, default is 0").build();
Integer depth = 0;
Crawler crawler = new Crawler();
Report report;
Document webpage;
options.addOption(urlArg);
options.addOption(depthArg);
CommandLineParser parser = new DefaultParser();
try {
cmd = parser.parse(options, args);
......@@ -27,7 +31,10 @@ public class Main {
if(cmd.hasOption("url")){
webpage = crawler.getDocumentFromURL(cmd.getOptionValue("url"));
crawler.analyze(webpage, depth);
report = crawler.analyze(webpage, depth);
//Print Report to Console
crawler.printReports(report);
}
}
}
package assignment;
import java.util.List;
public class Report {
......
import assignment.Crawler;
import assignment.Report;
import org.jsoup.nodes.Document;
import org.junit.Assert;
import org.junit.jupiter.api.*;
......
......@@ -18,7 +18,7 @@
<ul>
<li><a href="src/test/resources/testPage.html">Test Link 1</a> </li>
<li><a href="src/test/resources/testPage.html">Test Link 2</a> </li>
<li><a href="https://broken.link">Broken Link</a> </li>
<li><a href="https://öööö.at">Broken Link</a> </li>
</ul>
<video src="testVideo.mp4"></video>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment