Skip to content

Commit

Permalink
chore: maven sample
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Gammon <[email protected]>
  • Loading branch information
sgammon committed Mar 11, 2024
1 parent c4da303 commit c8262d0
Show file tree
Hide file tree
Showing 12 changed files with 737 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ clean: ## Clean all built targets.
org.checkerframework/build \
org.checkerframework/*/build \
samples/modular-guava/app/build \
samples/modular-guava-repo/app/build
samples/modular-guava-repo/app/build \
samples/modular-guava-maven/target

samples: ## Build samples.
$(info Building samples...)
Expand Down
11 changes: 8 additions & 3 deletions samples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,20 @@

include ../tools/common.mk

all: modular-guava modular-guava-repo
all: modular-guava modular-guava-repo modular-guava-maven
@echo "Samples ready."

modular-guava: modular-guava/app/build
modular-guava/app/build:
@echo "Building Modular Guava sample..."
@echo "Building Modular Guava sample (Gradle, local repo)..."
$(RULE)cd modular-guava && ./gradlew :app:build -x test -x check

modular-guava-repo: modular-guava-repo/app/build
modular-guava-repo/app/build:
@echo "Building Modular Guava sample (remote repo)..."
@echo "Building Modular Guava sample (Gradle, remote repo)..."
$(RULE)cd modular-guava-repo && ./gradlew :app:build -x test -x check --refresh-dependencies

modular-guava-maven: modular-guava-maven/target
modular-guava-maven/target:
@echo "Building Modular Guava sample (Maven, remote repo)..."
$(RULE)cd modular-guava-maven && mvnw clean package exec:exec@modular
10 changes: 9 additions & 1 deletion samples/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@

## JPMS Attic: Samples
# JPMS Attic: Samples

This sub-directory provides sample provides for Maven and Gradle which use the JPMS Attic repository. See each sample README for more information.

## Available Samples

- **[`modular-guava`](./modular-guava)**: Pure-Java project which builds against Guava JPMS with the local repository.

- **[`modular-guava-repo`](./modular-guava-repo)**: Same project, but builds with the remote repo, at `https://jpms.pkg.st/repository`.

- **[`modular-guava-maven`](./modular-guava-maven)**: Roughly the same project, but builds with the remote repo, at `https://jpms.pkg.st/repository`, with Maven.
2 changes: 2 additions & 0 deletions samples/modular-guava-maven/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/libs
/target
Binary file not shown.
18 changes: 18 additions & 0 deletions samples/modular-guava-maven/.mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
36 changes: 36 additions & 0 deletions samples/modular-guava-maven/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Modular Guava (Maven)

This sample builds a Guava-dependent pure-Java app [with the JPMS attic](../..). The app's module is `demo.modularguava`:

```java
module demo.modularguava {
requires com.google.common;
}
```

The entrypoint:

```java
public class ModularGuavaExample {
public static void main(String[] args) {
ImmutableNetwork<String, Integer> network =
NetworkBuilder.directed().<String, Integer>immutable().addEdge("A", "B", 10).build();

System.out.println("Hello Modular Guava! Here's a graph: " + network);
}
}
```

This sample can be built and run with:

```shell
mvnw clean package exec:exec@modular
```

The effective underlying Java run command is:

```shell
java \
--module-path target/libs:target/modular-guava-maven-1.0-SNAPSHOT.jar \
--module demo.modularguava/org.example.ModularGuavaExample
```
Loading

0 comments on commit c8262d0

Please sign in to comment.