Skip to content

Commit 86ec19b

Browse files
committed
Maven
1 parent c7d0a6c commit 86ec19b

24 files changed

+238
-46
lines changed

convertapi-java.iml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<module type="JAVA_MODULE" version="4">
3-
<component name="NewModuleRootManager" inherit-compiler-output="true">
4-
<exclude-output />
2+
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
4+
<output url="file://$MODULE_DIR$/target/classes" />
5+
<output-test url="file://$MODULE_DIR$/target/test-classes" />
56
<content url="file://$MODULE_DIR$">
6-
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7+
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
8+
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
9+
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
710
<excludeFolder url="file://$MODULE_DIR$/.idea" />
811
<excludeFolder url="file://$MODULE_DIR$/lib" />
9-
<excludeFolder url="file://$MODULE_DIR$/src/com/convertapi/examples" />
12+
<excludeFolder url="file://$MODULE_DIR$/src/main/java/com/convertapi/examples" />
13+
<excludeFolder url="file://$MODULE_DIR$/target" />
1014
</content>
1115
<orderEntry type="inheritedJdk" />
1216
<orderEntry type="sourceFolder" forTests="false" />
1317
<orderEntry type="library" exported="" name="lib" level="project" />
18+
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.5" level="project" />
19+
<orderEntry type="library" name="Maven: com.squareup.okhttp3:okhttp:3.10.0" level="project" />
20+
<orderEntry type="library" name="Maven: com.squareup.okio:okio:1.14.0" level="project" />
1421
</component>
1522
</module>

