Skip to content

Commit 349d978

Browse files
committed
Github Actions + Maven deploy
1 parent 54b1b6f commit 349d978

File tree

11 files changed

+288
-124
lines changed

11 files changed

+288
-124
lines changed

.github/workflows/redux4j.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# This workflow will build a Java project with Maven
2+
# For more information see: https://docs.github.com/en/actions/guides/building-and-testing-java-with-maven
3+
4+
name: redux4j
5+
6+
on:
7+
push:
8+
branches: [ master ]
9+
pull_request:
10+
branches: [ master ]
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v2
19+
- name: Set up JDK 8
20+
uses: actions/setup-java@v2
21+
with:
22+
java-version: '8'
23+
distribution: 'adopt'
24+
- name: Build with Maven
25+
run: mvn --batch-mode --update-snapshots verify
26+
- name: Receiving GPG key
27+
run: gpg --keyserver hkp://hkps.pool.sks-keyservers.net --recv-keys ${{secrets.GPG_KEYID}}
28+
- name: Import GPG Owner Trust
29+
run: echo ${{secrets.GPG_OWNERTRUST}} | base64 --decode | gpg --import-ownertrust
30+
- name: Import GPG key
31+
run: echo ${{secrets.GPG_SECRET_KEYS}} | base64 --decode | gpg --import --no-tty --batch --yes
32+
- name: Clean settings.xml
33+
run: sudo rm -rf ~/.m2/settings.xml
34+
- name: Create settings.xml
35+
uses: s4u/maven-settings-action@v1
36+
with:
37+
servers: '[{"id": "ossrh", "username": "${{secrets.SONATYPE_USERNAME}}", "password": "${{secrets.SONATYPE_PASSWORD}}"}]'
38+
- name: Deploy a new version to central
39+
run: mvn clean deploy -B -DskipTests -DskipExamples -Prelease -Dgpg.keyname=${{secrets.GPG_KEYNAME}} -Dgpg.passphrase=${{secrets.GPG_PASSPHRASE}}

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 Alexandre Grison
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
## Redux in Java
22

