Add maven package in stdlib
Signed-off-by: Alvise <vitalvise@gmail.com>
This commit is contained in:
parent
14062c3c38
commit
f807314668
@ -19,6 +19,7 @@
|
|||||||
- [git](./git.md) - Git operations
|
- [git](./git.md) - Git operations
|
||||||
- [go](./go.md) - Go build operations
|
- [go](./go.md) - Go build operations
|
||||||
- [io](./io.md) - IO operations
|
- [io](./io.md) - IO operations
|
||||||
|
- [java/maven](./java/maven.md) - Maven is a build automation tool for Java
|
||||||
- [js/yarn](./js/yarn.md) - Yarn is a package manager for Javascript applications
|
- [js/yarn](./js/yarn.md) - Yarn is a package manager for Javascript applications
|
||||||
- [kubernetes](./kubernetes/README.md) - Kubernetes client operations
|
- [kubernetes](./kubernetes/README.md) - Kubernetes client operations
|
||||||
- [kubernetes/helm](./kubernetes/helm.md) - Helm package manager
|
- [kubernetes/helm](./kubernetes/helm.md) - Helm package manager
|
||||||
|
32
docs/reference/universe/java/maven.md
Normal file
32
docs/reference/universe/java/maven.md
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
---
|
||||||
|
sidebar_label: maven
|
||||||
|
---
|
||||||
|
|
||||||
|
# alpha.dagger.io/java/maven
|
||||||
|
|
||||||
|
Maven is a build automation tool for Java
|
||||||
|
|
||||||
|
```cue
|
||||||
|
import "alpha.dagger.io/java/maven"
|
||||||
|
```
|
||||||
|
|
||||||
|
## maven.#Project
|
||||||
|
|
||||||
|
A Maven project
|
||||||
|
|
||||||
|
### maven.#Project Inputs
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| ------------- |:-------------: |:-------------: |
|
||||||
|
|*source* | `dagger.#Artifact` |Application source code |
|
||||||
|
|*package* | `struct` |Extra alpine packages to install |
|
||||||
|
|*env* | `struct` |Environment variables |
|
||||||
|
|*phases* | `*["package"] \| []` |- |
|
||||||
|
|*goals* | `*[] \| []` |- |
|
||||||
|
|*args* | `*[] \| []` |Optional arguments for the script |
|
||||||
|
|
||||||
|
### maven.#Project Outputs
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| ------------- |:-------------: |:-------------: |
|
||||||
|
|*build* | `struct` |Build output directory |
|
2
stdlib/.dagger/env/java-maven/.gitignore
vendored
Normal file
2
stdlib/.dagger/env/java-maven/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# dagger state
|
||||||
|
state/**
|
28
stdlib/.dagger/env/java-maven/values.yaml
vendored
Normal file
28
stdlib/.dagger/env/java-maven/values.yaml
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
plan:
|
||||||
|
module: ./java/maven
|
||||||
|
package: ./tests
|
||||||
|
name: java-maven
|
||||||
|
inputs:
|
||||||
|
TestData:
|
||||||
|
dir:
|
||||||
|
path: ./java/maven/tests/testdata
|
||||||
|
sops:
|
||||||
|
kms: []
|
||||||
|
gcp_kms: []
|
||||||
|
azure_kv: []
|
||||||
|
hc_vault: []
|
||||||
|
age:
|
||||||
|
- recipient: age1frg88gugx9ynthc66rcld7k5frtcddjehz4aw5k0wmntkd9pgsxs2vj5xe
|
||||||
|
enc: |
|
||||||
|
-----BEGIN AGE ENCRYPTED FILE-----
|
||||||
|
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSA4dWpSS2djbldQTzZQQ3kz
|
||||||
|
VUt2OU9zaVpCZHREa2plRDJsNFRaeVNOWmdVCnVqOVFZR2pJNXB4bThSUjBYTDZy
|
||||||
|
WWIzaWp3UTk2d0ErSFAzcHNYK3FRQ2cKLS0tIDhZWjVZZGFvbHVzN2FmTno3QzFx
|
||||||
|
WWV2Zjhra3AyenBKTVBoV3lNYVVTVWMKZQWIThYlZBEJKn62tGl7g3GkK4UqEfLF
|
||||||
|
NsY3h5vkK0ScE4DctWS4uSdL8tgfy40W/TyZpjRd2uHnSJkpbf/Amg==
|
||||||
|
-----END AGE ENCRYPTED FILE-----
|
||||||
|
lastmodified: "2021-06-28T07:24:04Z"
|
||||||
|
mac: ENC[AES256_GCM,data:c70mmWYksMLoDf0Ok+fXz0QYot/x4UTptsrAfgaMJ8Zba50OuvDhashvSfngtmzoXV0wYH0OK7uk0+JwIPV/6dC+6/qOw66Zpt1AF6fZ6FjayNXsdwuyzrG+ykYNS5PmlNm+U54CmGkCG/NdJ33dC1sfEzX6giL5cgSsjXA7FJw=,iv:sEFBzWFvjmR7czlAeNyKpB7uXgL6TBi+9t67Bn5xL/0=,tag:cGBLLp0BOQHZerbdvF/y0g==,type:str]
|
||||||
|
pgp: []
|
||||||
|
encrypted_suffix: secret
|
||||||
|
version: 3.7.1
|
69
stdlib/java/maven/maven.cue
Normal file
69
stdlib/java/maven/maven.cue
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
// Maven is a build automation tool for Java
|
||||||
|
package maven
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"alpha.dagger.io/dagger"
|
||||||
|
"alpha.dagger.io/alpine"
|
||||||
|
"alpha.dagger.io/os"
|
||||||
|
)
|
||||||
|
|
||||||
|
// A Maven project
|
||||||
|
#Project: {
|
||||||
|
|
||||||
|
// Application source code
|
||||||
|
source: dagger.#Artifact @dagger(input)
|
||||||
|
|
||||||
|
// Extra alpine packages to install
|
||||||
|
package: {
|
||||||
|
[string]: true | false | string
|
||||||
|
} @dagger(input)
|
||||||
|
|
||||||
|
// Environment variables
|
||||||
|
env: {
|
||||||
|
[string]: string
|
||||||
|
} @dagger(input)
|
||||||
|
|
||||||
|
phases: [...string] | *["package"] @dagger(input)
|
||||||
|
goals: [...string] | *[] @dagger(input)
|
||||||
|
|
||||||
|
// Optional arguments for the script
|
||||||
|
args: [...string] | *[] @dagger(input)
|
||||||
|
|
||||||
|
// Build output directory
|
||||||
|
build: os.#Dir & {
|
||||||
|
from: ctr
|
||||||
|
path: "/build"
|
||||||
|
} @dagger(output)
|
||||||
|
|
||||||
|
ctr: os.#Container & {
|
||||||
|
image: alpine.#Image & {
|
||||||
|
"package": package & {
|
||||||
|
bash: "=~5.1"
|
||||||
|
openjdk11: "=~11.0.9"
|
||||||
|
maven: "=~3.6.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
shell: path: "/bin/bash"
|
||||||
|
command: """
|
||||||
|
opts=( $(echo $MAVEN_ARGS) )
|
||||||
|
mvn $MAVEN_GOALS $MAVEN_PHASES ${opts[@]}
|
||||||
|
result=$?
|
||||||
|
modules=$(mvn -Dexec.executable='pwd' -Dexec.args='${project.artifactId}' exec:exec -q)
|
||||||
|
for module in $modules;do
|
||||||
|
source=$(echo "$module/target" | tr -s /)
|
||||||
|
target=$(echo "/build/$module" | tr -s /)
|
||||||
|
mkdir -p $target;cp -a $source $target 2>/dev/null || :
|
||||||
|
done
|
||||||
|
exit $result
|
||||||
|
"""
|
||||||
|
"env": env & {
|
||||||
|
MAVEN_ARGS: strings.Join(args, "\n")
|
||||||
|
MAVEN_PHASES: strings.Join(phases, "\n")
|
||||||
|
MAVEN_GOALS: strings.Join(goals, "\n")
|
||||||
|
}
|
||||||
|
dir: "/"
|
||||||
|
mount: "/": from: source
|
||||||
|
}
|
||||||
|
}
|
43
stdlib/java/maven/tests/maven.cue
Normal file
43
stdlib/java/maven/tests/maven.cue
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
package maven
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"alpha.dagger.io/dagger"
|
||||||
|
"alpha.dagger.io/alpine"
|
||||||
|
"alpha.dagger.io/os"
|
||||||
|
)
|
||||||
|
|
||||||
|
TestData: dagger.#Artifact
|
||||||
|
|
||||||
|
TestConfig: mavenOpts: strings.Join([
|
||||||
|
"-client",
|
||||||
|
"-XX:+TieredCompilation",
|
||||||
|
"-XX:TieredStopAtLevel=1",
|
||||||
|
"-Xverify:none",
|
||||||
|
"-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -Dorg.slf4j.simpleLogger.showDateTime=true",
|
||||||
|
"-Dorg.slf4j.simpleLogger.showDateTime=true -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss",
|
||||||
|
], " ")
|
||||||
|
|
||||||
|
TestSpringBoot: {
|
||||||
|
project: #Project & {
|
||||||
|
source: TestData
|
||||||
|
|
||||||
|
phases: ["install"]
|
||||||
|
|
||||||
|
env: MAVEN_OPTS: TestConfig.mavenOpts
|
||||||
|
|
||||||
|
args: ["--batch-mode"]
|
||||||
|
}
|
||||||
|
|
||||||
|
test: os.#Container & {
|
||||||
|
image: alpine.#Image & {
|
||||||
|
package: bash: "=5.1.0-r0"
|
||||||
|
}
|
||||||
|
copy: "/build": from: project.build
|
||||||
|
command: """
|
||||||
|
count=$(ls -1 /build/**/*.jar 2>/dev/null | wc -l)
|
||||||
|
test "$count" != "0"
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
33
stdlib/java/maven/tests/testdata/.gitignore
vendored
Normal file
33
stdlib/java/maven/tests/testdata/.gitignore
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
HELP.md
|
||||||
|
target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
!**/src/main/**/target/
|
||||||
|
!**/src/test/**/target/
|
||||||
|
|
||||||
|
### STS ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
build/
|
||||||
|
!**/src/main/**/build/
|
||||||
|
!**/src/test/**/build/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
41
stdlib/java/maven/tests/testdata/pom.xml
vendored
Normal file
41
stdlib/java/maven/tests/testdata/pom.xml
vendored
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>2.5.2</version>
|
||||||
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
|
</parent>
|
||||||
|
<groupId>io.dagger.maven</groupId>
|
||||||
|
<artifactId>spring-boot-test</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<name>spring-boot-test</name>
|
||||||
|
<description>Dagger maven spring boot test</description>
|
||||||
|
<properties>
|
||||||
|
<java.version>11</java.version>
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
@ -0,0 +1,13 @@
|
|||||||
|
package io.dagger.maven.springboottest;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
public class SpringBootTestApplication {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(SpringBootTestApplication.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
1
stdlib/java/maven/tests/testdata/src/main/resources/application.properties
vendored
Normal file
1
stdlib/java/maven/tests/testdata/src/main/resources/application.properties
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
@ -0,0 +1,13 @@
|
|||||||
|
package io.dagger.maven.springboottest;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
@SpringBootTest
|
||||||
|
class SpringBootTestApplicationTests {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void contextLoads() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -21,6 +21,10 @@ setup() {
|
|||||||
dagger -e js-yarn up
|
dagger -e js-yarn up
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "java/maven" {
|
||||||
|
dagger -e java-maven up
|
||||||
|
}
|
||||||
|
|
||||||
@test "alpine" {
|
@test "alpine" {
|
||||||
dagger -e alpine up
|
dagger -e alpine up
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user