Skip to content

Commit

Permalink
Merge branch 'release/2.11.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
mwalser committed Feb 23, 2023
2 parents 6d8a9fc + 61017ed commit 25a6318
Show file tree
Hide file tree
Showing 12 changed files with 237 additions and 146 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Java CI with Maven

on:
push:
branches: [ develop, master ]
pull_request:
branches: [ develop ]

jobs:
build_jdk11:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build with Maven
run: mvn -B verify
build_jdk8:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build with Maven
run: mvn -B verify
15 changes: 0 additions & 15 deletions .travis.yml

This file was deleted.

6 changes: 5 additions & 1 deletion CHANGELOG.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
= Changelog

== Unreleased
== Version 2.11.0

* Support authentication to the helm repository using credentials from server definitions in maven `settings.xml` via `chartRepoServerId`.
* Add an option to pass `--force-update` when adding helm repositories managed by this plugin.
* Cleanup dependencies, readme, and deprecated Kotlin functions

== Version 2.10.0

Expand Down
12 changes: 7 additions & 5 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
= Helm Maven Plugin

:uri-build-status: https://travis-ci.org/deviceinsight/helm-maven-plugin
:img-build-status: https://api.travis-ci.org/deviceinsight/helm-maven-plugin.svg?branch=develop
:uri-build-status: https://github.com/deviceinsight/helm-maven-plugin/actions/workflows/maven.yml
:img-build-status: https://github.com/deviceinsight/helm-maven-plugin/actions/workflows/maven.yml/badge.svg

image:{img-build-status}[Build Status Badge,link={uri-build-status}]

