Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PR builder GitHub Workflow for Code snippets #1283

Merged
merged 3 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "maven"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
29 changes: 29 additions & 0 deletions .github/workflows/maven-pr-builder.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Compile Java source files

on:
pull_request:
branches:
- main
paths:
- '**/*.java'
- 'pom.xml'
- 'docs/antora.yml'
- '.github/workflows/maven-pr-builder.yaml'
schedule:
- cron: '15 2 * * 0'

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: '17'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

distribution: 'temurin'
cache: 'maven'
- name: Maven compile
run: |
HZ_VERSION=$(grep full-version docs/antora.yml|sed "s/.*:[ ]*'\(.*\)'/\1/")
mvn --show-version --batch-mode --no-transfer-progress test "-Dhazelcast.version=$HZ_VERSION"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ package-lock.json
.project
.settings/
.vscode/settings.json
/target/
.classpath
4 changes: 3 additions & 1 deletion docs/modules/ROOT/examples/dds/map/Employee.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import com.hazelcast.core.HazelcastJsonValue;

//tag::emp[]
public class Employee {
public static HazelcastJsonValue asJson(String surname) {
return new HazelcastJsonValue("{ \"surname\": \"" + surname + "\" }");
}
}
//end::emp[]
//end::emp[]
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import com.hazelcast.core.EntryEvent;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.HazelcastJsonValue;
import com.hazelcast.map.IMap;
import com.hazelcast.map.listener.EntryAddedListener;
import com.hazelcast.map.listener.EntryRemovedListener;
Expand Down Expand Up @@ -41,4 +42,4 @@ public void entryUpdated(EntryEvent<String, HazelcastJsonValue> event) {
}
}
}
//end::lwp[]
//end::lwp[]
21 changes: 0 additions & 21 deletions docs/modules/ROOT/examples/dds/map/Modify.java

This file was deleted.

4 changes: 3 additions & 1 deletion docs/modules/ROOT/examples/dds/map/Supplement.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package dds.map;

import java.io.Serializable;


