Skip to content

Commit

Permalink
Gradle to Maven conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
marcingrzejszczak committed Oct 28, 2022
1 parent 45285fb commit aa358e4
Show file tree
Hide file tree
Showing 135 changed files with 3,900 additions and 3,043 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ indent_size = 2
indent_style = space
indent_size = 4
continuation_indent_size = 8
ij_java_imports_layout = *,|,javax.**,java.**,|,$*
ij_java_imports_layout = *, |, javax.**, java.**, |, $*
ij_java_class_count_to_use_import_on_demand = 5
ij_java_names_count_to_use_import_on_demand = 3
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ logs
out
.vscode/
tempo-data/
target/
1 change: 1 addition & 0 deletions .mvn/jvm.config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-Xmx1024m -XX:CICompilerCount=1 -XX:TieredStopAtLevel=1 -Djava.security.egd=file:/dev/./urandom
1 change: 1 addition & 0 deletions .mvn/maven.config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-P spring
122 changes: 122 additions & 0 deletions .mvn/wrapper/MavenWrapperDownloader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/*
* Copyright 2007-present the original author or authors.
*
* Licensed 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 {

private static final String WRAPPER_VERSION = "0.5.6";
/**
* 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/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".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 directory '" + 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 {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
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 added .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
2 changes: 2 additions & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
18 changes: 9 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ services:
language: groovy

jdk:
- oraclejdk8
- oraclejdk8

install:
- true
- true

before_script:
- "echo $JAVA_OPTS"
- "export JAVA_OPTS=-Xmx256m"
- "echo $JAVA_OPTS"
- "export JAVA_OPTS=-Xmx256m"

script:
- ./gradlew clean build --parallel $SWITCH
- ./gradlew clean build --parallel $SWITCH

env:
global:
- TERM=dumb
- SHOULD_START_RABBIT=no
- RETRIES=200
- TERM=dumb
- SHOULD_START_RABBIT=no
- RETRIES=200
matrix:
- SWITCH='-DWHAT_TO_TEST=SLEUTH'
- SWITCH='-DWHAT_TO_TEST=ZOOKEEPER'
- SWITCH='-DWHAT_TO_TEST=EUREKA'
- SWITCH='-DWHAT_TO_TEST=CONSUL'
- SWITCH='-DWHAT_TO_TEST=CONSUL'
56 changes: 11 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ Here is the UI

![UI](img/Brewery_UI.png)

- Go to the presenting service (http://localhost:9991 or to https://brewery-presenting.${PCF_DOMAIN}) and order ingredients. `PCF_DOMAIN` is the domain set to your CF installation. If you deploy to Pivotal Web Services it will default to `cfapps.io` (so the link for PWS will be https://brewery-presenting.cfapps.io) **(1)**
- Go to the presenting service (http://localhost:9991 or to https://brewery-presenting.${PCF_DOMAIN}) and order ingredients. `PCF_DOMAIN` is the domain set to your CF installation.
If you deploy to Pivotal Web Services it will default to `cfapps.io` (so the link for PWS will be https://brewery-presenting.cfapps.io) **(1)**
- A request from the presenting service is sent to the aggregating service when order is placed **(2)**
- A "PROCESS-ID" header is set and will be passed through each part of beer brewing

Expand All @@ -43,7 +44,7 @@ Brewing service contains the following functionalities:
- Service contains a warehouse ("database") where is stores the ingredients
- Spring Cloud Gateway will be used as proxy **(3)**
- Once the ingredients have been received an event is emitted **(7)**
- You have to have all 4 ingredients reach their threshold (1000) to start maturing the beer
- You have to have all 4 ingredients reach their threshold (1000) to start maturing the beer
- Once the brewing has been started an event is emitted **(7)**
- Once the threshold is met the application sends a request to the maturing service **(8)**
- Each time a request is sent to the aggregating service it returns as a response its warehouse state
Expand All @@ -52,14 +53,14 @@ Brewing service contains the following functionalities:

- It receives a request with ingredients needed to brew a beer
- The brewing process starts thanks to the `Thread.sleep` method
- Once it's done an event is emitted **(9)**
- Once it's done an event is emitted **(9)**
- And a request to the bottling service is sent with number of worts **(10)**
- Presenting service is called to update the current status of the beer brewing process

#### Bottling

- Waits some time to bottle the beer
- Once it's done an event is emitted **(11)**
- Once it's done an event is emitted **(11)**
- Presenting service is called to update the current status of the beer brewing process **(12)**

### Ingredients Service
Expand All @@ -86,29 +87,25 @@ Brewing service contains the following functionalities:
├── docker (docker scripts for additional apps - e.g. graphite)
├── config-server (set up for the config server)
├── eureka (Eureka server needed for Eureka tests)
├── git-props (properties for config-server to pick)
├── gradle (gradle related stuff)
├── img (the fabulous diagram of the brewery)
├── ingredients (service returns ingredients)
├── presenting (UI of the brewery)
├── reporting (service that listens to events)
├── zipkin-server (Zipkin Server for Sleuth Stream tests)
├── zookeeper (embedded zookeeper)
└── proxy (Spring Cloud Gateway that forwards requests to ingredients)
```

## How to build it?

```
./gradlew clean build
./mvnw clean install
```

## How to build one module?

E.g. `brewing` module

```
./gradlew brewing:clean brewing:build
./mvnw clean install -pl brewing
```

## How to run it?
Expand All @@ -121,39 +118,8 @@ YOU NEED DOCKER-COMPOSE INSTALLED TO RUN THE BREWERY ON YOUR LOCAL MACHINE!

The easiest way is to:

* GO to the cloned `brewery` where you have the `runAcceptanceTests.sh` script (which in fact is already a symbolic link to `acceptance-tests/scripts/runDockerAcceptanceTests.sh`
for your convenience)
* You can execute that script with such options

```
GLOBAL:
-t |--whattotest - define what you want to test (i.e. SLEUTH, ZOOKEEPER, SLEUTH, EUREKA, CONSUL, SCS)
-v |--version - which version of BOM do you want to use? Defaults to Brixton snapshot
-sv |--scsversion - which version of BOM for Spring Cloud Services do you want to use? Defaults to 1.1.2.BUILD-SNAPSHOT
-h |--healthhost - what is your health host? where is docker? defaults to localhost
-l |--numberoflines - how many lines of logs of your app do you want to print? Defaults to 1000
-r |--reset - do you want to reset the git repo of brewery? Defaults to "no"
-ke |--killattheend - should kill all the running apps at the end of execution? Defaults to "no"
-n |--killnow - should not run all the logic but only kill the running apps? Defaults to "no"
-x |--skiptests - should skip running of e2e tests? Defaults to "no"
-s |--skipbuilding - should skip building of the projects? Defaults to "no"
-k |--kafka - uses Kafka instead of RabbitMQ
-d |--skipdeployment - should skip deployment of apps? Defaults to "no"
-a |--deployonlyapps - should deploy only the brewery business apps instead of the infra too? Defaults to "no"
-b |--bootversion - Which version of Boot should be used? Defaults to 1.4.4.RELEASE for the plugin and to boot version used by libs
-ve |--verbose - Will print all library versions
CLOUD FOUNDRY RELATED PROPERTIES:
-c |--usecloudfoundry - should run tests for cloud foundry? (works only for SLEUTH) Defaults to "no"
-cd |--cloudfoundrydomain - what's the domain of your cloud foundry? Defaults to "run.pivotal.io"
-cu |--username - username to log in with to CF
-cp |--password - password to log in with to CF
-cpr|--cloudfoundryprefix - provides the prefix to the brewery app name. Defaults to 'brewery'
-cs |--space - provides the space for Cloud Foundry. Defaults to 'brewery'
-co |--org - provides the prefix to the brewery app name. Defaults to 'brewery'
```

* For more options just run `runAcceptanceTests.sh` without any options or with `--help` switch
* GO to the cloned `brewery` where you have the `runAcceptanceTests.sh` script
* For all options just run `runAcceptanceTests.sh` without any options or with `--help` switch

Once you run the script, the brewery app will be cloned, built with proper lib versions and proper tests
will be executed.
Expand Down Expand Up @@ -216,19 +182,19 @@ Execute:
bash runAcceptanceTests.sh -n
```


## How to run a single module?

To run a single module just execute (e.g. `presenting` module):

```
./gradlew presenting:bootRun -Dspring.profiles.active=dev
./mvnw spring-boot:run -Dspring.profiles.active=dev -pl presenting
```

## Authors

The code is ported from https://github.com/uservices-hackathon

The authors of the initial version of the code are:

- Marcin Grzejszczak (marcingrzejszczak)
- Tomasz Szymanski (szimano)
18 changes: 9 additions & 9 deletions acceptance-tests/README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Brewery Acceptance Tests
# Brewery Acceptance Tests

Tests that check various Spring Cloud functionalities on the Brewery project.

## What are we testing?

### Service Discovery
### Service Discovery

Do applications talk to each other properly via:

- Zookeeper
- Eureka
- Consul
- Consul

### Tracing
### Tracing

Does request instrumentalization work properly with:

Expand All @@ -35,18 +35,18 @@ This project is automatically ran from the Brewery root project via a bash scrip
is a normal Gradle project, you can run the tests by simply passing Gradle commands. Check the configuration section
for more info on how to parametrize the tests.

When ran in a PR build acceptance tests are placed in a docker container so that they can access the
Docker Virtual Network. Only then will the tests be able to find and successfully call the Presenting
When ran in a PR build acceptance tests are placed in a docker container so that they can access the
Docker Virtual Network. Only then will the tests be able to find and successfully call the Presenting
service via service discovery tool.

## Configuration

Check the `io.spring.cloud.samples.brewery.acceptance.common.WhatToTest` to see what exactly you can test.
Check the `io.spring.cloud.samples.brewery.acceptance.common.WhatToTest` to see what exactly you can test.
In order to execute the those tests you have to provide a system parameter `WHAT_TO_TEST` with the value
from that enum. E.g.

```
./gradlew test -DWHAT_TO_TEST=SLEUTH
../mvnw verify -DWHAT_TO_TEST=SLEUTH
```

### Parameters
Expand All @@ -57,4 +57,4 @@ In addition to this you can provide a couple of more parameters:
# will point to the desired URL to find the all services (e.g. https://192.168.99.100), Useful when working
# with docker-machine
-DLOCAL_URL=https://192.168.99.100
```
```
Loading

0 comments on commit aa358e4

Please sign in to comment.