Skip to content

Commit f625ab5

Browse files
committed
Merge branch 'release/0.0.2'
2 parents 5da67e7 + 9679cc3 commit f625ab5

File tree

14 files changed

+329
-77
lines changed

14 files changed

+329
-77
lines changed
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/*
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
*/
19+
20+
import java.net.*;
21+
import java.io.*;
22+
import java.nio.channels.*;
23+
import java.util.Properties;
24+
25+
public class MavenWrapperDownloader {
26+
27+
/**
28+
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
29+
*/
30+
private static final String DEFAULT_DOWNLOAD_URL =
31+
"https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar";
32+
33+
/**
34+
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
35+
* use instead of the default one.
36+
*/
37+
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
38+
".mvn/wrapper/maven-wrapper.properties";
39+
40+
/**
41+
* Path where the maven-wrapper.jar will be saved to.
42+
*/
43+
private static final String MAVEN_WRAPPER_JAR_PATH =
44+
".mvn/wrapper/maven-wrapper.jar";
45+
46+
/**
47+
* Name of the property which should be used to override the default download url for the wrapper.
48+
*/
49+
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
50+
51+
public static void main(String args[]) {
52+
System.out.println("- Downloader started");
53+
File baseDirectory = new File(args[0]);
54+
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
55+
56+
// If the maven-wrapper.properties exists, read it and check if it contains a custom
57+
// wrapperUrl parameter.
58+
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
59+
String url = DEFAULT_DOWNLOAD_URL;
60+
if(mavenWrapperPropertyFile.exists()) {
61+
FileInputStream mavenWrapperPropertyFileInputStream = null;
62+
try {
63+
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
64+
Properties mavenWrapperProperties = new Properties();
65+
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
66+
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
67+
} catch (IOException e) {
68+
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
69+
} finally {
70+
try {
71+
if(mavenWrapperPropertyFileInputStream != null) {
72+
mavenWrapperPropertyFileInputStream.close();
73+
}
74+
} catch (IOException e) {
75+
// Ignore ...
76+
}
77+
}
78+
}
79+
System.out.println("- Downloading from: : " + url);
80+
81+
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
82+
if(!outputFile.getParentFile().exists()) {
83+
if(!outputFile.getParentFile().mkdirs()) {
84+
System.out.println(
85+
"- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'");
86+
}
87+
}
88+
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
89+
try {
90+
downloadFileFromURL(url, outputFile);
91+
System.out.println("Done");
92+
System.exit(0);
93+
} catch (Throwable e) {
94+
System.out.println("- Error downloading");
95+
e.printStackTrace();
96+
System.exit(1);
97+
}
98+
}
99+
100+
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
101+
URL website = new URL(urlString);
102+
ReadableByteChannel rbc;
103+
rbc = Channels.newChannel(website.openStream());
104+
FileOutputStream fos = new FileOutputStream(destination);
105+
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
106+
fos.close();
107+
rbc.close();
108+
}
109+
110+
}

.mvn/wrapper/maven-wrapper.jar

100644100755
727 Bytes
Binary file not shown.