Expand All @@ -18,4 +20,4 @@ public String getName() {
public Integer getPrice() {
return price;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package dds.map;

import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.map.MapLoaderLifecycleSupport;
import com.hazelcast.map.MapStore;
Expand Down Expand Up @@ -106,4 +108,4 @@ public void delete(String key) {
public void deleteAll(Collection<String> keys) {
this.collection.deleteMany(in("_id", keys));
}
}
}
8 changes: 4 additions & 4 deletions docs/modules/ROOT/examples/dds/queue/ConsumerMember.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ public class ConsumerMember {

public static void main( String[] args ) throws Exception {
HazelcastInstance hz = Hazelcast.newHazelcastInstance();
IQueue<Integer> queue = hz.getQueue( "queue" ); <1>
IQueue<Integer> queue = hz.getQueue( "queue" ); // <1>
while ( true ) {
int item = queue.take(); <2>
int item = queue.take(); // <2>
System.out.println( "Consumed: " + item );
if ( item == -1 ) {
queue.put( -1 );
break;
}
Thread.sleep( 5000 ); <3>
Thread.sleep( 5000 ); // <3>
}
System.out.println( "Consumer Finished!" );
}
}
//end::consumer[]
//end::consumer[]
6 changes: 3 additions & 3 deletions docs/modules/ROOT/examples/dds/queue/ProducerMember.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ public class ProducerMember {

public static void main( String[] args ) throws Exception {
HazelcastInstance hz = Hazelcast.newHazelcastInstance();
IQueue<Integer> queue = hz.getQueue( "queue" ); <1>
IQueue<Integer> queue = hz.getQueue( "queue" ); // <1>

<2>
// <2>
for ( int k = 1; k < 100; k++ ) {
queue.put( k );
System.out.println( "Producing: " + k );
Expand All @@ -19,4 +19,4 @@ public static void main( String[] args ) throws Exception {
System.out.println( "Producer Finished!" );
}
}
//end::producer[]
//end::producer[]
4 changes: 2 additions & 2 deletions docs/modules/ROOT/examples/dds/queue/TheQueueStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void deleteAll(Collection<Long> keys) {
}

@Override
<1>
// <1>
public Item load(Long key) {
System.out.println("load");
return null;
Expand All @@ -46,4 +46,4 @@ public Set<Long> loadAllKeys() {
return null;
}
}
//end::qs[]
//end::qs[]
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import com.hazelcast.config.Config;
import com.hazelcast.config.MergePolicyConfig;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.scheduledexecutor.IScheduledExecutorService;
import com.hazelcast.config.ScheduledExecutorConfig;

public class ScheduledExecutorConfiguration {
public static void main(String[] args) throws Exception{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,17 @@ public void entryUpdated(EntryEvent<String, String> event) {
public void mapCleared(MapEvent event) {
System.out.println( "Map Cleared: " + event );
}
@Override
public void entryRemoved(EntryEvent<String, String> event) {
}
@Override
public void entryEvicted(EntryEvent<String, String> event) {
}
@Override
public void entryExpired(EntryEvent<String, String> event) {
}
@Override
public void mapEvicted(MapEvent event) {
}
}
//end::mm[]
//end::mm[]
6 changes: 3 additions & 3 deletions docs/modules/ROOT/examples/distributedevents/Listen.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.HazelcastClient;
import com.hazelcast.client.HazelcastClient;
import com.hazelcast.map.IMap;
import com.hazelcast.map.MapEvent;
import com.hazelcast.core.EntryEvent;
Expand All @@ -10,7 +10,7 @@
public class Listen {

public static void main( String[] args ) {
HazelcastInstance hz = HazelcastClient.newHazelcastCllient();
HazelcastInstance hz = HazelcastClient.newHazelcastClient();
IMap<String, String> map = hz.getMap( "somemap" );
map.addEntryListener( new MyEntryListener(), true );
System.out.println( "EntryListener registered" );
Expand Down Expand Up @@ -60,4 +60,4 @@ public void mapCleared( MapEvent event ) {
}
}
}
//end::listen[]
//end::listen[]
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package jcache;

import javax.cache.Cache;
import javax.cache.CacheManager;
import javax.cache.Caching;
Expand Down Expand Up @@ -37,4 +39,4 @@ public static void main(String[] args){
System.out.println( value );
//end::jcacheapp[]
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package jcache;

import com.hazelcast.cache.ICache;
import com.hazelcast.cache.impl.event.CachePartitionLostEvent;
import com.hazelcast.cache.impl.event.CachePartitionLostListener;
Expand Down Expand Up @@ -34,4 +36,4 @@ public void partitionLost(CachePartitionLostEvent event) {
});
}
}
//end::pllu[]
//end::pllu[]
4 changes: 3 additions & 1 deletion docs/modules/ROOT/examples/jcache/User.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package jcache;

import java.io.Serializable;

@SuppressWarnings("unused")
Expand Down Expand Up @@ -66,4 +68,4 @@ public String toString() {
+ ", username='" + username + '\''
+ '}';
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package jcache;

import javax.cache.event.CacheEntryCreatedListener;
import javax.cache.event.CacheEntryEvent;
import javax.cache.event.CacheEntryExpiredListener;
Expand Down Expand Up @@ -45,4 +47,4 @@ private void printEvents(Iterable<CacheEntryEvent<? extends Integer, ? extends U
}
}
}
//end::ucel[]
//end::ucel[]
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package jcache;

import javax.cache.configuration.Factory;
import javax.cache.event.CacheEntryListener;

Expand All @@ -10,4 +12,4 @@ public CacheEntryListener<Integer, User> create() {
return new UserCacheEntryListener();
}
}
//end::ucelf[]
//end::ucelf[]
4 changes: 3 additions & 1 deletion docs/modules/ROOT/examples/jcache/UserCacheLoader.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package jcache;

import javax.cache.integration.CacheLoader;
import javax.cache.integration.CacheLoaderException;
import java.io.Serializable;
Expand Down Expand Up @@ -36,4 +38,4 @@ public Map<Integer, User> loadAll(Iterable<? extends Integer> keys) throws Cache
return loaded;
}
}
//end::ucl[]
//end::ucl[]
4 changes: 3 additions & 1 deletion docs/modules/ROOT/examples/jcache/UserCacheWriter.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package jcache;

import javax.cache.Cache;
import javax.cache.integration.CacheWriter;
import javax.cache.integration.CacheWriterException;
Expand Down Expand Up @@ -55,4 +57,4 @@ public void deleteAll(Collection<?> keys) throws CacheWriterException {
}
}
}
//end::ucw[]
//end::ucw[]
4 changes: 3 additions & 1 deletion docs/modules/ROOT/examples/jcache/UserDao.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package jcache;

import java.util.Collection;

//tag::userdao[]
Expand All @@ -8,4 +10,4 @@ public interface UserDao {
boolean removeUser(int userId);
Collection<Integer> allUserIds();
}
//end::userdao[]
//end::userdao[]
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package jcache;

import javax.cache.processor.EntryProcessor;
import javax.cache.processor.EntryProcessorException;
import javax.cache.processor.MutableEntry;
Expand Down Expand Up @@ -34,4 +36,4 @@ public User process(MutableEntry<Integer, User> entry, Object... arguments) thro
return user;
}
}
//end::uuep[]
//end::uuep[]
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package security;

import com.hazelcast.security.Credentials;

import javax.security.auth.callback.Callback;
Expand Down
2 changes: 2 additions & 0 deletions docs/modules/ROOT/examples/security/CustomLoginModule.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package security;

import com.hazelcast.security.Credentials;

import javax.security.auth.Subject;
Expand Down
Loading