pom.xml

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.convertapi.client</groupId>
5+
<artifactId>convertapi</artifactId>
6+
<packaging>jar</packaging>
7+
8+
<version>1.6-SNAPSHOT</version>
9+
<name>ConvertAPI Java Client</name>
10+
<description>
11+
The ConvertAPI helps converting various file formats.
12+
Creating PDF and Images from various sources like Word, Excel, Powerpoint, images, web pages or raw HTML codes.
13+
Merge, Encrypt, Split, Repair and Decrypt PDF files.
14+
And many others files manipulations.
15+
In just few minutes you can integrate it into your application and use it easily.
16+
The ConvertAPI client library makes it easier to use the Convert API from your Java 8 projects without having to
17+
build your own API calls.
18+
</description>
19+
<url>https://www.convertapi.com/</url>
20+
21+
<licenses>
22+
<license>
23+
<name>The MIT License</name>
24+
<url>https://raw.githubusercontent.com/ConvertAPI/convertapi-java/master/LICENSE.txt</url>
25+
<distribution>repo</distribution>
26+
</license>
27+
</licenses>
28+
29+
<scm>
30+
<connection>scm:git:git://github.com/ConvertAPI/convertapi-java.git</connection>
31+
<developerConnection>scm:git:git://github.com/ConvertAPI/convertapi-java.git</developerConnection>
32+
<url>https://github.com/ConvertAPI/convertapi-java</url>
33+
<tag>HEAD</tag>
34+
</scm>
35+
36+
<distributionManagement>
37+
<snapshotRepository>
38+
<id>ossrh</id>
39+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
40+
</snapshotRepository>
41+
<repository>
42+
<id>ossrh</id>
43+
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
44+
</repository>
45+
</distributionManagement>
46+
47+
<properties>
48+
<maven.compiler.source>1.8</maven.compiler.source>
49+
<maven.compiler.target>1.8</maven.compiler.target>
50+
</properties>
51+
52+
<dependencies>
53+
<dependency>
54+
<groupId>com.google.code.gson</groupId>
55+
<artifactId>gson</artifactId>
56+
<version>2.8.5</version>
57+
</dependency>
58+
<dependency>
59+
<groupId>com.squareup.okhttp3</groupId>
60+
<artifactId>okhttp</artifactId>
61+
<version>3.10.0</version>
62+
</dependency>
63+
</dependencies>
64+
65+
<build>
66+
<resources>
67+
<resource>
68+
<directory>src/main/resources</directory>
69+
<excludes>
70+
<exclude>**/examples/*</exclude>
71+
</excludes>
72+
<filtering>false</filtering>
73+
</resource>
74+
</resources>
75+
76+
<plugins>
77+
<plugin>
78+
<artifactId>maven-deploy-plugin</artifactId>
79+
<version>2.8.2</version>
80+
<executions>
81+
<execution>
82+
<id>default-deploy</id>
83+
<phase>deploy</phase>
84+
<goals>
85+
<goal>deploy</goal>
86+
</goals>
87+
</execution>
88+
</executions>
89+
</plugin>
90+
91+
<plugin>
92+
<groupId>org.apache.maven.plugins</groupId>
93+
<artifactId>maven-release-plugin</artifactId>
94+
<version>2.5.3</version>
95+
<configuration>
96+
<localCheckout>true</localCheckout>
97+
<pushChanges>false</pushChanges>
98+
<mavenExecutorId>forked-path</mavenExecutorId>
99+
<arguments>-Dgpg.passphrase=${gpg.passphrase}</arguments>
100+
</configuration>
101+
<dependencies>
102+
<dependency>
103+
<groupId>org.apache.maven.scm</groupId>
104+
<artifactId>maven-scm-provider-gitexe</artifactId>
105+
<version>1.9.5</version>
106+
</dependency>
107+
</dependencies>
108+
</plugin>
109+
110+
<plugin>
111+
<groupId>org.sonatype.plugins</groupId>
112+
<artifactId>nexus-staging-maven-plugin</artifactId>
113+
<version>1.6.7</version>
114+
<extensions>true</extensions>
115+
<configuration>
116+
<serverId>ossrh</serverId>
117+
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
118+
<autoReleaseAfterClose>true</autoReleaseAfterClose>
119+
</configuration>
120+
</plugin>
121+
122+
<plugin>
123+
<groupId>org.apache.maven.plugins</groupId>
124+
<artifactId>maven-source-plugin</artifactId>
125+
<version>3.0.1</version>
126+
<executions>
127+
<execution>
128+
<id>attach-sources</id>
129+
<goals>
130+
<goal>jar</goal>
131+
</goals>
132+
</execution>
133+
</executions>
134+
</plugin>
135+
136+
</plugins>
137+
138+
</build>
139+
140+
141+
<profiles>
142+
<!-- GPG Signature on release -->
143+
<profile>
144+
<id>release-sign-artifacts</id>
145+
<activation>
146+
<property>
147+
<name>performRelease</name>
148+
<value>true</value>
149+
</property>
150+
</activation>
151+
<build>
152+
<plugins>
153+
<plugin>
154+
<groupId>org.apache.maven.plugins</groupId>
155+
<artifactId>maven-gpg-plugin</artifactId>
156+
<version>1.6</version>
157+
<executions>
158+
<execution>
159+
<id>sign-artifacts</id>
160+
<phase>verify</phase>
161+
<goals>
162+
<goal>sign</goal>
163+
</goals>
164+
</execution>
165+
</executions>
166+
</plugin>
167+
</plugins>
168+
</build>
169+
</profile>
170+
</profiles>
171+
172+
</project>

src/com/convertapi/Config.java renamed to src/main/java/com/convertapi/client/Config.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
package com.convertapi;
1+
package com.convertapi.client;
22

33
import okhttp3.OkHttpClient;
44

55
import java.util.function.Function;
66

77
public class Config {
8-
private static String defaultSecret;
9-
private static Function<OkHttpClient.Builder, OkHttpClient.Builder> defaultHttpClientBuilder = b -> b;
108
private static final String SCHEME = "https";
119
@SuppressWarnings("SpellCheckingInspection")
1210
private static final String HOST = "v2.convertapi.com";
1311
private static final int TIMEOUT = 180;
12+
private static String defaultSecret;
13+
private static Function<OkHttpClient.Builder, OkHttpClient.Builder> defaultHttpClientBuilder = b -> b;
1414
private final String scheme;
1515
private final String host;
1616
private final String secret;

src/com/convertapi/ConversionException.java renamed to src/main/java/com/convertapi/client/ConversionException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
package com.convertapi;
1+
package com.convertapi.client;
22

33
class ConversionException extends RuntimeException {
44
private final int httpStatusCode;
55

6-
public ConversionException(String message, int httpStatusCode){
6+
public ConversionException(String message, int httpStatusCode) {
77
super(message);
88
this.httpStatusCode = httpStatusCode;
99
}

src/com/convertapi/ConversionResult.java renamed to src/main/java/com/convertapi/client/ConversionResult.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package com.convertapi;
1+
package com.convertapi.client;
22

3-
import com.convertapi.model.ConversionResponse;
4-
import com.convertapi.model.ConversionResponseFile;
3+
import com.convertapi.client.model.ConversionResponse;
4+
import com.convertapi.client.model.ConversionResponseFile;
55

66
import java.nio.file.Files;
77
import java.nio.file.Path;
@@ -27,7 +27,7 @@ public Integer fileCount() {
2727

2828
public List<String> urls() {
2929
@SuppressWarnings("unchecked") List<String> valueList = new ArrayList();
30-
for (ConversionResponseFile file: response.Files) valueList.add(file.Url);
30+
for (ConversionResponseFile file : response.Files) valueList.add(file.Url);
3131
return valueList;
3232
}
3333

@@ -41,13 +41,14 @@ public ConversionResultFile getFile(int index) {
4141
return new ConversionResultFile(response.Files[index]);
4242
}
4343

44-
public CompletableFuture<Path> saveFile(Path file) {
44+
public CompletableFuture<Path> saveFile(Path file) {
4545
return getFile(0).saveFile(file);
4646
}
4747

4848
@SuppressWarnings("WeakerAccess")
4949
public List<CompletableFuture<Path>> saveFiles(Path directory) {
50-
if (!Files.isDirectory(directory)) throw new RuntimeException("Directory expected, but received: " + directory.toString());
50+
if (!Files.isDirectory(directory))
51+
throw new RuntimeException("Directory expected, but received: " + directory.toString());
5152
List<CompletableFuture<Path>> paths = new ArrayList<>();
5253
for (int i = 0; i < response.Files.length; i++) {
5354
paths.add(getFile(i).saveFile(directory));

src/com/convertapi/ConversionResultFile.java renamed to src/main/java/com/convertapi/client/ConversionResultFile.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
package com.convertapi;
1+
package com.convertapi.client;
22

3-
import com.convertapi.model.ConversionResponseFile;
3+
import com.convertapi.client.model.ConversionResponseFile;
44

55
import java.io.IOException;
66
import java.io.InputStream;

src/com/convertapi/ConvertApi.java renamed to src/main/java/com/convertapi/client/ConvertApi.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package com.convertapi;
1+
package com.convertapi.client;
22

3-
import com.convertapi.model.ConversionResponse;
4-
import com.convertapi.model.User;
3+
import com.convertapi.client.model.ConversionResponse;
4+
import com.convertapi.client.model.User;
55
import com.google.gson.Gson;
66
import okhttp3.HttpUrl;
77
import okhttp3.MultipartBody;
@@ -21,7 +21,7 @@
2121
@SuppressWarnings("WeakerAccess")
2222
public class ConvertApi {
2323
@SuppressWarnings("SpellCheckingInspection")
24-
private static final List<String> IGNORE_PARAMS = Arrays.asList( "storefile", "async", "jobid", "timeout");
24+
private static final List<String> IGNORE_PARAMS = Arrays.asList("storefile", "async", "jobid", "timeout");
2525

2626
@SuppressWarnings("unused")
2727
public static CompletableFuture<ConversionResult> convert(String fromFormat, String toFormat, Param... params) {

src/com/convertapi/Http.java renamed to src/main/java/com/convertapi/client/Http.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.convertapi;
1+
package com.convertapi.client;
22

33
import okhttp3.HttpUrl;
44
import okhttp3.OkHttpClient;
@@ -59,7 +59,8 @@ static CompletableFuture<Void> requestDelete(String url) {
5959
}
6060

6161
static Request.Builder getRequestBuilder() {
62-
String agent = String.format("ConvertAPI-Java/%.1f (%s)", 1.5, System.getProperty("os.name"));
62+
System.console().printf("VERSIJA: %s", Http.class.getPackage().getImplementationVersion());
63+
String agent = String.format("ConvertAPI-Java/%.1f (%s)", Http.class.getPackage().getImplementationVersion(), System.getProperty("os.name"));
6364
return new Request.Builder().header("User-Agent", agent);
6465
}
6566
}

src/com/convertapi/Param.java renamed to src/main/java/com/convertapi/client/Param.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.convertapi;
1+
package com.convertapi.client;
22

33
import okhttp3.MediaType;
44
import okhttp3.Request;
@@ -93,20 +93,6 @@ public Param(String name, CompletableFuture<ConversionResult> value) {
9393
this.value = value.thenApply(ConversionResult::urls);
9494
}
9595

96-
public String getName() {
97-
return name;
98-
}
99-
100-
public List<String> getValue() throws ExecutionException, InterruptedException {
101-
return this.value.get();
102-
}
103-
104-
public CompletableFuture<Void> delete() {
105-
return isUploadedFile
106-
? value.thenCompose(urls -> Http.requestDelete(urls.get(0)))
107-
: CompletableFuture.completedFuture(null);
108-
}
109-
11096
private static CompletableFuture<List<String>> upload(byte[] data, String fileName, Config config) {
11197
return CompletableFuture.supplyAsync(() -> {
11298
Request request = Http.getRequestBuilder()
@@ -125,4 +111,18 @@ private static CompletableFuture<List<String>> upload(byte[] data, String fileNa
125111
}
126112
});
127113
}
114+
115+
public String getName() {
116+
return name;
117+
}
118+
119+
public List<String> getValue() throws ExecutionException, InterruptedException {
120+
return this.value.get();
121+
}
122+
123+
public CompletableFuture<Void> delete() {
124+
return isUploadedFile
125+
? value.thenCompose(urls -> Http.requestDelete(urls.get(0)))
126+
: CompletableFuture.completedFuture(null);
127+
}
128128
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$">
6+
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
7+
</content>
8+
<orderEntry type="inheritedJdk" />
9+
<orderEntry type="sourceFolder" forTests="false" />
10+
</component>
11+
</module>

0 commit comments

Comments
 (0)