Expand All @@ -20,7 +20,7 @@ Add the following to your `pom.xml`
<plugin>
<groupId>com.deviceinsight.helm</groupId>
<artifactId>helm-maven-plugin</artifactId>
<version>2.10.0</version>
<version>2.11.0</version>
<configuration>
<chartName>my-chart</chartName>
<chartRepoUrl>https://charts.helm.sh/stable</chartRepoUrl>
Expand Down Expand Up @@ -82,11 +82,13 @@ that the correct docker image is used. An example snippet:
|chartRepoUrl |`null` |The URL of the Chart repository where dependencies are required from and where charts should be published to
|incubatorRepoUrl |`https://charts.helm.sh/incubator` |The URL to the incubator Chart repository
|addIncubatorRepo |`true` |Whether the repository defined in `incubatorRepoUrl` should be added when running the package goal
|forceAddRepos |`false` |Whether to overwrite the repository configuration when adding a new repository with the same name. This flag is only relevant when using Helm 3 and emulates Helm 2 behavior
|chartPublishUrl |`${chartRepoUrl}/api/charts` |The URL that will be used for publishing the chart. The default value will work if `chartRepoUrl` refers to a ChartMuseum.
|chartPublishMethod |"POST" |The HTTP method that will be used for publishing requests
|chartDeleteUrl |`${chartRepoUrl}/api/charts/${chartName}/${chartVersion}` |The URL that will be used for deleting a previous version of the chart. This is used for updating SNAPSHOT versions. The default value will work if `chartRepoUrl` refers to a ChartMuseum.
|chartRepoUsername |None |The username for basic authentication against the chart repo
|chartRepoPassword |None |The password for basic authentication against the chart repo
|chartRepoServerId |None |The ID of the server definition from the settings.xml server list to obtain the chart repo username/password from. If both chartRepoUsername/chartRepoPassword and chartRepoServerId are specified then the values specified in chartRepoUsername/chartRepoPassword take precedence.
|chartFolder |`"src/main/helm/<chartName>"` |The location of the chart files (e.g. Chart.yaml).
|skipSnapshots |`true` |If true, SNAPSHOT versions will be built, but not deployed.
|helmGroupId |`"com.deviceinsight.helm"` |The helm binary `groupId`
Expand Down Expand Up @@ -143,7 +145,7 @@ To use the `deployAtEnd` functionality it's mandatory to put the Helm Maven Plug
<plugin>
<groupId>com.deviceinsight.helm</groupId>
<artifactId>helm-maven-plugin</artifactId>
<version>2.10.0</version>
<version>2.11.0</version>
<configuration>
<chartName>my-chart</chartName>
<chartRepoUrl>https://charts.helm.sh/stable</chartRepoUrl>
Expand Down Expand Up @@ -177,7 +179,7 @@ Problem:: The following error message is a common source of trouble, lately:
...
[ERROR] Failed to execute goal com.deviceinsight.helm:helm-maven-plugin:2.10.0:package (default) on project my-project: Error creating helm chart: When executing '/home/user/.m2/repository/com/deviceinsight/helm/helm/2.16.2/helm-2.16.2-linux-amd64.binary init --client-only' got result code '1' -> [Help 1]
[ERROR] Failed to execute goal com.deviceinsight.helm:helm-maven-plugin:2.11.0:package (default) on project my-project: Error creating helm chart: When executing '/home/user/.m2/repository/com/deviceinsight/helm/helm/2.16.2/helm-2.16.2-linux-amd64.binary init --client-only' got result code '1' -> [Help 1]
----
Solution:: This is likely due to an old version of helm itself. Make sure to configure `<helmVersion>` to a version >= 3.4.0 or, if you are still using Helm 2, a version >= 2.17.0 (https://github.com/helm/charts#%EF%B8%8F-deprecation-and-archive-notice[background information]).
. {blank}
Expand Down
143 changes: 65 additions & 78 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,60 @@

<groupId>com.deviceinsight.helm</groupId>
<artifactId>helm-maven-plugin</artifactId>
<version>2.10.0</version>
<version>2.11.0</version>
<packaging>maven-plugin</packaging>

<name>Helm Maven Plugin</name>
<description>A Maven Plugin for Helm Charts</description>
<url>https://github.com/deviceinsight/helm-maven-plugin</url>

<properties>
<kotlin.version>1.4.30</kotlin.version>
<kotlin.version>1.8.10</kotlin.version>
<kotlin.compiler.jvmTarget>1.8</kotlin.compiler.jvmTarget>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<maven.version>3.6.0</maven.version>
<maven.version>3.6.2</maven.version>
<maven-project.version>2.2.1</maven-project.version>
<maven-artifact-transfer.version>0.13.1</maven-artifact-transfer.version>

<jackson.version>2.12.1</jackson.version>
<httpclient.version>4.5.13</httpclient.version>
<httpclient.version>4.5.14</httpclient.version>
<plexus-sec-dispatcher.version>1.4</plexus-sec-dispatcher.version>

<junit.jupiter.version>5.7.1</junit.jupiter.version>
<assertj-core.version>3.19.0</assertj-core.version>
<junit.jupiter.version>5.9.2</junit.jupiter.version>
<assertj-core.version>3.24.2</assertj-core.version>

<dokka-maven-plugin.version>1.4.20</dokka-maven-plugin.version>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<dokka-maven-plugin.version>1.7.20</dokka-maven-plugin.version>
<maven-compiler-plugin.version>3.10.1</maven-compiler-plugin.version>
<maven-source-plugin.version>3.2.1</maven-source-plugin.version>
<gitflow-maven-plugin.version>1.15.1</gitflow-maven-plugin.version>
<nexus-staging-maven-plugin.version>1.6.8</nexus-staging-maven-plugin.version>
<maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
<gitflow-maven-plugin.version>1.19.0</gitflow-maven-plugin.version>
<nexus-staging-maven-plugin.version>1.6.13</nexus-staging-maven-plugin.version>
<maven-gpg-plugin.version>3.0.1</maven-gpg-plugin.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-bom</artifactId>
<version>${kotlin.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
</dependency>

<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>${maven.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
Expand All @@ -58,48 +69,31 @@
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>${maven.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>${maven.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>${maven-project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-artifact-transfer</artifactId>
<version>${maven-artifact-transfer.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-kotlin</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${httpclient.version}</version>
</dependency>
<dependency>
<groupId>org.sonatype.plexus</groupId>
<artifactId>plexus-sec-dispatcher</artifactId>
<version>${plexus-sec-dispatcher.version}</version>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down Expand Up @@ -195,6 +189,38 @@
<useSnapshotInHotfix>true</useSnapshotInHotfix>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${maven-source-plugin.version}</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jetbrains.dokka</groupId>
<artifactId>dokka-maven-plugin</artifactId>
<version>${dokka-maven-plugin.version}</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>dokka</goal>
<goal>javadocJar</goal>
</goals>
<configuration>
<sourceDirectories>
<dir>${project.build.sourceDirectory}</dir>
</sourceDirectories>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down Expand Up @@ -257,45 +283,6 @@
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${maven-source-plugin.version}</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>verify</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jetbrains.dokka</groupId>
<artifactId>dokka-maven-plugin</artifactId>
<version>${dokka-maven-plugin.version}</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>dokka</goal>
<goal>javadocJar</goal>
</goals>
<configuration>
<sourceDirectories>
<dir>${project.build.sourceDirectory}</dir>
</sourceDirectories>
<perPackageOptions>
<packageOptions>
<prefix>com.deviceinsight.helm</prefix>
<reportUndocumented>false</reportUndocumented>
</packageOptions>
</perPackageOptions>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
Expand Down
28 changes: 21 additions & 7 deletions src/main/kotlin/com/deviceinsight/helm/AbstractHelmMojo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import org.apache.maven.plugin.AbstractMojo
import org.apache.maven.plugins.annotations.Parameter
import org.apache.maven.project.MavenProject
import java.io.File
import kotlin.concurrent.thread

abstract class AbstractHelmMojo : AbstractMojo() {

Expand All @@ -38,22 +39,35 @@ abstract class AbstractHelmMojo : AbstractMojo() {
@Parameter(property = "chartName", required = false)
private var chartName: String? = null

protected fun executeCmd(cmd: String, directory: File = target(),
redirectOutput: ProcessBuilder.Redirect = ProcessBuilder.Redirect.PIPE) {
val proc = ProcessBuilder(cmd.split(" "))
protected fun executeCmd(
cmd: List<String>,
directory: File = target(),
logStdoutToInfo: Boolean = false,
redirectOutput: ProcessBuilder.Redirect = ProcessBuilder.Redirect.PIPE
) {
val proc = ProcessBuilder(cmd)
.directory(directory)
.redirectOutput(redirectOutput)
.redirectError(ProcessBuilder.Redirect.PIPE)
.start()

val stdoutPrinter = thread(name = "Stdout printer") {
val logFunction: (String) -> Unit = if (logStdoutToInfo) log::info else log::debug
proc.inputStream.bufferedReader().lines().forEach { logFunction("Output: $it") }
}

val stderrPrinter = thread(name = "Stderr printer") {
proc.errorStream.bufferedReader().lines().forEach { log.error("Output: $it") }
}

proc.waitFor()
stdoutPrinter.join()
stderrPrinter.join()

log.debug("When executing '$cmd' in '${directory.absolutePath}', result was ${proc.exitValue()}")
proc.inputStream.bufferedReader().lines().forEach { log.debug("Output: $it") }
proc.errorStream.bufferedReader().lines().forEach { log.error("Output: $it") }
log.debug("When executing '${cmd.joinToString(" ")}' in '${directory.absolutePath}', result was ${proc.exitValue()}")

if (proc.exitValue() != 0) {
throw RuntimeException("When executing '$cmd' got result code '${proc.exitValue()}'")
throw RuntimeException("When executing '${cmd.joinToString(" ")}' got result code '${proc.exitValue()}'")
}
}

Expand Down
Loading

0 comments on commit 25a6318

Please sign in to comment.