Skip to content
This repository has been archived by the owner on Mar 29, 2024. It is now read-only.

Commit

Permalink
update maven configuration for packagign excutable jar;output time co…
Browse files Browse the repository at this point in the history
…nsuming.
  • Loading branch information
padeoe committed Dec 25, 2017
1 parent e16cb87 commit 1f44dae
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 43 deletions.
12 changes: 7 additions & 5 deletions libpdf.iml
Expand Up @@ -12,12 +12,14 @@
<orderEntry type="library" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" name="Maven: org.jsoup:jsoup:1.8.3" level="project" />
<orderEntry type="library" name="Maven: com.itextpdf:kernel:7.0.2" level="project" />
<orderEntry type="library" name="Maven: com.itextpdf:kernel:7.1.0" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.13" level="project" />
<orderEntry type="library" name="Maven: com.itextpdf:io:7.0.2" level="project" />
<orderEntry type="library" name="Maven: com.itextpdf:layout:7.0.2" level="project" />
<orderEntry type="library" name="Maven: com.itextpdf:forms:7.0.2" level="project" />
<orderEntry type="library" name="Maven: com.itextpdf:pdfa:7.0.2" level="project" />
<orderEntry type="library" name="Maven: com.itextpdf:io:7.1.0" level="project" />
<orderEntry type="library" name="Maven: com.itextpdf:layout:7.1.0" level="project" />
<orderEntry type="library" name="Maven: com.itextpdf:forms:7.1.0" level="project" />
<orderEntry type="library" name="Maven: com.itextpdf:pdfa:7.1.0" level="project" />
<orderEntry type="library" name="Maven: com.itextpdf:sign:7.1.0" level="project" />
<orderEntry type="library" name="Maven: com.itextpdf:font-asian:7.1.0" level="project" />
<orderEntry type="library" name="Maven: com.itextpdf:pdftest:7.0.2" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.1.3" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.1.3" level="project" />
Expand Down
75 changes: 54 additions & 21 deletions pom.xml
Expand Up @@ -11,34 +11,43 @@
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.release>8</maven.compiler.release>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
</plugin>
<plugin>

<!-- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>1.1</version>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<toolchains>
<jdk>
<version>1.8</version>
<vendor>oracle</vendor>
</jdk>
</toolchains>
<archive>
<manifest>
<mainClass>com.sslibrary.spider.BookDownloader</mainClass>
</manifest>
</archive>
</configuration>
</plugin>-->

<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>toolchain</goal>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>Starter</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
Expand All @@ -53,31 +62,55 @@
<artifactId>jsoup</artifactId>
<version>1.8.3</version>
</dependency>
<!-- always needed -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>kernel</artifactId>
<version>7.0.2</version>
<version>7.1.0</version>
</dependency>

<!-- always needed -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>io</artifactId>
<version>7.0.2</version>
<version>7.1.0</version>
</dependency>

<!-- always needed -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>layout</artifactId>
<version>7.0.2</version>
<version>7.1.0</version>
</dependency>

<!-- only needed for forms -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>forms</artifactId>
<version>7.0.2</version>
<version>7.1.0</version>
</dependency>

<!-- only needed for PDF/A -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>pdfa</artifactId>
<version>7.0.2</version>
<version>7.1.0</version>
</dependency>

<!-- only needed for digital signatures -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>sign</artifactId>
<version>7.1.0</version>
</dependency>

<!-- only needed for Asian fonts -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>font-asian</artifactId>
<version>7.1.0</version>
</dependency>

<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>pdftest</artifactId>
Expand Down
33 changes: 16 additions & 17 deletions src/main/java/Starter.java
Expand Up @@ -12,33 +12,33 @@
*/
public class Starter {
public static void main(String[] args) throws Exception {
if(args!=null&&args.length>0){
String url=args[args.length-1];
int thread_index=-1;
for(int i=0;i<args.length;i++){
if(args[i].equals("-t")){
thread_index=i;
if (args != null && args.length > 0) {
String url = args[args.length - 1];
int thread_index = -1;
for (int i = 0; i < args.length; i++) {
if (args[i].equals("-t")) {
thread_index = i;
break;
}
}
int threadNumber=(thread_index==-1)?8:Integer.parseInt(args[thread_index+1]);
int threadNumber = (thread_index == -1) ? 8 : Integer.parseInt(args[thread_index + 1]);

if(url.indexOf("chineseall.cn")!=-1){
if (url.indexOf("chineseall.cn") != -1) {
String[] segments = url.split("/");
String bookId=segments[segments.length-1];
String bookId = segments[segments.length - 1];
cn.chineseall.Downloader bookDownloader = new cn.chineseall.Downloader(bookId, new cn.chineseall.CoreService("Maskeney", "147258"));
bookDownloader.setThreadNumber(threadNumber);
// bookDownloader.setTmpPathDir(Paths.get("/mnt/f/tmp"));
// bookDownloader.setPath(Paths.get("/mnt/f/TP"));
long begin = System.currentTimeMillis();
bookDownloader.downloadBook();
System.out.println((System.currentTimeMillis() - begin) / 1000);
System.out.println("下载结束,耗时" + (System.currentTimeMillis() - begin) / 1000 + "秒");

}
else {
if(url.indexOf("img.sslibrary.com")!=-1){
} else {
if (url.indexOf("img.sslibrary.com") != -1) {
BookDownloader bookDownloader = new BookDownloader(args[0]);
bookDownloader.setThreadNumber(8);
long begin = System.currentTimeMillis();
bookDownloader.downloadAllImages();

Book originBook = bookDownloader.getBook();
Expand All @@ -53,14 +53,13 @@ public static void main(String[] args) throws Exception {
PDFTool.generatePDFFromImage(files.stream().filter(file -> !file.getName().endsWith(".txt")).toArray(File[]::new), originPDF);
bookDownloader.getOutline();
PDFGenerator.addBookMark(bookDownloader.getBook(), originPDF.getPath(), outPDF.getPath());
}
else {
System.out.println("\n下载结束,耗时" + (System.currentTimeMillis() - begin) / 1000 + "秒");
} else {
System.out.println("[ERROR] 未能识别的url,请输入chineseall.cn或者img.sslibrary.com开头的书本url");
}
}

}
else {
} else {
System.out.println("用法: java -jar libpdf.jar [options] <url>");
System.out.println("\n其中选项包括:");
System.out.println(" -t 线程数量\n \t默认为8。例如 -t 8");
Expand Down

0 comments on commit 1f44dae

Please sign in to comment.