Skip to content

Commit

Permalink
Update README and workflows.
Browse files Browse the repository at this point in the history
Merge pull request #1 from RezzedUp/info/readme
  • Loading branch information
RezzedUp authored Jun 27, 2021
2 parents e176f1a + 66e4cf4 commit 39862ca
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 37 deletions.
17 changes: 13 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,19 @@ jobs:
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
# https://github.com/samuelmeuli/action-maven-publish/issues/20#issuecomment-663544294
- name: Update Version in pom.xml (Release Only)
if: github.event.release
run: mvn -B versions:set -DnewVersion=${{ github.event.release.tag_name }} -DgenerateBackupPoms=false
- name: Verify and Update Version in pom.xml
run: |
VERSION=$(mvn -B -Dexec.executable='echo' -Dexec.args='${project.version}' --non-recursive exec:exec -q)
echo "Found version: ${VERSION}"
if [[ "${{ github.event_name }}" == "release" ]]; then
VERSION=$(echo "${{ github.event.release.tag_name }}" | sed -e 's/^v//gi')
echo "Release: updating version to ${VERSION}"
mvn -B versions:set -DnewVersion=${VERSION} -DgenerateBackupPoms=false
elif [[ ! "${VERSION}" =~ -SNAPSHOT$ ]]; then
echo "Missing SNAPSHOT in version: ${VERSION}"
exit 1
fi
- name: Release Maven Package
uses: samuelmeuli/action-maven-publish@v1
with:
Expand Down
29 changes: 0 additions & 29 deletions .run/build-then-deploy.run.xml

This file was deleted.

50 changes: 49 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,29 @@
[![](https://img.shields.io/badge/Java-11-orange)](# "Java Version: 11")
[![javadoc](https://javadoc.io/badge2/com.rezzedup.util/constants/javadoc.svg?label=Javadoc&color=%234D7A97)](https://javadoc.io/doc/com.rezzedup.util/constants "View Javadocs")

Utilities for `static final` constants.
Utilities for `static final` constants. Use 'em like enums.

```java
public class Example
{
public static final ComplexObject<String> STRING_CONSTANT =
ComplexObject.builder("abc").example("xyz").enabled(true).build();

public static final ComplexObject<Integer> INTEGER_CONSTANT =
ComplexObject.builder(1).example(-1).enabled(true).build();

@NotAggregated
public static final ComplexObject<Float> FLOAT_CONSTANT =
ComplexObject.builder(1.0F).example(-1.0F).enabled(false).build();

public static final ComplexObject<Double> DOUBLE_CONSTANT =
ComplexObject.builder(1.0).example(-1.0).enabled(true).build();

@AggregatedResult
public static final List<ComplexObject<?>> VALUES =
Aggregates.list(Example.class, new TypeCapture<ComplexObject<?>>() {});
}
```

## Maven

Expand Down Expand Up @@ -40,9 +62,35 @@ Maven Central: https://search.maven.org/artifact/com.rezzedup.util/constants
> ```
</details>
### Documentation
Javadoc: https://javadoc.io/doc/com.rezzedup.util/constants
### Shading
If you intend to shade this library, please consider **relocating** the packages
to avoid potential conflicts with other projects. This library also utilizes
nullness annotations, which may be undesirable in a shaded uber-jar. They can
safely be excluded, and you are encouraged to do so.
## Rationale
This library automates aggregating constants via reflection.
Or, in other words, it allows you to collect constants matching
specific type and name criteria in an orderly, enum-like way.
Now, why not just use enums? While enums are among the most
useful constructs offered by the Java language, they are, however,
deliberately limited in which data they're capable of representing.
Since all enums share a common supertype, they cannot extend any
other class by design. Some data just isn't suitable for enums,
such as instances of existing non-enum classes (or, *constants*).
Use this library when you need the 'collected' nature of an enum
in conjunction with the flexibility of full, unbridled objects.
In order to adequately support generics, this library also includes
various utilities for handling types, such as: a "super" type token
(`TypeCapture`), casting utility (`Cast`), primitive auto-boxing
utility (`Primitives`), and more. While seemingly unrelated, these
tools are included here to avoid introducing any extra dependencies.
62 changes: 59 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.4.0</version>
<version>5.7.2</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -124,6 +124,27 @@
</execution>
</executions>
</plugin>
<!-- Enforce Maven Central standards -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M3</version>
<executions>
<execution>
<id>enforce-no-repositories</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireNoRepositories>
<message>Only use dependencies from Maven Central.</message>
</requireNoRepositories>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand All @@ -135,6 +156,40 @@
</distributionManagement>

<profiles>
<!-- Development (activated by default, unless: -Ddeploy) -->
<profile>
<id>development</id>
<activation>
<property>
<name>!deploy</name>
</property>
</activation>
<build>
<plugins>
<!-- Enforce SNAPSHOT versions in development -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>enforce-no-releases</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireSnapshotVersion>
<message>Missing SNAPSHOT in version.</message>
</requireSnapshotVersion>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<!-- Production (activated by: -Pproduction OR -Ddeploy) -->
<profile>
<id>production</id>
Expand Down Expand Up @@ -184,7 +239,7 @@
</plugins>
</build>
</profile>
<!-- Production (activated by: -Ddeploy) -->
<!-- Deploy (activated by: -Ddeploy) -->
<profile>
<id>deploy</id>
<activation>
Expand All @@ -195,6 +250,7 @@
</activation>
<build>
<plugins>
<!-- Sign artifacts -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
Expand Down Expand Up @@ -225,7 +281,7 @@
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
<autoReleaseAfterClose>false</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
Expand Down

0 comments on commit 39862ca

Please sign in to comment.