Skip to content

Commit 69bc68d

Browse files
Some gradle publish settings
1 parent 4b555eb commit 69bc68d

File tree

3 files changed

+55
-23
lines changed

3 files changed

+55
-23
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
*.iml
99

1010
swagger*.json
11-
result.json
11+
result.json
12+
/local.properties

build.gradle

+33-2
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,50 @@
1+
plugins {
2+
id "com.jfrog.bintray" version "1.7.3"
3+
}
4+
15
group 'io.squark'
2-
version '1.0-SNAPSHOT'
6+
version '0.1'
37

48
apply plugin: 'java'
9+
apply plugin: 'application'
10+
apply plugin: 'maven'
11+
apply plugin: 'com.jfrog.bintray'
512

613
sourceCompatibility = 1.8
714

15+
mainClassName = 'io.squark.swaggercombine.SwaggerCombine'
16+
817
task (fatJar, type: Jar) {
918
manifest {
10-
attributes 'Main-Class': 'io.squark.swaggercombine.SwaggerCombine'
19+
attributes 'Main-Class': mainClassName
1120
}
1221
baseName = project.name + '-all'
1322
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
1423
with jar
1524
}
1625

26+
bintray {
27+
Properties properties = new Properties()
28+
properties.load( new FileInputStream("local.properties"))
29+
30+
user = properties.getProperty("bintray.user")
31+
key = properties.getProperty("bintray.apikey")
32+
33+
configurations = ['archives']
34+
pkg {
35+
repo = 'squark.io'
36+
name = 'io.squark'
37+
userOrg = 'squark-io'
38+
licenses = ['Apache-2.0']
39+
vcsUrl = 'https://github.com/squark-io/swagger-combine.git'
40+
version {
41+
name = rootProject.version
42+
}
43+
}
44+
}
45+
46+
//build.dependsOn(fatJar)
47+
1748
repositories {
1849
mavenCentral()
1950
}

src/main/java/io/squark/swaggercombine/SwaggerCombine.java

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
package io.squark.swaggercombine;
22

3+
import java.io.File;
4+
import java.io.FileInputStream;
5+
import java.util.ArrayList;
6+
import java.util.List;
7+
import java.util.Map;
8+
import java.util.Properties;
9+
10+
import org.apache.commons.io.IOUtils;
11+
312
import com.fasterxml.jackson.annotation.JsonInclude;
413
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
514
import com.fasterxml.jackson.databind.DeserializationFeature;
615
import com.fasterxml.jackson.databind.Module;
716
import com.fasterxml.jackson.databind.ObjectMapper;
817
import com.fasterxml.jackson.databind.SerializationFeature;
9-
import com.sun.org.apache.xpath.internal.operations.Bool;
10-
import io.swagger.models.ExternalDocs;
18+
1119
import io.swagger.models.Model;
12-
import io.swagger.models.Operation;
1320
import io.swagger.models.Path;
1421
import io.swagger.models.Response;
1522
import io.swagger.models.Scheme;
@@ -19,19 +26,8 @@
1926
import io.swagger.models.auth.SecuritySchemeDefinition;
2027
import io.swagger.models.parameters.Parameter;
2128
import io.swagger.parser.SwaggerParser;
22-
import io.swagger.parser.util.SwaggerDeserializer;
2329
import io.swagger.util.DeserializationModule;
2430
import io.swagger.util.Json;
25-
import io.swagger.util.ObjectMapperFactory;
26-
import org.apache.commons.io.IOUtils;
27-
28-
import java.io.File;
29-
import java.io.FileInputStream;
30-
import java.util.ArrayList;
31-
import java.util.Arrays;
32-
import java.util.List;
33-
import java.util.Map;
34-
import java.util.Properties;
3531

3632
/**
3733
* Created by erik on 2017-01-05.
@@ -64,7 +60,7 @@ public SwaggerCombine(List<String> files, Properties properties) throws Exceptio
6460
public Swagger combine() {
6561

6662
boolean stripBasePath = (properties != null &&
67-
Boolean.parseBoolean(properties.getProperty("--stripBasePath", "false")));
63+
Boolean.parseBoolean(properties.getProperty("--stripBasePath", "false")));
6864
for (Swagger swagger : swaggers) {
6965
if (swagger.getTags() != null) {
7066
for (Tag tag : swagger.getTags()) {
@@ -96,8 +92,9 @@ public Swagger combine() {
9692
if (stripBasePath) {
9793
String replacedPath = path.getKey();
9894
if (path.getKey().startsWith(firstSwagger.getBasePath()) || path.getKey().startsWith("/" + firstSwagger.getBasePath())) {
99-
replacedPath = path.getKey().replace(firstSwagger.getBasePath(), "")
100-
.replaceAll("//", "/");
95+
replacedPath = path.getKey()
96+
.replace(firstSwagger.getBasePath(), "")
97+
.replaceAll("//", "/");
10198
}
10299
firstSwagger.path(replacedPath, path.getValue());
103100
} else {
@@ -154,7 +151,6 @@ public static void main(String[] args) throws Exception {
154151
SwaggerCombine swaggerCombine = new SwaggerCombine(arguments, properties);
155152
Swagger combined = swaggerCombine.combine();
156153

157-
158154
ObjectMapper mapper = Json.mapper();
159155

160156
Module deserializerModule = new DeserializationModule(true, true);
@@ -163,11 +159,15 @@ public static void main(String[] args) throws Exception {
163159
mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
164160
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
165161
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
166-
File output = new File("result.json");
162+
163+
String outputFile = properties.getProperty("--outputFile");
164+
if (outputFile == null) {
165+
outputFile = "result.json";
166+
}
167+
File output = new File(outputFile);
167168
mapper.writer(new DefaultPrettyPrinter()).writeValue(output, combined);
168169

169170
System.out.println("Done.");
170171
}
171172

172-
173173
}

0 commit comments

Comments
 (0)