Skip to content

Commit

Permalink
#36 ✨ enable Maven Build Cache testing and add instructions to replic…
Browse files Browse the repository at this point in the history
…ate; self PR feedback
  • Loading branch information
d-ryan-ashcraft committed Aug 23, 2023
1 parent 643d370 commit 3a945bc
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .mvn/extensions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<extensions>
<extension>
<groupId>org.apache.maven.extensions</groupId>
<artifactId>maven-build-cache-extension</artifactId>
<version>1.0.1</version>
</extension>
</extensions>
83 changes: 83 additions & 0 deletions .mvn/maven-build-cache-config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<cache xmlns="http://maven.apache.org/BUILD-CACHE-CONFIG/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/BUILD-CACHE-CONFIG/1.0.0 https://maven.apache.org/xsd/build-cache-config-1.0.0.xsd">
<configuration>
<enabled>true</enabled>
<hashAlgorithm>SHA-256</hashAlgorithm>
<validateXml>true</validateXml>
<remote enabled="false">
</remote>
<attachedOutputs>
<dirNames>
<dirName>../dist</dirName>
</dirNames>
</attachedOutputs>
<local>
<maxBuildsCached>3</maxBuildsCached>
</local>
<projectVersioning adjustMetaInf="true"/>
</configuration>
<input>
<global>
<glob>
{*.java,*.xml,*.proto,*.properties,*.py,*.txt,*.toml,.env*,*.feature}
</glob>
<includes>
<include>src/</include>
<include>pom.xml</include>
<include>pyproject.toml</include>
</includes>
<excludes>
<exclude>poetry.lock</exclude>
</excludes>
</global>
</input>
<executionControl>
<runAlways>
<plugins>
<plugin artifactId="maven-failsafe-plugin"/>
</plugins>
<executions>
<execution artifactId="maven-deploy-plugin">
<execIds>
<execId>my-execution-id</execId>
</execIds>
</execution>
</executions>
<goalsLists>
<goalsList artifactId="maven-install-plugin">
<goals>
<goal>install</goal>
</goals>
</goalsList>
<goalsList artifactId="maven-deploy-plugin">
<goals>
<goal>deploy</goal>
</goals>
</goalsList>
</goalsLists>
</runAlways>
<reconcile logAllProperties="true">
<plugins>
<plugin artifactId="maven-compiler-plugin" goal="compile">
<reconciles>
<reconcile propertyName="source"/>
<reconcile propertyName="target"/>
<reconcile propertyName="debug"/>
<reconcile propertyName="debuglevel"/>
</reconciles>
<!-- whitelist of logged properties -->
<logs>
<log propertyName="includes"/>
<log propertyName="excludes"/>
<log propertyName="argLine"/>
</logs>
</plugin>
<plugin artifactId="maven-enforcer-plugin" goal="enforce">
<reconciles>
<reconcile propertyName="skip" skipValue="true"/>
</reconciles>
</plugin>
</plugins>
</reconcile>
</executionControl>
</cache>
65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ No one person will agree with all the opinions implemented by Habushu. The value
In order to use Habushu, the following prerequisites must be installed:

* Maven 3.6+
* Maven 3.9+ for use with Maven Build Cache
* Java 11+
* [Poetry 1.2+](https://python-poetry.org/)
* [Pyenv](https://github.com/pyenv/pyenv)
Expand Down Expand Up @@ -159,6 +160,70 @@ For example, developers may use this feature to bind a Habushu module's `compile
</plugin>
```

### Leveraging Maven Build Cache for Faster Builds ###

Habushu enables support for faster builds via
the [Maven Build Cache](https://maven.apache.org/extensions/maven-build-cache-extension/) (only available in Maven
3.9+). This functionality
is enabled through two mechanisms: the Maven Reactor and Maven Build Cache Configuration. Both require manual action
to enable.

#### Maven Reactor Configuration ####

The [Reactor](https://maven.apache.org/guides/mini/guide-multiple-modules.html#the-reactor) allows Maven to understand
the relative structure and local hierarchy of Habushu/non-Habushu modules in your build. This can be accomplished by
adding a standard Maven dependency to the modules that should be tied together. For instance, the dependency below is
used in Habushu's test modules to create a dependency such that `habushu-mixology-consumer` depends on `habushu-mixology`.
By adding this, any time a change occurs in `habushu-mixology`, all dependent Habushu modules will be rebuilt automatically.

```xml
<!-- SNIPPET from habushu-mixology-consumer/pom.xml: -->
<dependency>
<!-- Follow standard Maven GAV (GroupId-ArtifactId-Version) referencing: -->
<groupId>org.technologybrewery.habushu</groupId>
<artifactId>habushu-mixology</artifactId>
<version>2.7.0</version>
<!-- type of habushu needed for habushu modules specifically: -->
<type>habushu</type>
</dependency>
```

#### Maven Build Cache Configuration ####

You also need to add the following to your Maven Build Cache `maven-build-cache-config.xml` file:

```xml

<cache>
<configuration>
...
<attachedOutputs>
<dirNames>
<!-- Critical to enable Maven to process the artifacts created by Habushu: -->
<dirName>../dist</dirName>
</dirNames>
</attachedOutputs>
...
</configuration>
<input>
<global>
<!-- The following glob values should be ADDED to your existing values: -->
<glob>
{*.xml,*.proto,*.properties,*.py,*.txt,*.toml,.env*,*.feature}
</glob>
<includes>
<include>src/</include>
<include>pyproject.toml</include>
</includes>
<excludes>
<exclude>poetry.lock</exclude>
</excludes>
</global>
</input>
...
</cache>
```

## Configuration ##

All Habushu configurations may be set either via the `habushu-maven-plugin`'s `<configuration>` definition, Maven POM properties, or `-D` on the line and follow a consistent naming pattern for the different configuration approaches. For setting configurations via POM properties or `-D` on the command line, all configuration keys may be prepended with `habushu.`. For example, `pythonVersion` controls the version of Python utilized by Habushu and may be configured using the following approaches:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public Integer executePoetryCommandAndLogAfterTimeout(List<String> arguments, in
return future.get(timeout, timeUnit);
} catch (TimeoutException e) {
logger.warn("poetry " + String.join(" ", arguments)
+ " has been running for quite some time, you may want to quit the mvn process (Ctrl+c) and run \"poetry cache clear . --all \" and restart your build.");
+ " has been running for quite some time, you may want to quit the mvn process (Ctrl+c) and run \"poetry cache clear . --all\" and restart your build.");
try {
return future.get();
} catch (InterruptedException | ExecutionException e1) {
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<name>habushu::Root</name>
<description>
In Okinawa, habushu (pronounced HA-BU-SHU) is a sake that is made with venomous snake. The alcohol in the snake assists in dissolving the snake's venom and making
it non-poisonous. In Maven, habushu allows pyhton projects to be build as part a Maven build. This brings some order and consistency to what can otherwise be
it non-poisonous. In Maven, habushu allows python projects to be build as part a Maven build. This brings some order and consistency to what can otherwise be
haphazardly structured projects.
</description>
<url>https://github.com/TechnologyBrewery/habushu</url>
Expand Down

0 comments on commit 3a945bc

Please sign in to comment.