3-
Using Java 13 and vavr.
3+
![redux4j](https://github.com/agrison/redux4j/workflows/redux4j/badge.svg)
4+
5+
Using Java and Vavr.
46

57
## Features
68

@@ -9,6 +11,16 @@ Using Java 13 and vavr.
911
* CombineReducers
1012
* Middlewares
1113

14+
## Install
15+
16+
```xml
17+
<dependency>
18+
<groupId>me.grison</groupId>
19+
<artifactId>redux4j</artifactId>
20+
<version>1.0</version>
21+
</dependency>
22+
```
23+
1224
## Counter example
1325

1426
```java

pom.xml

+111-52
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
<version>1.0-SNAPSHOT</version>
1010

1111
<properties>
12-
<maven.compiler.source>15</maven.compiler.source>
13-
<maven.compiler.target>15</maven.compiler.target>
14-
<java.version>1.15</java.version>
12+
<maven.compiler.source>1.8</maven.compiler.source>
13+
<maven.compiler.target>1.8</maven.compiler.target>
14+
1515
<junit.jupiter.version>5.6.2</junit.jupiter.version>
1616
<maven.maven-surefire-plugin.version>3.0.0-M4</maven.maven-surefire-plugin.version>
1717
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -58,57 +58,116 @@
5858
<dependency>
5959
<groupId>org.projectlombok</groupId>
6060
<artifactId>lombok</artifactId>
61-
<version>1.18.12</version>
61+
<version>1.18.20</version>
6262
</dependency>
6363
</dependencies>
6464

65-
<build>
66-
<plugins>
67-
<plugin>
68-
<groupId>org.apache.maven.plugins</groupId>
69-
<artifactId>maven-surefire-plugin</artifactId>
70-
<version>3.0.0-M4</version>
71-
<configuration>
72-
<argLine>--enable-preview</argLine>
73-
</configuration>
74-
</plugin>
75-
<plugin>
76-
<groupId>org.apache.maven.plugins</groupId>
77-
<artifactId>maven-failsafe-plugin</artifactId>
78-
<version>3.0.0-M4</version>
79-
<configuration>
80-
<argLine>--enable-preview</argLine>
81-
</configuration>
82-
</plugin>
83-
<plugin>
84-
<groupId>org.apache.maven.plugins</groupId>
85-
<artifactId>maven-compiler-plugin</artifactId>
86-
<version>3.3</version>
87-
<executions>
88-
<execution>
89-
<id>compile</id>
90-
<phase>compile</phase>
91-
<goals>
92-
<goal>compile</goal>
93-
</goals>
94-
</execution>
95-
<execution>
96-
<id>testCompile</id>
97-
<phase>test-compile</phase>
98-
<goals>
99-
<goal>testCompile</goal>
100-
</goals>
101-
</execution>
102-
</executions>
103-
<configuration>
104-
<source>15</source>
105-
<target>15</target>
106-
<compilerArgs>
107-
--enable-preview
108-
</compilerArgs>
109-
</configuration>
110-
</plugin>
111-
</plugins>
112-
</build>
65+
<profiles>
66+
<profile>
67+
<id>release</id>
68+
<activation>
69+
<property>
70+
<name>release</name>
71+
</property>
72+
</activation>
73+
<build>
74+
<plugins>
75+
<plugin>
76+
<groupId>org.apache.maven.plugins</groupId>
77+
<artifactId>maven-deploy-plugin</artifactId>
78+
<version>3.0.0-M1</version>
79+
<configuration>
80+
<skip>true</skip>
81+
</configuration>
82+
</plugin>
83+
<plugin>
84+
<groupId>org.sonatype.plugins</groupId>
85+
<artifactId>nexus-staging-maven-plugin</artifactId>
86+
<version>1.6.8</version>
87+
<configuration>
88+
<autoReleaseAfterClose>true</autoReleaseAfterClose>
89+
<serverId>ossrh</serverId>
90+
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
91+
</configuration>
92+
<executions>
93+
<execution>
94+
<id>default-deploy</id>
95+
<phase>deploy</phase>
96+
<goals>
97+
<goal>deploy</goal>
98+
</goals>
99+
</execution>
100+
</executions>
101+
</plugin>
102+
<plugin>
103+
<groupId>org.apache.maven.plugins</groupId>
104+
<artifactId>maven-source-plugin</artifactId>
105+
<version>3.2.1</version>
106+
<executions>
107+
<execution>
108+
<id>attach-sources</id>
109+
<goals>
110+
<goal>jar</goal>
111+
</goals>
112+
</execution>
113+
</executions>
114+
</plugin>
115+
<plugin>
116+
<groupId>org.apache.maven.plugins</groupId>
117+
<artifactId>maven-javadoc-plugin</artifactId>
118+
<version>3.2.0</version>
119+
<executions>
120+
<execution>
121+
<id>attach-javadocs</id>
122+
<goals>
123+
<goal>jar</goal>
124+
</goals>
125+
</execution>
126+
</executions>
127+
</plugin>
128+
<plugin>
129+
<groupId>org.apache.maven.plugins</groupId>
130+
<artifactId>maven-gpg-plugin</artifactId>
131+
<version>1.6</version>
132+
<configuration>
133+
<gpgArguments>
134+
<arg>--batch</arg>
135+
<arg>--yes</arg>
136+
<arg>--pinentry-mode</arg>
137+
<arg>loopback</arg>
138+
</gpgArguments>
139+
</configuration>
140+
<executions>
141+
<execution>
142+
<id>sign-artifacts</id>
143+
<phase>verify</phase>
144+
<goals>
145+
<goal>sign</goal>
146+
</goals>
147+
</execution>
148+
</executions>
149+
</plugin>
150+
</plugins>
151+
</build>
152+
</profile>
153+
</profiles>
154+
155+
<distributionManagement>
156+
<snapshotRepository>
157+
<id>ossrh</id>
158+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
159+
</snapshotRepository>
160+
<repository>
161+
<id>ossrh</id>
162+
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
163+
</repository>
164+
</distributionManagement>
165+
166+
<scm>
167+
<connection>scm:git:git://github.com/agrison/redux4j.git</connection>
168+
<developerConnection>scm:git:[email protected]:agrison/redux4j.git</developerConnection>
169+
<url>https://github.com/agrison/redux4j</url>
170+
<tag>HEAD</tag>
171+
</scm>
113172

114173
</project>

src/main/java/me/grison/redux4j/Middleware.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
*/
1111
@FunctionalInterface
1212
public interface Middleware<State, Action>
13-
extends TriConsumer<State, Action, Middleware<State,Action>> {
13+
extends TriConsumer<ReduxStore<State, Action>, Action, Middleware<State,Action>> {
1414
}

src/main/java/me/grison/redux4j/Redux.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package me.grison.redux4j;
22

33
import io.vavr.Tuple2;
4+
import io.vavr.collection.HashMap;
45
import io.vavr.control.Try;
56
import org.apache.commons.beanutils.PropertyUtilsBean;
67

@@ -33,12 +34,13 @@ public static <State, Action> Store<State, Action> createStore(State initialStat
3334
* @return a reducer combining the given reducers.
3435
*/
3536
@SafeVarargs
37+
@SuppressWarnings("unchecked")
3638
public static <State> Reducer<Object, State> combineReducers(Tuple2<String, Reducer>... reducers) {
37-
var allReducers = io.vavr.collection.HashMap.ofEntries(reducers);
39+
HashMap<String, Reducer> allReducers = HashMap.ofEntries(reducers);
3840

3941
return (action, state) -> {
4042
if (state instanceof Map) {
41-
var s = (Map<String, Object>) state;
43+
Map<String, Object> s = (Map<String, Object>) state;
4244
allReducers.forEach((a, r) -> s.put(a, r.apply(action, s.get(a))));
4345
} else {
4446
allReducers.forEach((a, r) ->

src/main/java/me/grison/redux4j/Store.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public class Store<State, Action>
4848
* @param reducer the reducer
4949
* @param middlewares the middlewares
5050
*/
51+
@SafeVarargs
5152
public static <State, Action> Store<State, Action> create(State initialState, Reducer<Action, State> reducer,
5253
Middleware<State, Action>... middlewares) {
5354
return new Store<>(initialState, reducer, middlewares);
@@ -60,6 +61,7 @@ public static <State, Action> Store<State, Action> create(State initialState, Re
6061
* @param reducer the reducer
6162
* @param middlewares the middlewares
6263
*/
64+
@SafeVarargs
6365
private Store(State initialState, Reducer<Action, State> reducer, Middleware<State, Action>... middlewares) {
6466
currentState = initialState;
6567
this.reducer = reducer;
@@ -75,9 +77,9 @@ private Store(State initialState, Reducer<Action, State> reducer, Middleware<Sta
7577

7678
middlewareStack = some((action) -> List.of(middlewares)
7779
.fold((s1, a1, m) -> internalDispatch(action),
78-
(m1, m2) -> (c, d, e) -> m2.accept(getState(), action, m1)
80+
(m1, m2) -> (c, d, e) -> m2.accept(this, action, m1)
7981
)
80-
.accept(getState(), action, null));
82+
.accept(this, action, null));
8183
}
8284
}
8385

@@ -133,7 +135,7 @@ private void notifySubscribers() {
133135
}
134136

135137
public UUID subscribe(Consumer<State> subscriber) {
136-
var uuid = UUID.randomUUID();
138+
UUID uuid = UUID.randomUUID();
137139
consumers = consumers.put(uuid, subscriber);
138140

139141
SUBSCRIBING_LOGGER.debug("Subscribing {}. ID: {}.", subscriber, uuid);

0 commit comments

Comments
 (0)