Skip to content

Commit

Permalink
Merge branch 'release/0.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
ihostage committed Oct 15, 2018
2 parents 5da67e7 + 9679cc3 commit f625ab5
Show file tree
Hide file tree
Showing 14 changed files with 329 additions and 77 deletions.
110 changes: 110 additions & 0 deletions .mvn/wrapper/MavenWrapperDownloader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/

import java.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;

public class MavenWrapperDownloader {

/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL =
"https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar";

/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";

/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";

/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";

public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());

// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if(mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if(mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: : " + url);

File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if(!outputFile.getParentFile().exists()) {
if(!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}

private static void downloadFileFromURL(String urlString, File destination) throws Exception {
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}

}
Binary file modified .mvn/wrapper/maven-wrapper.jar
100644 → 100755
Binary file not shown.
2 changes: 1 addition & 1 deletion .mvn/wrapper/maven-wrapper.properties
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1 +1 @@
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
[![codebeat](https://codebeat.co/badges/36a7965b-aa57-40af-8db3-fd7e6b54fee3)](https://codebeat.co/projects/github-com-taymyr-openapi-java-develop)
[![Build Status](https://travis-ci.org/taymyr/openapi-java.svg?branch=develop)](https://travis-ci.org/taymyr/openapi-java)
[![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)
[![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)
[![codecov](https://codecov.io/gh/taymyr/openapi-java/branch/develop/graph/badge.svg)](https://codecov.io/gh/taymyr/openapi-java)
[![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)
[![Gitter](https://img.shields.io/badge/chat-gitter-purple.svg)](https://gitter.im/taymyr/taymyr)
[![Gitter_RU](https://img.shields.io/badge/chat-russian%20channel-purple.svg)](https://gitter.im/taymyr/taymyr_ru)
[![codebeat](https://codebeat.co/badges/e9c10a77-0084-4cc7-9328-2d224e95c558)](https://codebeat.co/projects/github-com-taymyr-lagom-openapi-java-develop)
[![Build Status](https://travis-ci.org/taymyr/lagom-openapi-java.svg?branch=develop)](https://travis-ci.org/taymyr/lagom-openapi-java)
[![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)
[![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)
[![codecov](https://codecov.io/gh/taymyr/lagom-openapi-java/branch/develop/graph/badge.svg)](https://codecov.io/gh/taymyr/lagom-openapi-java)
[![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)

# OpenAPI service for Lagom

Expand Down
86 changes: 79 additions & 7 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,83 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.taymyr</groupId>
<artifactId>openapi-java</artifactId>
<version>0.0.1</version>
<groupId>org.taymyr.lagom</groupId>
<artifactId>lagom-openapi-java</artifactId>
<version>0.0.2</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>openapi-java-api</artifactId>
<artifactId>lagom-openapi-java-api</artifactId>
<packaging>jar</packaging>
<name>Taymyr: Openapi Java API</name>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
</dependency>
<!-- Provided dependencies -->
<dependency>
<groupId>com.lightbend.lagom</groupId>
<artifactId>lagom-javadsl-api_${scala.binary.version}</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<configuration>
<args>
<arg>-Xjsr305=strict</arg>
<arg>-Xjvm-default=enable</arg>
</args>
</configuration>
<executions>
<execution>
<id>compile</id>
<goals> <goal>compile</goal> </goals>
</execution>
<execution>
<id>test-compile</id>
<goals> <goal>test-compile</goal> </goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>prepare-package</phase>
<id>ktlint</id>
<phase>verify</phase>
<configuration>
<target name="ktlint">
<java taskname="ktlint" dir="${basedir}" fork="true" failonerror="true"
classpathref="maven.plugin.classpath" classname="com.github.shyiko.ktlint.Main">
<arg value="src/**/*.kt"/>
<!-- see https://github.com/shyiko/ktlint#usage for more -->
<arg value="--reporter=plain"/>
<arg value="--reporter=checkstyle,output=${project.build.directory}/ktlint.xml"/>
</java>
</target>
</configuration>
<goals>
<goal>jar</goal>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.github.shyiko</groupId>
<artifactId>ktlint</artifactId>
<version>${ktlint.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -44,6 +93,29 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jetbrains.dokka</groupId>
<artifactId>dokka-maven-plugin</artifactId>
<configuration>
<cacheRoot>default</cacheRoot>
<noStdlibLink>false</noStdlibLink>
<jdkVersion>8</jdkVersion>
<sourceRoots>
<root>
<path>${basedir}/src/main/kotlin</path>
<platforms>JVM</platforms>
</root>
</sourceRoots>
</configuration>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>javadocJar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
31 changes: 0 additions & 31 deletions api/src/main/java/org/taymyr/openapi/OpenAPIService.java

This file was deleted.

27 changes: 27 additions & 0 deletions api/src/main/kotlin/org/taymyr/lagom/openapi/OpenAPIService.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.taymyr.lagom.openapi

import akka.NotUsed
import com.lightbend.lagom.javadsl.api.Descriptor
import com.lightbend.lagom.javadsl.api.Service
import com.lightbend.lagom.javadsl.api.Service.pathCall
import com.lightbend.lagom.javadsl.api.ServiceCall
import kotlin.reflect.jvm.javaMethod

/**
* OpenAPI service descriptor.
*/
interface OpenAPIService : Service {

/**
* Return OpenAPI specification for current service.
* @return OpenAPI specification
*/
fun openapi(): ServiceCall<NotUsed, String>

@JvmDefault
fun withOpenAPI(descriptor: Descriptor): Descriptor {
return descriptor.withCalls(
pathCall<NotUsed, String>("/_${descriptor.name()}/openapi", OpenAPIService::openapi.javaMethod)
)
}
}
14 changes: 7 additions & 7 deletions impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.taymyr</groupId>
<artifactId>openapi-java</artifactId>
<version>0.0.1</version>
<groupId>org.taymyr.lagom</groupId>
<artifactId>lagom-openapi-java</artifactId>
<version>0.0.2</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>openapi-java-impl</artifactId>
<artifactId>lagom-openapi-java-impl</artifactId>
<packaging>jar</packaging>
<name>Taymyr: Openapi Java Impl</name>
<dependencies>
Expand All @@ -17,8 +17,8 @@
<artifactId>kotlin-stdlib-jdk8</artifactId>
</dependency>
<dependency>
<groupId>org.taymyr</groupId>
<artifactId>openapi-java-api</artifactId>
<groupId>org.taymyr.lagom</groupId>
<artifactId>lagom-openapi-java-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
Expand Down Expand Up @@ -54,6 +54,7 @@
<configuration>
<args>
<arg>-Xjsr305=strict</arg>
<arg>-Xjvm-default=enable</arg>
</args>
</configuration>
<executions>
Expand Down Expand Up @@ -102,7 +103,6 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.plugin.version}</version>
<executions>
<execution>
<goals>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.taymyr.openapi
package org.taymyr.lagom.openapi

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

/**
* @author Sergey Morgunov
*/
abstract class AbstractOpenAPIService(config: Config) : OpenAPIService {

private val apiSpec: String?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.taymyr.openapi
package org.taymyr.lagom.openapi

import com.lightbend.lagom.javadsl.api.transport.NotFound
import com.typesafe.config.ConfigFactory
Expand All @@ -9,9 +9,6 @@ import io.kotlintest.whenReady
import org.taymyr.lagom.javadsl.api.transport.MessageProtocols.YAML
import org.taymyr.lagom.javadsl.api.transport.ResponseHeaders.OK_JSON

/**
* @author Sergey Morgunov
*/
class OpenAPIServiceTest : StringSpec({

"Service with incorrect config should be return 404" {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.taymyr.openapi
package org.taymyr.lagom.openapi

import com.lightbend.lagom.javadsl.api.Descriptor

Expand Down
Loading

0 comments on commit f625ab5

Please sign in to comment.