.mvn/wrapper/maven-wrapper.properties

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
1+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
[![codebeat](https://codebeat.co/badges/36a7965b-aa57-40af-8db3-fd7e6b54fee3)](https://codebeat.co/projects/github-com-taymyr-openapi-java-develop)
2-
[![Build Status](https://travis-ci.org/taymyr/openapi-java.svg?branch=develop)](https://travis-ci.org/taymyr/openapi-java)
3-
[![Javadoc API](https://www.javadoc.io/badge/org.taymyr/openapi-java-api.svg?label=javadoc%20api)](https://www.javadoc.io/doc/org.taymyr/openapi-java-api)
4-
[![Javadoc Impl](https://www.javadoc.io/badge/org.taymyr/openapi-java-impl.svg?label=javadoc%20impl)](https://www.javadoc.io/doc/org.taymyr/openapi-java-impl)
5-
[![codecov](https://codecov.io/gh/taymyr/openapi-java/branch/develop/graph/badge.svg)](https://codecov.io/gh/taymyr/openapi-java)
6-
[![Maven API](https://img.shields.io/maven-central/v/org.taymyr/openapi-java.svg)](https://search.maven.org/search?q=a:openapi-java%20AND%20g:org.taymyr)
1+
[![Gitter](https://img.shields.io/badge/chat-gitter-purple.svg)](https://gitter.im/taymyr/taymyr)
2+
[![Gitter_RU](https://img.shields.io/badge/chat-russian%20channel-purple.svg)](https://gitter.im/taymyr/taymyr_ru)
3+
[![codebeat](https://codebeat.co/badges/e9c10a77-0084-4cc7-9328-2d224e95c558)](https://codebeat.co/projects/github-com-taymyr-lagom-openapi-java-develop)
4+
[![Build Status](https://travis-ci.org/taymyr/lagom-openapi-java.svg?branch=develop)](https://travis-ci.org/taymyr/lagom-openapi-java)
5+
[![Javadoc API](https://www.javadoc.io/badge/org.taymyr.lagom/lagom-openapi-java-api.svg?label=javadoc%20api)](https://www.javadoc.io/doc/org.taymyr.lagom/lagom-openapi-java-api)
6+
[![Javadoc Impl](https://www.javadoc.io/badge/org.taymyr.lagom/lagom-openapi-java-impl.svg?label=javadoc%20impl)](https://www.javadoc.io/doc/org.taymyr.lagom/lagom-openapi-java-impl)
7+
[![codecov](https://codecov.io/gh/taymyr/lagom-openapi-java/branch/develop/graph/badge.svg)](https://codecov.io/gh/taymyr/lagom-openapi-java)
8+
[![Maven](https://img.shields.io/maven-central/v/org.taymyr.lagom/lagom-openapi-java.svg)](https://search.maven.org/search?q=a:lagom-openapi-java%20AND%20g:org.taymyr.lagom)
79

810
# OpenAPI service for Lagom
911

api/pom.xml

Lines changed: 79 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,83 @@
33
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
44
<modelVersion>4.0.0</modelVersion>
55
<parent>
6-
<groupId>org.taymyr</groupId>
7-
<artifactId>openapi-java</artifactId>
8-
<version>0.0.1</version>
6+
<groupId>org.taymyr.lagom</groupId>
7+
<artifactId>lagom-openapi-java</artifactId>
8+
<version>0.0.2</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
11-
<artifactId>openapi-java-api</artifactId>
11+
<artifactId>lagom-openapi-java-api</artifactId>
1212
<packaging>jar</packaging>
1313
<name>Taymyr: Openapi Java API</name>
1414
<dependencies>
15+
<dependency>
16+
<groupId>org.jetbrains.kotlin</groupId>
17+
<artifactId>kotlin-stdlib-jdk8</artifactId>
18+
</dependency>
19+
<dependency>
20+
<groupId>org.jetbrains.kotlin</groupId>
21+
<artifactId>kotlin-reflect</artifactId>
22+
</dependency>
23+
<!-- Provided dependencies -->
1524
<dependency>
1625
<groupId>com.lightbend.lagom</groupId>
1726
<artifactId>lagom-javadsl-api_${scala.binary.version}</artifactId>
1827
<scope>provided</scope>
1928
</dependency>
2029
</dependencies>
2130
<build>
31+
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
2232
<plugins>
33+
<plugin>
34+
<groupId>org.jetbrains.kotlin</groupId>
35+
<artifactId>kotlin-maven-plugin</artifactId>
36+
<configuration>
37+
<args>
38+
<arg>-Xjsr305=strict</arg>
39+
<arg>-Xjvm-default=enable</arg>
40+
</args>
41+
</configuration>
42+
<executions>
43+
<execution>
44+
<id>compile</id>
45+
<goals> <goal>compile</goal> </goals>
46+
</execution>
47+
<execution>
48+
<id>test-compile</id>
49+
<goals> <goal>test-compile</goal> </goals>
50+
</execution>
51+
</executions>
52+
</plugin>
2353
<plugin>
2454
<groupId>org.apache.maven.plugins</groupId>
25-
<artifactId>maven-javadoc-plugin</artifactId>
55+
<artifactId>maven-antrun-plugin</artifactId>
2656
<executions>
2757
<execution>
28-
<phase>prepare-package</phase>
58+
<id>ktlint</id>
59+
<phase>verify</phase>
60+
<configuration>
61+
<target name="ktlint">
62+
<java taskname="ktlint" dir="${basedir}" fork="true" failonerror="true"
63+
classpathref="maven.plugin.classpath" classname="com.github.shyiko.ktlint.Main">
64+
<arg value="src/**/*.kt"/>
65+
<!-- see https://github.com/shyiko/ktlint#usage for more -->
66+
<arg value="--reporter=plain"/>
67+
<arg value="--reporter=checkstyle,output=${project.build.directory}/ktlint.xml"/>
68+
</java>
69+
</target>
70+
</configuration>
2971
<goals>
30-
<goal>jar</goal>
72+
<goal>run</goal>
3173
</goals>
3274
</execution>
3375
</executions>
76+
<dependencies>
77+
<dependency>
78+
<groupId>com.github.shyiko</groupId>
79+
<artifactId>ktlint</artifactId>
80+
<version>${ktlint.version}</version>
81+
</dependency>
82+
</dependencies>
3483
</plugin>
3584
<plugin>
3685
<groupId>org.apache.maven.plugins</groupId>
@@ -44,6 +93,29 @@
4493
</execution>
4594
</executions>
4695
</plugin>
96+
<plugin>
97+
<groupId>org.jetbrains.dokka</groupId>
98+
<artifactId>dokka-maven-plugin</artifactId>
99+
<configuration>
100+
<cacheRoot>default</cacheRoot>
101+
<noStdlibLink>false</noStdlibLink>
102+
<jdkVersion>8</jdkVersion>
103+
<sourceRoots>
104+
<root>
105+
<path>${basedir}/src/main/kotlin</path>
106+
<platforms>JVM</platforms>
107+
</root>
108+
</sourceRoots>
109+
</configuration>
110+
<executions>
111+
<execution>
112+
<phase>prepare-package</phase>
113+
<goals>
114+
<goal>javadocJar</goal>
115+
</goals>
116+
</execution>
117+
</executions>
118+
</plugin>
47119
</plugins>
48120
</build>
49121
</project>

api/src/main/java/org/taymyr/openapi/OpenAPIService.java

Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.taymyr.lagom.openapi
2+
3+
import akka.NotUsed
4+
import com.lightbend.lagom.javadsl.api.Descriptor
5+
import com.lightbend.lagom.javadsl.api.Service
6+
import com.lightbend.lagom.javadsl.api.Service.pathCall
7+
import com.lightbend.lagom.javadsl.api.ServiceCall
8+
import kotlin.reflect.jvm.javaMethod
9+
10+
/**
11+
* OpenAPI service descriptor.
12+
*/
13+
interface OpenAPIService : Service {
14+
15+
/**
16+
* Return OpenAPI specification for current service.
17+
* @return OpenAPI specification
18+
*/
19+
fun openapi(): ServiceCall<NotUsed, String>
20+
21+
@JvmDefault
22+
fun withOpenAPI(descriptor: Descriptor): Descriptor {
23+
return descriptor.withCalls(
24+
pathCall<NotUsed, String>("/_${descriptor.name()}/openapi", OpenAPIService::openapi.javaMethod)
25+
)
26+
}
27+
}

impl/pom.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
44
<modelVersion>4.0.0</modelVersion>
55
<parent>
6-
<groupId>org.taymyr</groupId>
7-
<artifactId>openapi-java</artifactId>
8-
<version>0.0.1</version>
6+
<groupId>org.taymyr.lagom</groupId>
7+
<artifactId>lagom-openapi-java</artifactId>
8+
<version>0.0.2</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
11-
<artifactId>openapi-java-impl</artifactId>
11+
<artifactId>lagom-openapi-java-impl</artifactId>
1212
<packaging>jar</packaging>
1313
<name>Taymyr: Openapi Java Impl</name>
1414
<dependencies>
@@ -17,8 +17,8 @@
1717
<artifactId>kotlin-stdlib-jdk8</artifactId>
1818
</dependency>
1919
<dependency>
20-
<groupId>org.taymyr</groupId>
21-
<artifactId>openapi-java-api</artifactId>
20+
<groupId>org.taymyr.lagom</groupId>
21+
<artifactId>lagom-openapi-java-api</artifactId>
2222
<version>${project.version}</version>
2323
</dependency>
2424
<dependency>
@@ -54,6 +54,7 @@
5454
<configuration>
5555
<args>
5656
<arg>-Xjsr305=strict</arg>
57+
<arg>-Xjvm-default=enable</arg>
5758
</args>
5859
</configuration>
5960
<executions>
@@ -102,7 +103,6 @@
102103
<plugin>
103104
<groupId>org.jacoco</groupId>
104105
<artifactId>jacoco-maven-plugin</artifactId>
105-
<version>${jacoco.plugin.version}</version>
106106
<executions>
107107
<execution>
108108
<goals>

impl/src/main/kotlin/org/taymyr/openapi/AbstractOpenAPIService.kt renamed to impl/src/main/kotlin/org/taymyr/lagom/openapi/AbstractOpenAPIService.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.taymyr.openapi
1+
package org.taymyr.lagom.openapi
22

33
import akka.NotUsed
44
import com.lightbend.lagom.javadsl.api.transport.MessageProtocol
@@ -13,9 +13,6 @@ import org.taymyr.lagom.javadsl.api.transport.ResponseHeaders.ok
1313
import java.util.Optional.ofNullable
1414
import java.util.concurrent.CompletableFuture.completedFuture
1515

16-
/**
17-
* @author Sergey Morgunov
18-
*/
1916
abstract class AbstractOpenAPIService(config: Config) : OpenAPIService {
2017

2118
private val apiSpec: String?

impl/src/test/kotlin/org/taymyr/openapi/OpenAPIServiceTest.kt renamed to impl/src/test/kotlin/org/taymyr/lagom/openapi/OpenAPIServiceTest.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.taymyr.openapi
1+
package org.taymyr.lagom.openapi
22

33
import com.lightbend.lagom.javadsl.api.transport.NotFound
44
import com.typesafe.config.ConfigFactory
@@ -9,9 +9,6 @@ import io.kotlintest.whenReady
99
import org.taymyr.lagom.javadsl.api.transport.MessageProtocols.YAML
1010
import org.taymyr.lagom.javadsl.api.transport.ResponseHeaders.OK_JSON
1111

12-
/**
13-
* @author Sergey Morgunov
14-
*/
1512
class OpenAPIServiceTest : StringSpec({
1613

1714
"Service with incorrect config should be return 404" {

0 commit comments

Comments
 (0)