createProperties(NisseConfiguration configuration);
21 | }
22 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/it-dynamic-versioning-scm-tag-0-commits-0-tags/verify.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | // check that property was set
9 |
10 | def mavenLogFile = new File(basedir, 'build.log')
11 | assert mavenLogFile.exists() : "Maven log file does not exist"
12 |
13 | // Read the log file
14 | def logContent = mavenLogFile.text
15 |
16 | // Define a pattern to match the version output
17 | def versionPattern = /org.eclipse.jgit.api.errors.NoHeadException: No HEAD exists and no explicit starting revision was specified/
18 | def matcher = (logContent =~ versionPattern)
19 | assert matcher.find() : "SCM repo should have no head/commits"
20 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/it-dynamic-versioning-scm-tag-1-commit-0-tags/setup.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | void exec(String command) {
9 | def proc = command.execute(null, basedir)
10 | proc.consumeProcessOutput(System.out, System.out)
11 | proc.waitFor()
12 | assert proc.exitValue() == 0 : "Command '${command}' returned status: ${proc.exitValue()}"
13 | }
14 |
15 | def testFile = new File(basedir, 'test.txt')
16 | testFile << 'content'
17 |
18 | exec('git init')
19 | exec('git config user.email "you@example.com"')
20 | exec('git config user.name "Your Name"')
21 |
22 | exec('git add test.txt')
23 | exec('git commit -m initial-commit')
24 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/it-dynamic-versioning-scm-tag-param-use-versions/setup.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | void exec(String command) {
9 | def proc = command.execute(null, basedir)
10 | proc.consumeProcessOutput(System.out, System.out)
11 | proc.waitFor()
12 | assert proc.exitValue() == 0 : "Command '${command}' returned status: ${proc.exitValue()}"
13 | }
14 |
15 | def testFile = new File(basedir, 'test.txt')
16 | testFile << 'content'
17 |
18 | exec('git init')
19 | exec('git config user.email "you@example.com"')
20 | exec('git config user.name "Your Name"')
21 |
22 | exec('git add test.txt')
23 | exec('git commit -m initial-commit')
24 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/it-dynamic-versioning-scm-tag-param-append-snapshot/setup.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | void exec(String command) {
9 | def proc = command.execute(null, basedir)
10 | proc.consumeProcessOutput(System.out, System.out)
11 | proc.waitFor()
12 | assert proc.exitValue() == 0 : "Command '${command}' returned status: ${proc.exitValue()}"
13 | }
14 |
15 | def testFile = new File(basedir, 'test.txt')
16 | testFile << 'content'
17 |
18 | exec('git init')
19 | exec('git config user.email "you@example.com"')
20 | exec('git config user.name "Your Name"')
21 |
22 | exec('git add test.txt')
23 | exec('git commit -m initial-commit')
24 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/it-dynamic-versioning-scm-tag-1-commit-0-tags/pom.xml:
--------------------------------------------------------------------------------
1 |
10 |
13 | 4.0.0
14 | localhost
15 | it-dynamic-versioning-scm-tag-1-commit-0-tags
16 | ${nisse.jgit.dynamicVersion}
17 | pom
18 | ranges-update-report
19 | http://localhost/
20 |
21 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/it-dynamic-versioning-version-hint-custom/pom.xml:
--------------------------------------------------------------------------------
1 |
10 |
13 | 4.0.0
14 | localhost
15 | it-dynamic-versioning-version-hint-custom
16 | ${nisse.jgit.dynamicVersion}
17 | pom
18 | version-hint-custom-test
19 | http://localhost/
20 |
21 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/it-dynamic-versioning-scm-tag-0-commits-0-tags/pom.xml:
--------------------------------------------------------------------------------
1 |
10 |
13 | 4.0.0
14 | localhost
15 | it-dynamic-versioning-scm-tag-0-commits-0-tags
16 | ${nisse.jgit.dynamicVersion}
17 | pom
18 | ranges-update-report
19 | http://localhost/
20 |
21 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/it-dynamic-versioning-scm-tag-4-commits-1-vtag/pom.xml:
--------------------------------------------------------------------------------
1 |
10 |
13 | 4.0.0
14 | localhost
15 | it-dynamic-versioning-scm-tag-4-commits-1-vtag
16 | ${nisse.jgit.dynamicVersion}
17 | pom
18 | ranges-update-report
19 | http://localhost/
20 |
21 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/it-dynamic-versioning-version-hint-snapshot/pom.xml:
--------------------------------------------------------------------------------
1 |
10 |
13 | 4.0.0
14 | localhost
15 | it-dynamic-versioning-version-hint-snapshot
16 | ${nisse.jgit.dynamicVersion}
17 | pom
18 | version-hint-snapshot-test
19 | http://localhost/
20 |
21 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/it-dynamic-versioning-scm-tag-param-use-versions/pom.xml:
--------------------------------------------------------------------------------
1 |
10 |
13 | 4.0.0
14 | localhost
15 | it-dynamic-versioning-scm-tag-param-use-versions
16 | ${nisse.jgit.dynamicVersion}
17 | pom
18 | ranges-update-report
19 | http://localhost/
20 |
21 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/it-dynamic-versioning-scm-tag-param-append-snapshot/pom.xml:
--------------------------------------------------------------------------------
1 |
10 |
13 | 4.0.0
14 | localhost
15 | it-dynamic-versioning-scm-tag-param-append-snapshot
16 | ${nisse.jgit.dynamicVersion}
17 | pom
18 | ranges-update-report
19 | http://localhost/
20 |
21 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/it-dynamic-versioning-scm-tag-latest-commit-annotated-vtag/pom.xml:
--------------------------------------------------------------------------------
1 |
10 |
13 | 4.0.0
14 | localhost
15 | it-dynamic-versioning-scm-tag-latest-commit-annotated-vtag
16 | ${nisse.jgit.dynamicVersion}
17 | pom
18 | ranges-update-report
19 | http://localhost/
20 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/it-dynamic-versioning-scm-tag-latest-commit-lightweight-vtag/pom.xml:
--------------------------------------------------------------------------------
1 |
10 |
13 | 4.0.0
14 | localhost
15 | it-dynamic-versioning-scm-tag-latest-commit-lightweight-vtag
16 | ${nisse.jgit.dynamicVersion}
17 | pom
18 | ranges-update-report
19 | http://localhost/
20 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/it-dynamic-versioning-version-hint-vs-release-tags/pom.xml:
--------------------------------------------------------------------------------
1 |
10 |
13 | 4.0.0
14 | localhost
15 | it-dynamic-versioning-version-hint-vs-release-tags
16 | ${nisse.jgit.dynamicVersion}
17 | pom
18 | version-hint-vs-release-tags-test
19 | http://localhost/
20 |
21 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/it-dynamic-versioning-scm-tag-latest-commit-lightweight-vtag/setup.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | void exec(String command) {
9 | def proc = command.execute(null, basedir)
10 | proc.consumeProcessOutput(System.out, System.out)
11 | proc.waitFor()
12 | assert proc.exitValue() == 0 : "Command '${command}' returned status: ${proc.exitValue()}"
13 | }
14 |
15 | def testFile = new File(basedir, 'test.txt')
16 | testFile << 'content'
17 |
18 | exec('git init')
19 | exec('git config user.email "you@example.com"')
20 | exec('git config user.name "Your Name"')
21 |
22 | exec('git add test.txt')
23 | exec('git commit -m initial-commit')
24 | exec('git tag v1.1.1')
25 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/translated/verify.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | File buildLog = new File( basedir, 'build.log' )
9 | assert buildLog.exists()
10 | assert buildLog.text.contains ('os.detected.name')
11 | assert buildLog.text.contains ('os.detected.arch')
12 | assert buildLog.text.contains ('os.detected.bitness')
13 | assert buildLog.text.contains ('os.detected.classifier')
14 |
15 | // alt keys
16 | assert buildLog.text.contains ('something.else.name')
17 | assert buildLog.text.contains ('another.arch')
18 |
19 | // falback applied as well to some
20 | assert buildLog.text.contains ('nisse.os.bitness')
21 |
22 | // removed
23 | assert !buildLog.text.contains ('nisse.os.version.minor')
24 |
--------------------------------------------------------------------------------
/it/extension4-its/src/it/translated/verify.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | File buildLog = new File( basedir, 'build.log' )
9 | assert buildLog.exists()
10 | assert buildLog.text.contains ('os.detected.name')
11 | assert buildLog.text.contains ('os.detected.arch')
12 | assert buildLog.text.contains ('os.detected.bitness')
13 | assert buildLog.text.contains ('os.detected.classifier')
14 |
15 | // alt keys
16 | assert buildLog.text.contains ('something.else.name')
17 | assert buildLog.text.contains ('another.arch')
18 |
19 | // falback applied as well to some
20 | assert buildLog.text.contains ('nisse.os.bitness')
21 |
22 | // removed
23 | assert !buildLog.text.contains ('nisse.os.version.minor')
24 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/smoke/mod1/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 |
15 | eu.maveniverse.maven.nisse.it.smoke
16 | smoke
17 | 0.1.0-SNAPSHOT
18 |
19 |
20 | mod1
21 |
22 | ${project.groupId}:${project.artifactId}
23 |
24 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/smoke/mod2/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 |
15 | eu.maveniverse.maven.nisse.it.smoke
16 | smoke
17 | 0.1.0-SNAPSHOT
18 |
19 |
20 | mod2
21 |
22 | ${project.groupId}:${project.artifactId}
23 |
24 |
--------------------------------------------------------------------------------
/it/extension4-its/src/it/smoke/mod1/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 |
15 | eu.maveniverse.maven.nisse.it.smoke
16 | smoke
17 | 0.1.0-SNAPSHOT
18 |
19 |
20 | mod1
21 |
22 | ${project.groupId}:${project.artifactId}
23 |
24 |
--------------------------------------------------------------------------------
/it/extension4-its/src/it/smoke/mod2/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 |
15 | eu.maveniverse.maven.nisse.it.smoke
16 | smoke
17 | 0.1.0-SNAPSHOT
18 |
19 |
20 | mod2
21 |
22 | ${project.groupId}:${project.artifactId}
23 |
24 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/ci-friendly/mod1/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 |
15 | eu.maveniverse.maven.nisse.it.ci-friendly
16 | ci-friendly
17 | ${nisse.jgit.commit}
18 |
19 |
20 | mod1
21 |
22 | ${project.groupId}:${project.artifactId}
23 |
24 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/ci-friendly/mod2/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 |
15 | eu.maveniverse.maven.nisse.it.ci-friendly
16 | ci-friendly
17 | ${nisse.jgit.commit}
18 |
19 |
20 | mod2
21 |
22 | ${project.groupId}:${project.artifactId}
23 |
24 |
--------------------------------------------------------------------------------
/it/extension4-its/src/it/ci-friendly/mod1/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 |
15 | eu.maveniverse.maven.nisse.it.ci-friendly
16 | ci-friendly
17 | ${nisse.jgit.commit}
18 |
19 |
20 | mod1
21 |
22 | ${project.groupId}:${project.artifactId}
23 |
24 |
--------------------------------------------------------------------------------
/it/extension4-its/src/it/ci-friendly/mod2/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 |
15 | eu.maveniverse.maven.nisse.it.ci-friendly
16 | ci-friendly
17 | ${nisse.jgit.commit}
18 |
19 |
20 | mod2
21 |
22 | ${project.groupId}:${project.artifactId}
23 |
24 |
--------------------------------------------------------------------------------
/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 | wrapperVersion=3.3.2
18 | distributionType=only-script
19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.12/apache-maven-3.9.12-bin.zip
20 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/it-dynamic-versioning-scm-tag-latest-commit-annotated-vtag/setup.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | void exec(String[] command) {
9 | def proc = command.execute(null, basedir)
10 | proc.consumeProcessOutput(System.out, System.out)
11 | proc.waitFor()
12 | assert proc.exitValue() == 0 : "Command '${command}' returned status: ${proc.exitValue()}"
13 | }
14 |
15 | def testFile = new File(basedir, 'test.txt')
16 | testFile << 'content'
17 |
18 | exec('git', 'init')
19 | exec('git', 'config', 'user.email', 'you@example.com')
20 | exec('git', 'config', 'user.name', 'Your Name')
21 |
22 | exec('git', 'add', 'test.txt')
23 | exec('git', 'commit', '-m', 'initial-commit')
24 | exec('git', 'tag', '-a', 'v1.1.1', '-m', 'v1.1.1 as annotated tag')
25 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/develocity/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 | eu.maveniverse.maven.nisse.it.smoke
15 | smoke
16 | 0.1.0-SNAPSHOT
17 |
18 | ${project.groupId}:${project.artifactId}
19 |
20 |
21 | UTF-8
22 | UTF-8
23 |
24 |
25 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/os-detector/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 | eu.maveniverse.maven.nisse.it.smoke
15 | smoke
16 | 0.1.0-SNAPSHOT
17 |
18 | ${project.groupId}:${project.artifactId}
19 |
20 |
21 | UTF-8
22 | UTF-8
23 |
24 |
25 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/translated/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 | eu.maveniverse.maven.nisse.it.smoke
15 | smoke
16 | 0.1.0-SNAPSHOT
17 |
18 | ${project.groupId}:${project.artifactId}
19 |
20 |
21 | UTF-8
22 | UTF-8
23 |
24 |
25 |
--------------------------------------------------------------------------------
/it/extension4-its/src/it/develocity/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 | eu.maveniverse.maven.nisse.it.smoke
15 | smoke
16 | 0.1.0-SNAPSHOT
17 |
18 | ${project.groupId}:${project.artifactId}
19 |
20 |
21 | UTF-8
22 | UTF-8
23 |
24 |
25 |
--------------------------------------------------------------------------------
/it/extension4-its/src/it/os-detector/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 | eu.maveniverse.maven.nisse.it.smoke
15 | smoke
16 | 0.1.0-SNAPSHOT
17 |
18 | ${project.groupId}:${project.artifactId}
19 |
20 |
21 | UTF-8
22 | UTF-8
23 |
24 |
25 |
--------------------------------------------------------------------------------
/it/extension4-its/src/it/translated/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 | eu.maveniverse.maven.nisse.it.smoke
15 | smoke
16 | 0.1.0-SNAPSHOT
17 |
18 | ${project.groupId}:${project.artifactId}
19 |
20 |
21 | UTF-8
22 | UTF-8
23 |
24 |
25 |
--------------------------------------------------------------------------------
/core/src/main/java/eu/maveniverse/maven/nisse/core/PropertySource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | package eu.maveniverse.maven.nisse.core;
9 |
10 | import java.util.Map;
11 |
12 | /**
13 | * A property source, that provides all the supported properties.
14 | */
15 | public interface PropertySource {
16 | /**
17 | * Returns the name of the property source, never {@code null}.
18 | */
19 | String getName();
20 |
21 | /**
22 | * Returns a map of provided properties, never {@code null}.
23 | *
24 | * The returned map should not contain {@code null} keys and {@code null} values, they should be
25 | * "mavenized", in a way Apache Maven does: empty values should be replaced with {@code "true"} string.
26 | */
27 | Map getProperties(NisseConfiguration configuration);
28 | }
29 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/it-dynamic-versioning-scm-tag-param-use-versions/verify.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | // check that property was set
9 |
10 | def mavenLogFile = new File(basedir, 'build.log')
11 | assert mavenLogFile.exists() : "Maven log file does not exist"
12 |
13 | // Read the log file
14 | def logContent = mavenLogFile.text
15 |
16 | // Define a pattern to match the version output
17 | def versionPattern = /\$\{nisse.jgit.dynamicVersion\}=(.+)/
18 | def matcher = (logContent =~ versionPattern)
19 | assert matcher.find() : "Version information not found in log file"
20 |
21 | // Extract the version from the matched group
22 | def actualVersion = matcher[0][1]
23 |
24 | def expectedVersion = '9.9.9-9'
25 |
26 | assert actualVersion == expectedVersion : "Expected version '${expectedVersion}', but found '${actualVersion}'"
27 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/it-dynamic-versioning-scm-tag-1-commit-0-tags/verify.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | // check that property was set
9 |
10 | def mavenLogFile = new File(basedir, 'build.log')
11 | assert mavenLogFile.exists() : "Maven log file does not exist"
12 |
13 | // Read the log file
14 | def logContent = mavenLogFile.text
15 |
16 | // Define a pattern to match the version output
17 | def versionPattern = /\$\{nisse.jgit.dynamicVersion\}=(.+)/
18 | def matcher = (logContent =~ versionPattern)
19 | assert matcher.find() : "Version information not found in log file"
20 |
21 | // Extract the version from the matched group
22 | def actualVersion = matcher[0][1]
23 |
24 | def expectedVersion = '0.1.0-1-SNAPSHOT'
25 |
26 | assert actualVersion == expectedVersion : "Expected version '${expectedVersion}', but found '${actualVersion}'"
27 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/it-dynamic-versioning-scm-tag-param-append-snapshot/verify.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | // check that property was set
9 |
10 | def mavenLogFile = new File(basedir, 'build.log')
11 | assert mavenLogFile.exists() : "Maven log file does not exist"
12 |
13 | // Read the log file
14 | def logContent = mavenLogFile.text
15 |
16 | // Define a pattern to match the version output
17 | def versionPattern = /\$\{nisse.jgit.dynamicVersion\}=(.+)/
18 | def matcher = (logContent =~ versionPattern)
19 | assert matcher.find() : "Version information not found in log file"
20 |
21 | // Extract the version from the matched group
22 | def actualVersion = matcher[0][1]
23 |
24 | def expectedVersion = '0.1.0-1'
25 |
26 | assert actualVersion == expectedVersion : "Expected version '${expectedVersion}', but found '${actualVersion}'"
27 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/it-dynamic-versioning-scm-tag-4-commits-1-vtag/verify.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | // check that property was set
9 |
10 | def mavenLogFile = new File(basedir, 'build.log')
11 | assert mavenLogFile.exists() : "Maven log file does not exist"
12 |
13 | // Read the log file
14 | def logContent = mavenLogFile.text
15 |
16 | // Define a pattern to match the version output
17 | def versionPattern = /\$\{nisse.jgit.dynamicVersion\}=(.+)/
18 | def matcher = (logContent =~ versionPattern)
19 | assert matcher.find() : "Version information not found in log file"
20 |
21 | // Extract the version from the matched group
22 | def actualVersion = matcher[0][1]
23 |
24 | def expectedVersion = '1.1.2-3-SNAPSHOT'
25 |
26 | assert actualVersion == expectedVersion : "Expected version '${expectedVersion}', but found '${actualVersion}'"
27 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/it-dynamic-versioning-scm-tag-latest-commit-annotated-vtag/verify.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | // check that property was set
9 |
10 | def mavenLogFile = new File(basedir, 'build.log')
11 | assert mavenLogFile.exists() : "Maven log file does not exist"
12 |
13 | // Read the log file
14 | def logContent = mavenLogFile.text
15 |
16 | // Define a pattern to match the version output
17 | def versionPattern = /\$\{nisse.jgit.dynamicVersion\}=(.+)/
18 | def matcher = (logContent =~ versionPattern)
19 | assert matcher.find() : "Version information not found in log file"
20 |
21 | // Extract the version from the matched group
22 | def actualVersion = matcher[0][1]
23 |
24 | def expectedVersion = '1.1.1'
25 |
26 | assert actualVersion == expectedVersion : "Expected version '${expectedVersion}', but found '${actualVersion}'"
27 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/it-dynamic-versioning-scm-tag-latest-commit-lightweight-vtag/verify.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | // check that property was set
9 |
10 | def mavenLogFile = new File(basedir, 'build.log')
11 | assert mavenLogFile.exists() : "Maven log file does not exist"
12 |
13 | // Read the log file
14 | def logContent = mavenLogFile.text
15 |
16 | // Define a pattern to match the version output
17 | def versionPattern = /\$\{nisse.jgit.dynamicVersion\}=(.+)/
18 | def matcher = (logContent =~ versionPattern)
19 | assert matcher.find() : "Version information not found in log file"
20 |
21 | // Extract the version from the matched group
22 | def actualVersion = matcher[0][1]
23 |
24 | def expectedVersion = '1.1.1'
25 |
26 | assert actualVersion == expectedVersion : "Expected version '${expectedVersion}', but found '${actualVersion}'"
27 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/jgit-dynamicVersion/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 | eu.maveniverse.maven.nisse.it.dynamic
15 | dynamic
16 | ${nisse.jgit.dynamicVersion}
17 | pom
18 |
19 | ${project.groupId}:${project.artifactId}
20 |
21 |
22 | UTF-8
23 | UTF-8
24 |
25 |
26 |
--------------------------------------------------------------------------------
/it/extension4-its/src/it/jgit-dynamicVersion/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 | eu.maveniverse.maven.nisse.it.dynamic
15 | dynamic
16 | ${nisse.jgit.dynamicVersion}
17 | pom
18 |
19 | ${project.groupId}:${project.artifactId}
20 |
21 |
22 | UTF-8
23 | UTF-8
24 |
25 |
26 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/configured-inline/verify.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | import java.util.regex.Matcher
9 | import java.util.regex.Pattern
10 |
11 | File buildLog = new File( basedir, 'build.log' )
12 | assert buildLog.exists()
13 | String buildLogString = buildLog.text
14 | assert buildLogString.contains ('Nisse injecting 3 properties into User Properties')
15 |
16 | String[] paths = new String[]{
17 | "eu/maveniverse/maven/nisse/it/configured-inline/configured-inline/1.0/configured-inline-1.0.pom",
18 | "eu/maveniverse/maven/nisse/it/configured-inline/mod1/1.0/mod1-1.0.pom",
19 | "eu/maveniverse/maven/nisse/it/configured-inline/mod2/1.0/mod2-1.0.pom",
20 | }
21 |
22 | for (String path : paths) {
23 | File pomPath = new File(localRepositoryPath, path)
24 | assert pomPath.exists()
25 | String pomXml = pomPath.text
26 | assert !pomXml.contains('${nisse.file.')
27 | }
--------------------------------------------------------------------------------
/sources/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 |
15 | eu.maveniverse.maven.nisse
16 | nisse
17 | 0.6.4-SNAPSHOT
18 |
19 |
20 | eu.maveniverse.maven.nisse.sources
21 | sources
22 | pom
23 |
24 | ${project.groupId}:${project.artifactId}
25 |
26 |
27 | file-source
28 | jgit-source
29 | mvn-source
30 | os-source
31 |
32 |
33 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/it-dynamic-versioning-version-hint-snapshot/verify.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | // check that property was set
9 |
10 | def mavenLogFile = new File(basedir, 'build.log')
11 | assert mavenLogFile.exists() : "Maven log file does not exist"
12 |
13 | // Read the log file
14 | def logContent = mavenLogFile.text
15 |
16 | // Define a pattern to match the version output
17 | def versionPattern = /\$\{nisse.jgit.dynamicVersion\}=(.+)/
18 | def matcher = (logContent =~ versionPattern)
19 | assert matcher.find() : "Version information not found in log file"
20 |
21 | // Extract the version from the matched group
22 | def actualVersion = matcher[0][1]
23 |
24 | // Should use the highest version hint tag (4.2.0) and add SNAPSHOT since we're ahead
25 | def expectedVersion = '4.2.0-SNAPSHOT'
26 |
27 | assert actualVersion == expectedVersion : "Expected version '${expectedVersion}', but found '${actualVersion}'"
28 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/smoke/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 | eu.maveniverse.maven.nisse.it.smoke
15 | smoke
16 | 0.1.0-SNAPSHOT
17 | pom
18 |
19 | ${project.groupId}:${project.artifactId}
20 |
21 |
22 | UTF-8
23 | UTF-8
24 |
25 |
26 |
27 | mod1
28 | mod2
29 |
30 |
31 |
--------------------------------------------------------------------------------
/it/extension4-its/src/it/smoke/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 | eu.maveniverse.maven.nisse.it.smoke
15 | smoke
16 | 0.1.0-SNAPSHOT
17 | pom
18 |
19 | ${project.groupId}:${project.artifactId}
20 |
21 |
22 | UTF-8
23 | UTF-8
24 |
25 |
26 |
27 | mod1
28 | mod2
29 |
30 |
31 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/configured-inline/mod2/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 |
15 | eu.maveniverse.maven.nisse.it.configured-inline
16 | configured-inline
17 | 1.0
18 |
19 |
20 | mod2
21 |
22 | ${project.groupId}:${project.artifactId}
23 |
24 |
25 |
26 | santa
27 |
28 | ${nisse.file.size}
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/ci-friendly/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 | eu.maveniverse.maven.nisse.it.ci-friendly
15 | ci-friendly
16 | ${nisse.jgit.commit}
17 | pom
18 |
19 | ${project.groupId}:${project.artifactId}
20 |
21 |
22 | UTF-8
23 | UTF-8
24 |
25 |
26 |
27 | mod1
28 | mod2
29 |
30 |
31 |
--------------------------------------------------------------------------------
/it/extension4-its/src/it/ci-friendly/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 | eu.maveniverse.maven.nisse.it.ci-friendly
15 | ci-friendly
16 | ${nisse.jgit.commit}
17 | pom
18 |
19 | ${project.groupId}:${project.artifactId}
20 |
21 |
22 | UTF-8
23 | UTF-8
24 |
25 |
26 |
27 | mod1
28 | mod2
29 |
30 |
31 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/it-dynamic-versioning-scm-tag-4-commits-1-vtag/setup.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | void exec(String command) {
9 | def proc = command.execute(null, basedir)
10 | proc.consumeProcessOutput(System.out, System.out)
11 | proc.waitFor()
12 | assert proc.exitValue() == 0 : "Command '${command}' returned status: ${proc.exitValue()}"
13 | }
14 |
15 | def testFile = new File(basedir, 'test.txt')
16 | testFile << 'content'
17 |
18 | exec('git init')
19 | exec('git config user.email "you@example.com"')
20 | exec('git config user.name "Your Name"')
21 |
22 | exec('git add test.txt')
23 | exec('git commit -m initial-commit')
24 | exec('git tag 1.1.1')
25 | exec('git tag')
26 |
27 | testFile << 'content2'
28 | exec('git add test.txt')
29 | exec('git commit -m commit_no2')
30 |
31 | testFile << 'content3'
32 | exec('git add test.txt')
33 | exec('git commit -m commit_no3')
34 |
35 | testFile << 'content4'
36 | exec('git add test.txt')
37 | exec('git commit -m commit_no4')
38 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/it-dynamic-versioning-version-hint-custom/verify.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | // check that property was set
9 |
10 | def mavenLogFile = new File(basedir, 'build.log')
11 | assert mavenLogFile.exists() : "Maven log file does not exist"
12 |
13 | // Read the log file
14 | def logContent = mavenLogFile.text
15 |
16 | // Define a pattern to match the version output
17 | def versionPattern = /\$\{nisse.jgit.dynamicVersion\}=(.+)/
18 | def matcher = (logContent =~ versionPattern)
19 | assert matcher.find() : "Version information not found in log file"
20 |
21 | // Extract the version from the matched group
22 | def actualVersion = matcher[0][1]
23 |
24 | // Should use the highest version hint tag with custom pattern (3.2.0) and add SNAPSHOT since we're ahead
25 | // The 5.0.0-SNAPSHOT tag should be ignored because it doesn't match "hint-${version}" pattern
26 | def expectedVersion = '3.2.0-SNAPSHOT'
27 |
28 | assert actualVersion == expectedVersion : "Expected version '${expectedVersion}', but found '${actualVersion}'"
29 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/configured-inline/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 | eu.maveniverse.maven.nisse.it.configured-inline
15 | configured-inline
16 | 1.0
17 | pom
18 |
19 | ${project.groupId}:${project.artifactId}
20 |
21 |
22 | UTF-8
23 | UTF-8
24 |
25 | ${nisse.file.color}
26 |
27 |
28 |
29 | mod1
30 | mod2
31 |
32 |
33 |
--------------------------------------------------------------------------------
/sources/file-source/src/test/java/eu/maveniverse/maven/nisse/source/file/PropertyFilePropertySourceTest.java:
--------------------------------------------------------------------------------
1 | package eu.maveniverse.maven.nisse.source.file;
2 |
3 | import eu.maveniverse.maven.nisse.core.simple.SimpleNisseConfiguration;
4 | import java.nio.file.Files;
5 | import java.nio.file.Path;
6 | import java.util.Arrays;
7 | import java.util.HashMap;
8 | import org.junit.jupiter.api.Test;
9 | import org.junit.jupiter.api.io.TempDir;
10 |
11 | public class PropertyFilePropertySourceTest {
12 | @Test
13 | void smoke(@TempDir Path tempDir) throws Exception {
14 | Path propertyFile = tempDir.resolve("property.properties");
15 | Files.write(propertyFile, Arrays.asList("one=en", "two=to", "three=tre"));
16 | try {
17 | HashMap conf = new HashMap<>();
18 | conf.put(
19 | PropertyFilePropertySource.FILE_NAME,
20 | propertyFile.toAbsolutePath().toString());
21 | new PropertyFilePropertySource()
22 | .getProperties(SimpleNisseConfiguration.builder()
23 | .withUserProperties(conf)
24 | .build())
25 | .forEach((k, v) -> System.out.println(k + " = " + v));
26 | } finally {
27 | System.clearProperty(PropertyFilePropertySource.FILE_NAME);
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/it-dynamic-versioning-version-hint-snapshot/setup.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | void exec(String command) {
9 | def proc = command.execute(null, basedir)
10 | proc.consumeProcessOutput(System.out, System.out)
11 | proc.waitFor()
12 | assert proc.exitValue() == 0 : "Command '${command}' returned status: ${proc.exitValue()}"
13 | }
14 |
15 | def testFile = new File(basedir, 'test.txt')
16 | testFile << 'content'
17 |
18 | exec('git init')
19 | exec('git config user.email "you@example.com"')
20 | exec('git config user.name "Your Name"')
21 |
22 | exec('git add test.txt')
23 | exec('git commit -m initial-commit')
24 |
25 | // Create a version hint tag for 4.1.0
26 | exec('git tag 4.1.0-SNAPSHOT')
27 |
28 | // Add another commit to move HEAD away from the tag
29 | testFile << '\nmore content'
30 | exec('git add test.txt')
31 | exec('git commit -m second-commit')
32 |
33 | // Create another version hint tag for 4.2.0 (should be the highest)
34 | exec('git tag 4.2.0-SNAPSHOT')
35 |
36 | // Add one more commit
37 | testFile << '\neven more content'
38 | exec('git add test.txt')
39 | exec('git commit -m third-commit')
40 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/configured-inline/mod1/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 |
15 | eu.maveniverse.maven.nisse.it.configured-inline
16 | configured-inline
17 | 1.0
18 |
19 |
20 | mod1
21 |
22 | ${project.groupId}:${project.artifactId}
23 |
24 |
25 |
26 |
27 | org.apache.maven.plugins
28 | maven-clean-plugin
29 | 3.4.0
30 |
31 | ${nisse.file.weight}
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/it-dynamic-versioning-version-hint-custom/setup.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | void exec(String command) {
9 | def proc = command.execute(null, basedir)
10 | proc.consumeProcessOutput(System.out, System.out)
11 | proc.waitFor()
12 | assert proc.exitValue() == 0 : "Command '${command}' returned status: ${proc.exitValue()}"
13 | }
14 |
15 | def testFile = new File(basedir, 'test.txt')
16 | testFile << 'content'
17 |
18 | exec('git init')
19 | exec('git config user.email "you@example.com"')
20 | exec('git config user.name "Your Name"')
21 |
22 | exec('git add test.txt')
23 | exec('git commit -m initial-commit')
24 |
25 | // Create version hint tags using custom pattern "hint-${version}"
26 | exec('git tag hint-3.1.0')
27 |
28 | // Add another commit
29 | testFile << '\nmore content'
30 | exec('git add test.txt')
31 | exec('git commit -m second-commit')
32 |
33 | // Create another version hint tag (should be the highest)
34 | exec('git tag hint-3.2.0')
35 |
36 | // Create a regular SNAPSHOT tag that should be ignored with custom pattern
37 | exec('git tag 5.0.0-SNAPSHOT')
38 |
39 | // Add one more commit
40 | testFile << '\neven more content'
41 | exec('git add test.txt')
42 | exec('git commit -m third-commit')
43 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/ci-friendly/verify.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | import java.util.regex.Matcher
9 | import java.util.regex.Pattern
10 |
11 | File buildLog = new File( basedir, 'build.log' )
12 | assert buildLog.exists()
13 | String buildLogString = buildLog.text
14 |
15 | String placeholder = '${nisse.jgit.commit}'
16 | assert buildLogString.contains (placeholder)
17 |
18 | String search = placeholder + "="
19 | int commitHashStart = buildLogString.indexOf(search) + search.length()
20 | assert commitHashStart > -1
21 | String commitHash = buildLogString.substring(commitHashStart, commitHashStart + 40)
22 | assert commitHash != null
23 | System.out.println(commitHash)
24 |
25 | String[] paths = new String[]{
26 | "eu/maveniverse/maven/nisse/it/ci-friendly/ci-friendly/${commitHash}/ci-friendly-${commitHash}.pom",
27 | "eu/maveniverse/maven/nisse/it/ci-friendly/mod1/${commitHash}/mod1-${commitHash}.pom",
28 | "eu/maveniverse/maven/nisse/it/ci-friendly/mod2/${commitHash}/mod2-${commitHash}.pom"
29 | }
30 |
31 | for (String path : paths) {
32 | File pomPath = new File(localRepositoryPath, path)
33 | assert pomPath.exists()
34 | String pomXml = pomPath.text
35 | assert pomXml.contains(commitHash)
36 | assert !pomXml.contains(placeholder)
37 | }
--------------------------------------------------------------------------------
/it/extension4-its/src/it/ci-friendly/verify.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | import java.util.regex.Matcher
9 | import java.util.regex.Pattern
10 |
11 | File buildLog = new File( basedir, 'build.log' )
12 | assert buildLog.exists()
13 | String buildLogString = buildLog.text
14 |
15 | String placeholder = 'nisse.jgit.commit'
16 | // assert buildLogString.contains (placeholder)
17 |
18 | String search = placeholder + "="
19 | int commitHashStart = buildLogString.indexOf(search) + search.length()
20 | assert commitHashStart > -1
21 | String commitHash = buildLogString.substring(commitHashStart, commitHashStart + 40)
22 | assert commitHash != null
23 | System.out.println(commitHash)
24 |
25 | String[] paths = new String[]{
26 | "eu/maveniverse/maven/nisse/it/ci-friendly/ci-friendly/${commitHash}/ci-friendly-${commitHash}.pom",
27 | "eu/maveniverse/maven/nisse/it/ci-friendly/mod1/${commitHash}/mod1-${commitHash}.pom",
28 | "eu/maveniverse/maven/nisse/it/ci-friendly/mod2/${commitHash}/mod2-${commitHash}.pom"
29 | }
30 |
31 | for (String path : paths) {
32 | File pomPath = new File(localRepositoryPath, path)
33 | assert pomPath.exists()
34 | String pomXml = pomPath.text
35 | assert pomXml.contains(commitHash)
36 | assert !pomXml.contains(placeholder)
37 | }
--------------------------------------------------------------------------------
/sources/mvn-source/src/test/java/eu/maveniverse/maven/nisse/source/mvn/MvnPropertySourceTest.java:
--------------------------------------------------------------------------------
1 | package eu.maveniverse.maven.nisse.source.mvn;
2 |
3 | import eu.maveniverse.maven.nisse.core.simple.SimpleNisseConfiguration;
4 | import java.io.IOException;
5 | import java.nio.file.Paths;
6 | import java.util.HashMap;
7 | import java.util.Map;
8 | import org.junit.jupiter.api.Test;
9 |
10 | public class MvnPropertySourceTest {
11 | @Test
12 | void smoke() throws IOException {
13 | Map up = new HashMap<>();
14 |
15 | up.clear();
16 | up.put("maven.version", "3.9.9");
17 | up.put(
18 | "maven.home",
19 | Paths.get("src/test/resources/mvn399").toAbsolutePath().toString());
20 | System.out.println(up);
21 | new MvnPropertySource()
22 | .getProperties(SimpleNisseConfiguration.builder()
23 | .withUserProperties(up)
24 | .build())
25 | .forEach((k, v) -> System.out.println(k + " = " + v));
26 |
27 | up.clear();
28 | up.put("maven.version", "4.0.0-beta-3");
29 | up.put(
30 | "maven.home",
31 | Paths.get("src/test/resources/mvn400-beta-3").toAbsolutePath().toString());
32 | System.out.println(up);
33 | new MvnPropertySource()
34 | .getProperties(SimpleNisseConfiguration.builder()
35 | .withUserProperties(up)
36 | .build())
37 | .forEach((k, v) -> System.out.println(k + " = " + v));
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/it-dynamic-versioning-version-hint-vs-release-tags/verify.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | // check that property was set
9 |
10 | def mavenLogFile = new File(basedir, 'build.log')
11 | assert mavenLogFile.exists() : "Maven log file does not exist"
12 |
13 | // Read the log file
14 | def logContent = mavenLogFile.text
15 |
16 | // Define a pattern to match the version output
17 | def versionPattern = /\$\{nisse.jgit.dynamicVersion\}=(.+)/
18 | def matcher = (logContent =~ versionPattern)
19 | assert matcher.find() : "Version information not found in log file"
20 |
21 | // Extract the version from the matched group
22 | def actualVersion = matcher[0][1]
23 |
24 | // Should use the higher release tag version (0.13.1-1-SNAPSHOT) instead of the old hint tag (0.9.2-SNAPSHOT)
25 | // The version should be 0.13.1-1-SNAPSHOT because:
26 | // - 0.13.0 is the latest release tag
27 | // - We're 1 commit ahead of it, so patch gets incremented to 0.13.1
28 | // - Build number is 1 (commits ahead)
29 | // - SNAPSHOT qualifier is added because we're ahead
30 | def expectedVersion = '0.13.1-1-SNAPSHOT'
31 |
32 | assert actualVersion == expectedVersion : "Expected version '${expectedVersion}', but found '${actualVersion}'. The old version hint tag (0.9.2-SNAPSHOT) should not take precedence over the newer release tag (0.13.0)."
33 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/os-detector/verify.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | File buildLog = new File( basedir, 'build.log' )
9 | assert buildLog.exists()
10 |
11 | // nisse keys
12 | assert buildLog.text.contains ('nisse.os.name')
13 | assert buildLog.text.contains ('nisse.os.arch')
14 | assert buildLog.text.contains ('nisse.os.bitness')
15 | assert buildLog.text.contains ('nisse.os.version')
16 | assert buildLog.text.contains ('nisse.os.version.major')
17 | assert buildLog.text.contains ('nisse.os.version.minor')
18 | assert buildLog.text.contains ('nisse.os.classifier')
19 | assert buildLog.text.contains ('nisse.os.release')
20 | assert buildLog.text.contains ('nisse.os.release.version')
21 |
22 | // os-detectot keys
23 | assert buildLog.text.contains ('os.detected.name')
24 | assert buildLog.text.contains ('os.detected.arch')
25 | assert buildLog.text.contains ('os.detected.bitness')
26 | assert buildLog.text.contains ('os.detected.version')
27 | assert buildLog.text.contains ('os.detected.version.major')
28 | assert buildLog.text.contains ('os.detected.version.minor')
29 | assert buildLog.text.contains ('os.detected.classifier')
30 | assert buildLog.text.contains ('os.detected.release')
31 | assert buildLog.text.contains ('os.detected.release.version')
32 |
33 | // alt keys (from translate properties)
34 | assert buildLog.text.contains ('something.else.name')
35 |
--------------------------------------------------------------------------------
/it/extension4-its/src/it/os-detector/verify.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | File buildLog = new File( basedir, 'build.log' )
9 | assert buildLog.exists()
10 |
11 | // nisse keys
12 | assert buildLog.text.contains ('nisse.os.name')
13 | assert buildLog.text.contains ('nisse.os.arch')
14 | assert buildLog.text.contains ('nisse.os.bitness')
15 | assert buildLog.text.contains ('nisse.os.version')
16 | assert buildLog.text.contains ('nisse.os.version.major')
17 | assert buildLog.text.contains ('nisse.os.version.minor')
18 | assert buildLog.text.contains ('nisse.os.classifier')
19 | assert buildLog.text.contains ('nisse.os.release')
20 | assert buildLog.text.contains ('nisse.os.release.version')
21 |
22 | // os-detectot keys
23 | assert buildLog.text.contains ('os.detected.name')
24 | assert buildLog.text.contains ('os.detected.arch')
25 | assert buildLog.text.contains ('os.detected.bitness')
26 | assert buildLog.text.contains ('os.detected.version')
27 | assert buildLog.text.contains ('os.detected.version.major')
28 | assert buildLog.text.contains ('os.detected.version.minor')
29 | assert buildLog.text.contains ('os.detected.classifier')
30 | assert buildLog.text.contains ('os.detected.release')
31 | assert buildLog.text.contains ('os.detected.release.version')
32 |
33 | // alt keys (from translate properties)
34 | assert buildLog.text.contains ('something.else.name')
35 |
--------------------------------------------------------------------------------
/sources/file-source/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 |
15 | eu.maveniverse.maven.nisse.sources
16 | sources
17 | 0.6.4-SNAPSHOT
18 |
19 |
20 | file-source
21 |
22 | ${project.groupId}:${project.artifactId}
23 |
24 |
25 |
26 |
27 | eu.maveniverse.maven.nisse
28 | core
29 |
30 |
31 | javax.inject
32 | javax.inject
33 |
34 |
35 |
36 |
37 | org.junit.jupiter
38 | junit-jupiter-api
39 | test
40 |
41 |
42 | org.slf4j
43 | slf4j-simple
44 | test
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/sources/mvn-source/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 |
15 | eu.maveniverse.maven.nisse.sources
16 | sources
17 | 0.6.4-SNAPSHOT
18 |
19 |
20 | mvn-source
21 |
22 | ${project.groupId}:${project.artifactId}
23 |
24 |
25 |
26 |
27 | eu.maveniverse.maven.nisse
28 | core
29 |
30 |
31 | javax.inject
32 | javax.inject
33 |
34 |
35 |
36 |
37 | org.junit.jupiter
38 | junit-jupiter-api
39 | test
40 |
41 |
42 | org.slf4j
43 | slf4j-simple
44 | test
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/sources/os-source/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 |
15 | eu.maveniverse.maven.nisse.sources
16 | sources
17 | 0.6.4-SNAPSHOT
18 |
19 |
20 | os-source
21 |
22 | ${project.groupId}:${project.artifactId}
23 |
24 |
25 |
26 |
27 | eu.maveniverse.maven.nisse
28 | core
29 |
30 |
31 | javax.inject
32 | javax.inject
33 |
34 |
35 |
36 |
37 | org.junit.jupiter
38 | junit-jupiter-api
39 | test
40 |
41 |
42 | org.slf4j
43 | slf4j-simple
44 | test
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/core/src/main/java/eu/maveniverse/maven/nisse/core/Version.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | package eu.maveniverse.maven.nisse.core;
9 |
10 | import static java.util.stream.Collectors.toMap;
11 |
12 | import java.io.IOException;
13 | import java.io.InputStream;
14 | import java.util.HashMap;
15 | import java.util.Map;
16 | import java.util.Properties;
17 |
18 | public final class Version {
19 | private Version() {}
20 |
21 | public static String version() {
22 | return loadClasspathProperties("eu.maveniverse.maven.nisse", "core").getOrDefault("version", "");
23 | }
24 |
25 | public static Map loadClasspathProperties(String groupId, String artifactId) {
26 | String resource = "/META-INF/maven/" + groupId + "/" + artifactId + "/pom.properties";
27 | final Properties props = new Properties();
28 | try (InputStream is = Version.class.getResourceAsStream(resource)) {
29 | if (is != null) {
30 | props.load(is);
31 | }
32 | } catch (IOException e) {
33 | // fall through
34 | }
35 | return props.entrySet().stream()
36 | .collect(toMap(
37 | e -> String.valueOf(e.getKey()),
38 | e -> String.valueOf(e.getValue()),
39 | (prev, next) -> next,
40 | HashMap::new));
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/it/extension3-its/src/it/it-dynamic-versioning-version-hint-vs-release-tags/setup.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | void exec(String command) {
9 | def proc = command.execute(null, basedir)
10 | proc.consumeProcessOutput(System.out, System.out)
11 | proc.waitFor()
12 | assert proc.exitValue() == 0 : "Command '${command}' returned status: ${proc.exitValue()}"
13 | }
14 |
15 | def testFile = new File(basedir, 'test.txt')
16 | testFile << 'content'
17 |
18 | exec('git init')
19 | exec('git config user.email "you@example.com"')
20 | exec('git config user.name "Your Name"')
21 |
22 | exec('git add test.txt')
23 | exec('git commit -m initial-commit')
24 |
25 | // Create an old version hint tag (like the issue describes: 0.9.2-SNAPSHOT from a year ago)
26 | exec('git tag 0.9.2-SNAPSHOT')
27 |
28 | // Add more commits to simulate time passing
29 | testFile << '\nmore content'
30 | exec('git add test.txt')
31 | exec('git commit -m second-commit')
32 |
33 | testFile << '\neven more content'
34 | exec('git add test.txt')
35 | exec('git commit -m third-commit')
36 |
37 | // Create a much newer release tag (like the issue describes: 0.13.0 is the latest)
38 | exec('git tag 0.13.0')
39 |
40 | // Add one more commit to move HEAD away from the release tag
41 | testFile << '\nfinal content'
42 | exec('git add test.txt')
43 | exec('git commit -m fourth-commit')
44 |
45 | // List all tags for debugging
46 | exec('git tag')
47 |
--------------------------------------------------------------------------------
/core/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 |
15 | eu.maveniverse.maven.nisse
16 | nisse
17 | 0.6.4-SNAPSHOT
18 |
19 |
20 | core
21 |
22 | ${project.groupId}:${project.artifactId}
23 |
24 |
25 |
26 |
27 | org.slf4j
28 | slf4j-api
29 |
30 |
31 | javax.inject
32 | javax.inject
33 |
34 |
35 | org.eclipse.sisu
36 | org.eclipse.sisu.inject
37 |
38 |
39 |
40 |
41 | org.junit.jupiter
42 | junit-jupiter-api
43 | test
44 |
45 |
46 | org.slf4j
47 | slf4j-simple
48 | test
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/it/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 |
15 | eu.maveniverse.maven.nisse
16 | nisse
17 | 0.6.4-SNAPSHOT
18 |
19 |
20 | eu.maveniverse.maven.nisse.it
21 | it
22 | pom
23 |
24 | ${project.groupId}:${project.artifactId}
25 |
26 |
27 | extension3-its
28 | extension4-its
29 | plugin3-its
30 |
31 |
32 |
33 | true
34 | true
35 | true
36 |
37 |
38 |
39 |
40 | run-its
41 |
42 |
43 |
44 | com.diffplug.spotless
45 | spotless-maven-plugin
46 |
47 |
48 | check
49 |
50 | check
51 |
52 | none
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/core/src/main/java/eu/maveniverse/maven/nisse/core/simple/SimpleNisseManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | package eu.maveniverse.maven.nisse.core.simple;
9 |
10 | import static java.util.Objects.requireNonNull;
11 |
12 | import eu.maveniverse.maven.nisse.core.NisseConfiguration;
13 | import eu.maveniverse.maven.nisse.core.NisseManager;
14 | import eu.maveniverse.maven.nisse.core.PropertySource;
15 | import java.util.HashMap;
16 | import java.util.List;
17 | import java.util.Map;
18 | import java.util.function.BiFunction;
19 | import javax.inject.Inject;
20 | import javax.inject.Named;
21 | import javax.inject.Singleton;
22 |
23 | @Singleton
24 | @Named
25 | public class SimpleNisseManager implements NisseManager {
26 | private final List sources;
27 |
28 | @Inject
29 | public SimpleNisseManager(List sources) {
30 | this.sources = requireNonNull(sources, "sources");
31 | }
32 |
33 | @Override
34 | public Map createProperties(NisseConfiguration configuration) {
35 | requireNonNull(configuration, "configuration");
36 | BiFunction> propertyKeyNamingStrategy =
37 | configuration.propertyKeyNamingStrategy();
38 | HashMap properties = new HashMap<>();
39 | for (PropertySource source : this.sources) {
40 | if (configuration.isPropertySourceActive(source)) {
41 | source.getProperties(configuration).forEach((key, value) -> {
42 | for (String translated : propertyKeyNamingStrategy.apply(source, key)) {
43 | properties.put(translated, value);
44 | }
45 | });
46 | }
47 | }
48 | return properties;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/sources/jgit-source/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 |
15 | eu.maveniverse.maven.nisse.sources
16 | sources
17 | 0.6.4-SNAPSHOT
18 |
19 |
20 | jgit-source
21 |
22 | ${project.groupId}:${project.artifactId}
23 |
24 |
25 | 1.9.25
26 |
27 |
28 |
29 |
30 |
31 | eu.maveniverse.maven.nisse
32 | core
33 |
34 |
35 | javax.inject
36 | javax.inject
37 |
38 |
39 |
40 |
41 | org.eclipse.jgit
42 | org.eclipse.jgit
43 | 5.13.5.202508271544-r
44 |
45 |
46 | org.apache.maven.resolver
47 | maven-resolver-api
48 | ${version.resolver}
49 |
50 |
51 | org.apache.maven.resolver
52 | maven-resolver-util
53 | ${version.resolver}
54 |
55 |
56 |
57 | org.junit.jupiter
58 | junit-jupiter-api
59 | test
60 |
61 |
62 | org.slf4j
63 | slf4j-simple
64 | test
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/core/src/test/java/eu/maveniverse/maven/nisse/core/simple/SimpleNisseManagerTest.java:
--------------------------------------------------------------------------------
1 | package eu.maveniverse.maven.nisse.core.simple;
2 |
3 | import static org.junit.jupiter.api.Assertions.assertEquals;
4 | import static org.junit.jupiter.api.Assertions.assertSame;
5 | import static org.junit.jupiter.api.Assertions.assertTrue;
6 |
7 | import eu.maveniverse.maven.nisse.core.NisseConfiguration;
8 | import eu.maveniverse.maven.nisse.core.PropertySource;
9 | import java.io.IOException;
10 | import java.util.Arrays;
11 | import java.util.HashMap;
12 | import java.util.Map;
13 | import org.junit.jupiter.api.Test;
14 |
15 | public class SimpleNisseManagerTest {
16 | @Test
17 | void smoke() throws IOException {
18 | Map m1 = new HashMap<>();
19 | m1.put("one", "en");
20 | m1.put("two", "to");
21 | Map m2 = new HashMap<>();
22 | m2.put("one", "egy");
23 | m2.put("two", "kettő");
24 | PropertySource s1 = new PropertySource() {
25 | @Override
26 | public String getName() {
27 | return "dk";
28 | }
29 |
30 | @Override
31 | public Map getProperties(NisseConfiguration configuration) {
32 | return m1;
33 | }
34 | };
35 | PropertySource s2 = new PropertySource() {
36 | @Override
37 | public String getName() {
38 | return "hu";
39 | }
40 |
41 | @Override
42 | public Map getProperties(NisseConfiguration configuration) {
43 | return m2;
44 | }
45 | };
46 |
47 | SimpleNisseManager snm = new SimpleNisseManager(Arrays.asList(s1, s2));
48 |
49 | SimpleNisseConfiguration conf = SimpleNisseConfiguration.builder().build();
50 | Map allProperties = snm.createProperties(conf);
51 | assertEquals(4, allProperties.size());
52 | assertTrue(allProperties.containsKey("nisse.dk.one"));
53 | assertSame(allProperties.get("nisse.dk.one"), "en");
54 | assertTrue(allProperties.containsKey("nisse.dk.two"));
55 | assertSame(allProperties.get("nisse.dk.two"), "to");
56 | assertTrue(allProperties.containsKey("nisse.hu.one"));
57 | assertSame(allProperties.get("nisse.hu.one"), "egy");
58 | assertTrue(allProperties.containsKey("nisse.hu.two"));
59 | assertSame(allProperties.get("nisse.hu.two"), "kettő");
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/sources/file-source/src/main/java/eu/maveniverse/maven/nisse/source/file/PropertyFilePropertySource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | package eu.maveniverse.maven.nisse.source.file;
9 |
10 | import eu.maveniverse.maven.nisse.core.NisseConfiguration;
11 | import eu.maveniverse.maven.nisse.core.PropertySource;
12 | import java.io.IOException;
13 | import java.io.InputStream;
14 | import java.io.UncheckedIOException;
15 | import java.nio.file.Files;
16 | import java.nio.file.Path;
17 | import java.util.Collections;
18 | import java.util.HashMap;
19 | import java.util.Map;
20 | import java.util.Properties;
21 | import javax.inject.Named;
22 | import javax.inject.Singleton;
23 |
24 | /**
25 | * A simple property key source that accepts a Java Properties file name, and will load up properties from it.
26 | */
27 | @Singleton
28 | @Named(PropertyFilePropertySource.NAME)
29 | public class PropertyFilePropertySource implements PropertySource {
30 | public static final String NAME = "file";
31 |
32 | public static final String FILE_NAME = NisseConfiguration.SOURCE_PREFIX + NAME + ".name";
33 |
34 | @Override
35 | public String getName() {
36 | return NAME;
37 | }
38 |
39 | @Override
40 | public Map getProperties(NisseConfiguration configuration) {
41 | String propertyFile = configuration.getConfiguration().get(FILE_NAME);
42 | HashMap properties = new HashMap<>();
43 | if (propertyFile != null) {
44 | Path propertyFilePath = configuration.getCurrentWorkingDirectory().resolve(propertyFile);
45 | if (Files.isRegularFile(propertyFilePath)) {
46 | try (InputStream stream = Files.newInputStream(propertyFilePath)) {
47 | Properties prop = new Properties();
48 | prop.load(stream);
49 | for (final String key : prop.stringPropertyNames()) {
50 | properties.put(key, prop.getProperty(key));
51 | }
52 | } catch (IOException e) {
53 | throw new UncheckedIOException(e);
54 | }
55 | }
56 | }
57 | return Collections.unmodifiableMap(properties);
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/it/plugin3-its/src/it/smoke/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 | eu.maveniverse.maven.nisse.it.smoke
15 | smoke
16 | 0.1.0-SNAPSHOT
17 |
18 | ${project.groupId}:${project.artifactId}
19 |
20 |
21 | UTF-8
22 | UTF-8
23 |
24 |
25 |
26 |
27 |
28 | eu.maveniverse.maven.plugins
29 | nisse-plugin3
30 | @project.version@
31 |
32 |
33 | inject-properties
34 |
35 | inject-properties
36 |
37 | validate
38 |
39 |
40 |
41 |
42 | org.codehaus.mojo
43 | properties-maven-plugin
44 | 1.2.1
45 |
46 |
47 | display-property
48 | validate
49 |
50 | write-project-properties
51 |
52 |
53 | project.properties
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Maveniverse Nisse
2 |
3 | Requirements:
4 | * Java: 8+
5 | * Maven: 3.8.x+
6 |
7 | Nisse is a suite of extensions and plugins for Maven 3 and Maven 4 that provides following:
8 | * in Maven 3 "fixes" the CI Friendly version support, as out of the box implementation is flaky (allows you to deploy broken POMs).
9 | * provides "property sources", aggregates properties got from them, it may rename/translate property keys, and publishes properties to Maven.
10 | * provides drop-in-replacement for discontinued [OS Detector plugin](https://github.com/trustin/os-maven-plugin).
11 | * is extensible, one can add new property sources as needed.
12 |
13 | ## Usage with Maven
14 |
15 | There are 3 extensions: `extension3` meant to be used with Maven 3 exclusively (does not work in Maven 4), then
16 | `extension4` meant to be used with Maven 4 exclusively (does not work in Maven 3), and finally `extension`, that
17 | works in both, Maven 3 and Maven 4. Last is the recommended extension to be used. Use it like this:
18 |
19 | ```xml
20 |
21 |
22 |
23 | eu.maveniverse.maven.nisse
24 | extension
25 | ${version.nisse}
26 |
27 |
28 | ```
29 |
30 | Note: Nisse can be used as "plugin only" as well, but functionality in this case is limited ONLY to providing
31 | properties for interpolation (within a project).
32 |
33 | Nisse can serve as OS Detector **drop in replacement**, just add Nisse as extension to your project and
34 | specify `-Dnisse.compat.osDetector` on CLI or better, in `.mvn/maven.config` file. If this option present,
35 | Nisse will emit **same properties** as OS Detector did.
36 |
37 | To check what Nisse injects, simplest command to use is Nisse dump:
38 |
39 | ```
40 | $ mvn validate -N -Dnisse.dump
41 | ```
42 |
43 | The `-N` is needed only if you are in root of some complex multi-module project.
44 | Note that this only works when Nisse is declared as a ["core extension"](https://maven.apache.org/guides/mini/guide-using-extensions.html)
45 | (Maven 3 and 4) through **.mvn/extensions.xml** or as a "user-wide extension" (Maven 4 only) through **~/.m2/extensions.xml**.
46 | Otherwise, one may use `dump-properties` Mojo or the `nisse.dump` property of `inject-properties` Mojo.
47 |
48 | ## Implemented Sources
49 |
50 | There are 4 sources provided out of the box:
51 | * `file-source`: it reads up a Java Properties File from disk and publishes that
52 | * `jgit-source`: it uses Eclipse JGit to get some git related data
53 | * `mvn-source`: it provides major/minor/patch versions of currently used Maven (note: Maven 4 already provides this from core)
54 | * `os-source`: heavily inspired by [OS Detector](https://github.com/trustin/os-maven-plugin) and made reusable
55 |
56 | Look into ITs for usage examples.
57 |
--------------------------------------------------------------------------------
/it/plugin3-its/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 |
15 | eu.maveniverse.maven.nisse.it
16 | it
17 | 0.6.4-SNAPSHOT
18 |
19 |
20 | plugin3-its
21 | pom
22 |
23 | ${project.groupId}:${project.artifactId}
24 |
25 |
26 |
27 | eu.maveniverse.maven.plugins
28 | nisse-plugin3
29 |
30 |
31 |
32 |
33 |
34 | run-its
35 |
36 |
37 |
38 | org.apache.maven.plugins
39 | maven-invoker-plugin
40 |
41 | ${project.build.directory}/it
42 | true
43 | src/it/settings.xml
44 |
45 | */pom.xml
46 |
47 | setup
48 | verify
49 | ${project.build.directory}/local-repo
50 | src/it/settings.xml
51 | false
52 |
53 |
54 |
55 | integration-test
56 | none
57 |
58 |
59 | invoker-install
60 |
61 | install
62 |
63 | integration-test
64 |
65 |
66 | invoker-run
67 |
68 | run
69 |
70 | integration-test
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/extension3/src/main/java/eu/maveniverse/maven/nisse/extension3/internal/NisseModelVersionProcessor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | package eu.maveniverse.maven.nisse.extension3.internal;
9 |
10 | import static java.util.Objects.requireNonNull;
11 |
12 | import eu.maveniverse.maven.nisse.core.NisseConfiguration;
13 | import java.util.Properties;
14 | import javax.inject.Inject;
15 | import javax.inject.Named;
16 | import javax.inject.Provider;
17 | import javax.inject.Singleton;
18 | import org.apache.maven.execution.MavenSession;
19 | import org.apache.maven.model.building.ModelBuildingRequest;
20 | import org.apache.maven.model.interpolation.ModelVersionProcessor;
21 | import org.eclipse.sisu.Priority;
22 | import org.slf4j.Logger;
23 | import org.slf4j.LoggerFactory;
24 |
25 | @Singleton
26 | @Named
27 | @Priority(200)
28 | final class NisseModelVersionProcessor implements ModelVersionProcessor {
29 | private final Logger logger = LoggerFactory.getLogger(NisseModelVersionProcessor.class);
30 | private final Provider sessionProvider;
31 | private final NissePropertyInliner inliner;
32 |
33 | @Inject
34 | public NisseModelVersionProcessor(Provider sessionProvider, NissePropertyInliner inliner) {
35 | this.sessionProvider = requireNonNull(sessionProvider, "sessionProvider");
36 | this.inliner = requireNonNull(inliner, "inliner");
37 | }
38 |
39 | @Override
40 | public boolean isValidProperty(String property) {
41 | MavenSession session = this.sessionProvider.get();
42 | boolean valid = property.startsWith(NisseConfiguration.PROPERTY_PREFIX)
43 | && session.getRequest().getUserProperties().containsKey(property);
44 | if (valid) {
45 | inliner.inlinedKeys(session).add(property);
46 | }
47 | return valid;
48 | }
49 |
50 | @Override
51 | public void overwriteModelProperties(Properties modelProperties, ModelBuildingRequest request) {
52 | try {
53 | MavenSession session = this.sessionProvider.get();
54 | for (String inlinedKey : inliner.inlinedKeys(session)) {
55 | modelProperties.setProperty(
56 | inlinedKey, session.getRequest().getUserProperties().getProperty(inlinedKey));
57 | }
58 | } catch (Exception e) {
59 | // ignore; this means we were invoked outside of session
60 | if (logger.isDebugEnabled()) {
61 | logger.warn("NisseModelVersionProcessor.overwriteModelProperties: failed, called out of session?", e);
62 | } else {
63 | logger.warn("NisseModelVersionProcessor.overwriteModelProperties: failed, called out of session?");
64 | }
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/core/src/main/java/eu/maveniverse/maven/nisse/core/NisseConfiguration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | package eu.maveniverse.maven.nisse.core;
9 |
10 | import java.nio.file.Path;
11 | import java.util.Collection;
12 | import java.util.List;
13 | import java.util.Map;
14 | import java.util.function.BiFunction;
15 |
16 | public interface NisseConfiguration {
17 | /**
18 | * The default Nisse prefix.
19 | */
20 | String PROPERTY_PREFIX = "nisse.";
21 |
22 | /**
23 | * The default Nisse source config prefix.
24 | */
25 | String SOURCE_PREFIX = PROPERTY_PREFIX + "source.";
26 |
27 | /**
28 | * Key to use for detecting is "os-detector compatibility" requested. Value of this key is parsed as
29 | * boolean string.
30 | */
31 | String COMPAT_OS_DETECTOR = PROPERTY_PREFIX + "compat.osDetector";
32 |
33 | /**
34 | * Returns immutable map of session effective system properties, never {@code null}.
35 | */
36 | Map getSystemProperties();
37 |
38 | /**
39 | * Returns immutable map of session effective user properties, never {@code null}.
40 | */
41 | Map getUserProperties();
42 |
43 | /**
44 | * Returns immutable map of session effective configuration, never {@code null}.
45 | *
46 | * Note: in Maven this is systemProperties + userProperties flattened in this order.
47 | */
48 | Map getConfiguration();
49 |
50 | /**
51 | * Returns the path that should be considered "current working directory", never {@code null}.
52 | *
53 | * Note: in Maven this may not be same as "user.dir" system property!
54 | */
55 | Path getCurrentWorkingDirectory();
56 |
57 | /**
58 | * Returns the path that should be considered "session root directory", never {@code null}.
59 | *
60 | * Note: this is to support older Maven versions than 3.9.2.
61 | */
62 | Path getSessionRootDirectory();
63 |
64 | /**
65 | * Returns {@code true} if property source is active (by default they are active). To disable a source use
66 | * {@code "nisse.source.$source.active=false"} property (defaults to {@code true}).
67 | */
68 | boolean isPropertySourceActive(PropertySource source);
69 |
70 | /**
71 | * Returns {@code true} if property source is active (by default they are active). To disable a source use
72 | * {@code "nisse.source.inlinedKeys=key1,key2"} property (defaults to empty collection).
73 | */
74 | Collection getInlinedPropertyKeys();
75 |
76 | /**
77 | * Returns the {@link PropertyKeyNamingStrategies} to apply to published properties.
78 | */
79 | BiFunction> propertyKeyNamingStrategy();
80 | }
81 |
--------------------------------------------------------------------------------
/core/src/test/java/eu/maveniverse/maven/nisse/core/simple/PropertyKeyNamingStrategiesTest.java:
--------------------------------------------------------------------------------
1 | package eu.maveniverse.maven.nisse.core.simple;
2 |
3 | import static org.junit.jupiter.api.Assertions.assertEquals;
4 |
5 | import eu.maveniverse.maven.nisse.core.NisseConfiguration;
6 | import eu.maveniverse.maven.nisse.core.PropertyKeyNamingStrategies;
7 | import eu.maveniverse.maven.nisse.core.PropertySource;
8 | import java.io.IOException;
9 | import java.util.Arrays;
10 | import java.util.Collections;
11 | import java.util.HashMap;
12 | import java.util.List;
13 | import java.util.Map;
14 | import java.util.function.BiFunction;
15 | import org.junit.jupiter.api.Test;
16 |
17 | public class PropertyKeyNamingStrategiesTest {
18 | @Test
19 | void smoke() throws IOException {
20 | Map> translations = new HashMap<>();
21 | translations.put("one.first", Collections.singletonList("first.theOnly"));
22 | translations.put("two.first", Arrays.asList("second.one", "second.two"));
23 | BiFunction> strategy = PropertyKeyNamingStrategies.fork(
24 | PropertyKeyNamingStrategies.translated(
25 | translations,
26 | PropertyKeyNamingStrategies.sourcePrefixed(),
27 | PropertyKeyNamingStrategies.defaultStrategy()),
28 | PropertyKeyNamingStrategies.osDetector());
29 |
30 | PropertySource oneSource = new PropertySource() {
31 | @Override
32 | public String getName() {
33 | return "one";
34 | }
35 |
36 | @Override
37 | public Map getProperties(NisseConfiguration configuration) {
38 | throw new UnsupportedOperationException("not implemented");
39 | }
40 | };
41 | PropertySource twoSource = new PropertySource() {
42 | @Override
43 | public String getName() {
44 | return "two";
45 | }
46 |
47 | @Override
48 | public Map getProperties(NisseConfiguration configuration) {
49 | throw new UnsupportedOperationException("not implemented");
50 | }
51 | };
52 | PropertySource osSource = new PropertySource() {
53 | @Override
54 | public String getName() {
55 | return "os";
56 | }
57 |
58 | @Override
59 | public Map getProperties(NisseConfiguration configuration) {
60 | throw new UnsupportedOperationException("not implemented");
61 | }
62 | };
63 | List keys;
64 |
65 | keys = strategy.apply(oneSource, "first");
66 | assertEquals(Collections.singletonList("first.theOnly"), keys);
67 |
68 | keys = strategy.apply(twoSource, "first");
69 | assertEquals(Arrays.asList("second.one", "second.two"), keys);
70 |
71 | keys = strategy.apply(osSource, "name");
72 | assertEquals(Arrays.asList("nisse.os.name", "os.detected.name"), keys);
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/extension/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 |
15 | eu.maveniverse.maven.nisse
16 | nisse
17 | 0.6.4-SNAPSHOT
18 |
19 |
20 | extension
21 |
22 | ${project.groupId}:${project.artifactId}
23 |
24 |
25 |
26 |
27 | eu.maveniverse.maven.nisse
28 | extension3
29 |
30 |
31 | eu.maveniverse.maven.nisse
32 | extension4
33 |
34 |
35 |
36 |
37 | org.slf4j
38 | slf4j-api
39 | provided
40 |
41 |
42 | org.apache.maven.resolver
43 | maven-resolver-api
44 | ${maven3ResolverVersion}
45 | provided
46 |
47 |
48 | org.apache.maven.resolver
49 | maven-resolver-util
50 | ${maven3ResolverVersion}
51 | provided
52 |
53 |
54 | org.apache.maven
55 | maven-core
56 | ${maven3Version}
57 | provided
58 |
59 |
60 | org.apache.maven
61 | maven-embedder
62 | ${maven3Version}
63 | provided
64 |
65 |
66 | org.apache.maven
67 | maven-model
68 | ${maven3Version}
69 | provided
70 |
71 |
72 | org.apache.maven
73 | maven-model-builder
74 | ${maven3Version}
75 | provided
76 |
77 |
78 |
79 | javax.inject
80 | javax.inject
81 | provided
82 |
83 |
84 | org.eclipse.sisu
85 | org.eclipse.sisu.inject
86 | provided
87 |
88 |
89 |
90 |
--------------------------------------------------------------------------------
/extension4/src/main/java/eu/maveniverse/maven/nisse/extension4/internal/NissePropertyContributor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | package eu.maveniverse.maven.nisse.extension4.internal;
9 |
10 | import static java.util.Objects.requireNonNull;
11 |
12 | import eu.maveniverse.maven.nisse.core.NisseConfiguration;
13 | import eu.maveniverse.maven.nisse.core.NisseManager;
14 | import eu.maveniverse.maven.nisse.core.PropertyKeyNamingStrategies;
15 | import eu.maveniverse.maven.nisse.core.Version;
16 | import eu.maveniverse.maven.nisse.core.simple.SimpleNisseConfiguration;
17 | import java.io.IOException;
18 | import java.io.UncheckedIOException;
19 | import java.util.HashMap;
20 | import java.util.Map;
21 | import javax.inject.Inject;
22 | import javax.inject.Named;
23 | import javax.inject.Singleton;
24 | import org.apache.maven.api.ProtoSession;
25 | import org.apache.maven.api.spi.PropertyContributor;
26 | import org.slf4j.Logger;
27 | import org.slf4j.LoggerFactory;
28 |
29 | @Singleton
30 | @Named
31 | final class NissePropertyContributor implements PropertyContributor {
32 | private final Logger logger = LoggerFactory.getLogger(getClass());
33 | private final NisseManager nisseManager;
34 |
35 | @Inject
36 | public NissePropertyContributor(NisseManager nisseManager) {
37 | this.nisseManager = requireNonNull(nisseManager, "nisseManager");
38 | }
39 |
40 | @Override
41 | public Map contribute(ProtoSession protoSession) {
42 | try {
43 | logger.info("Maveniverse Nisse {} loaded", Version.version());
44 | // create properties and push what we got into CLI user properties
45 | NisseConfiguration configuration = SimpleNisseConfiguration.builder()
46 | .withSystemProperties(protoSession.getSystemProperties())
47 | .withUserProperties(protoSession.getUserProperties())
48 | .withCurrentWorkingDirectory(protoSession.getTopDirectory())
49 | .withSessionRootDirectory(protoSession.getRootDirectory())
50 | .combinePropertyKeyNamingStrategy(PropertyKeyNamingStrategies.translated(
51 | PropertyKeyNamingStrategies.translationTableFromPropertiesFile(protoSession
52 | .getRootDirectory()
53 | .resolve(".mvn")
54 | .resolve("nisse-translation.properties")),
55 | PropertyKeyNamingStrategies.sourcePrefixed(),
56 | PropertyKeyNamingStrategies.defaultStrategy()))
57 | .build();
58 | Map result = new HashMap<>(protoSession.getUserProperties());
59 | Map nisseProperties = nisseManager.createProperties(configuration);
60 | logger.info("Nisse injecting {} properties into User Properties", nisseProperties.size());
61 | if (Boolean.parseBoolean(protoSession.getUserProperties().getOrDefault("nisse.dump", "false"))) {
62 | nisseProperties.forEach((k, v) -> logger.info("{}={}", k, v));
63 | }
64 | nisseProperties.forEach(result::putIfAbsent);
65 | return result;
66 | } catch (IOException e) {
67 | throw new UncheckedIOException("Error while creating Nisse configuration", e);
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/it/extension3-its/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 |
15 | eu.maveniverse.maven.nisse.it
16 | it
17 | 0.6.4-SNAPSHOT
18 |
19 |
20 | extension3-its
21 | pom
22 |
23 | ${project.groupId}:${project.artifactId}
24 |
25 |
26 |
27 | eu.maveniverse.maven.nisse
28 | extension3
29 |
30 |
31 |
32 |
33 |
34 | run-its
35 |
36 |
37 |
38 | org.apache.maven.plugins
39 | maven-dependency-plugin
40 |
41 |
42 | prepare-maven-distro
43 |
44 | unpack
45 |
46 | generate-test-resources
47 |
48 |
49 |
50 | org.apache.maven
51 | apache-maven
52 | ${maven3Version}
53 | bin
54 | zip
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 | org.apache.maven.plugins
63 | maven-invoker-plugin
64 |
65 | ${project.build.directory}/dependency/apache-maven-${maven3Version}
66 | ${project.build.directory}/it
67 | ${project.build.directory}/it-repo
68 | true
69 |
70 | */pom.xml
71 |
72 | setup
73 | verify
74 | false
75 |
76 |
77 |
78 | integration-test
79 | none
80 |
81 |
82 | run-its
83 |
84 | install
85 | run
86 |
87 | integration-test
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
--------------------------------------------------------------------------------
/extension4/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 |
15 | eu.maveniverse.maven.nisse
16 | nisse
17 | 0.6.4-SNAPSHOT
18 |
19 |
20 | extension4
21 |
22 | ${project.groupId}:${project.artifactId}
23 |
24 |
25 |
26 |
27 | eu.maveniverse.maven.nisse
28 | core
29 |
30 |
31 | *
32 | *
33 |
34 |
35 |
36 |
37 | eu.maveniverse.maven.nisse.sources
38 | file-source
39 |
40 |
41 | eu.maveniverse.maven.nisse.sources
42 | jgit-source
43 |
44 |
45 | org.apache.maven.resolver
46 | *
47 |
48 |
49 |
50 |
51 | eu.maveniverse.maven.nisse.sources
52 | mvn-source
53 |
54 |
55 | eu.maveniverse.maven.nisse.sources
56 | os-source
57 |
58 |
59 |
60 |
61 | org.slf4j
62 | slf4j-api
63 | provided
64 |
65 |
66 | org.apache.maven
67 | maven-api-spi
68 | ${maven4Version}
69 | provided
70 |
71 |
72 | org.apache.maven.resolver
73 | maven-resolver-api
74 | ${maven3ResolverVersion}
75 | provided
76 |
77 |
78 | org.apache.maven.resolver
79 | maven-resolver-util
80 | ${maven3ResolverVersion}
81 | provided
82 |
83 |
84 |
85 | javax.inject
86 | javax.inject
87 | provided
88 |
89 |
90 | org.eclipse.sisu
91 | org.eclipse.sisu.inject
92 | provided
93 |
94 |
95 |
96 |
97 | org.junit.jupiter
98 | junit-jupiter-api
99 | test
100 |
101 |
102 | org.slf4j
103 | slf4j-simple
104 | test
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/extension3/src/main/java/eu/maveniverse/maven/nisse/extension3/internal/NisseLifecycleParticipant.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | package eu.maveniverse.maven.nisse.extension3.internal;
9 |
10 | import static java.util.Objects.requireNonNull;
11 |
12 | import eu.maveniverse.maven.nisse.core.NisseConfiguration;
13 | import eu.maveniverse.maven.nisse.core.PropertyKeyNamingStrategies;
14 | import eu.maveniverse.maven.nisse.core.simple.SimpleNisseConfiguration;
15 | import java.io.IOException;
16 | import java.nio.file.Paths;
17 | import javax.inject.Inject;
18 | import javax.inject.Named;
19 | import javax.inject.Singleton;
20 | import org.apache.maven.AbstractMavenLifecycleParticipant;
21 | import org.apache.maven.MavenExecutionException;
22 | import org.apache.maven.execution.MavenSession;
23 | import org.slf4j.Logger;
24 | import org.slf4j.LoggerFactory;
25 |
26 | @Singleton
27 | @Named
28 | class NisseLifecycleParticipant extends AbstractMavenLifecycleParticipant {
29 | private final Logger logger = LoggerFactory.getLogger(getClass());
30 | private final NissePropertyInliner inliner;
31 |
32 | @Inject
33 | public NisseLifecycleParticipant(NissePropertyInliner inliner) {
34 | this.inliner = requireNonNull(inliner, "inliner");
35 | }
36 |
37 | @Override
38 | public void afterSessionStart(MavenSession session) throws MavenExecutionException {
39 | try {
40 | NisseConfiguration configuration = SimpleNisseConfiguration.builder()
41 | .withSystemProperties(session.getSystemProperties())
42 | .withUserProperties(session.getUserProperties())
43 | .withCurrentWorkingDirectory(Paths.get(session.getRequest().getBaseDirectory()))
44 | .withSessionRootDirectory(session.getRequest()
45 | .getMultiModuleProjectDirectory()
46 | .toPath())
47 | .combinePropertyKeyNamingStrategy(PropertyKeyNamingStrategies.translated(
48 | PropertyKeyNamingStrategies.translationTableFromPropertiesFile(session.getRequest()
49 | .getMultiModuleProjectDirectory()
50 | .toPath()
51 | .resolve(".mvn")
52 | .resolve("nisse-translation.properties")),
53 | PropertyKeyNamingStrategies.sourcePrefixed(),
54 | PropertyKeyNamingStrategies.defaultStrategy()))
55 | .build();
56 | for (String inlinedKey : configuration.getInlinedPropertyKeys()) {
57 | if (inliner.inlinedKeys(session).add(inlinedKey)) {
58 | logger.info("Nisse property {} configured for inlining", inlinedKey);
59 | }
60 | }
61 | } catch (IOException e) {
62 | throw new MavenExecutionException("Error while creating Nisse configuration", e);
63 | }
64 | }
65 |
66 | @Override
67 | public void afterProjectsRead(MavenSession session) throws MavenExecutionException {
68 | try {
69 | inliner.mayInlinePom(session, session.getProjects());
70 | } catch (IOException e) {
71 | throw new MavenExecutionException("Nisse failed to inline", e);
72 | }
73 | }
74 |
75 | @Override
76 | public void afterSessionEnd(MavenSession session) throws MavenExecutionException {
77 | try {
78 | inliner.cleanup(session, session.getProjects());
79 | } catch (IOException e) {
80 | throw new MavenExecutionException("Nisse failed to inline", e);
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/plugin3/src/main/java/eu/maveniverse/maven/nisse/plugin3/InjectPropertiesMojo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | package eu.maveniverse.maven.nisse.plugin3;
9 |
10 | import eu.maveniverse.maven.nisse.core.NisseConfiguration;
11 | import eu.maveniverse.maven.nisse.core.NisseManager;
12 | import eu.maveniverse.maven.nisse.core.PropertyKeyNamingStrategies;
13 | import eu.maveniverse.maven.nisse.core.simple.SimpleNisseConfiguration;
14 | import java.io.IOException;
15 | import java.nio.file.Paths;
16 | import java.util.Map;
17 | import javax.inject.Inject;
18 | import org.apache.maven.execution.MavenSession;
19 | import org.apache.maven.plugin.AbstractMojo;
20 | import org.apache.maven.plugin.MojoExecutionException;
21 | import org.apache.maven.plugins.annotations.Mojo;
22 | import org.apache.maven.plugins.annotations.Parameter;
23 | import org.apache.maven.project.MavenProject;
24 | import org.slf4j.Logger;
25 | import org.slf4j.LoggerFactory;
26 |
27 | /**
28 | * Nisse inject-properties Mojo that injects created properties into project.
29 | */
30 | @Mojo(name = "inject-properties", threadSafe = true)
31 | public class InjectPropertiesMojo extends AbstractMojo {
32 | private final Logger logger = LoggerFactory.getLogger(getClass());
33 |
34 | @Inject
35 | private MavenProject mavenProject;
36 |
37 | @Inject
38 | private MavenSession mavenSession;
39 |
40 | @Inject
41 | private NisseManager nisseManager;
42 |
43 | /**
44 | * Diagnostic utility, if {@code true}, it will dump to log all the properties it injects into project.
45 | */
46 | @Parameter(property = "nisse.dump", defaultValue = "false")
47 | private boolean dump;
48 |
49 | @Override
50 | public void execute() throws MojoExecutionException {
51 | try {
52 | NisseConfiguration configuration = SimpleNisseConfiguration.builder()
53 | .withSystemProperties(mavenSession.getSystemProperties())
54 | .withUserProperties(mavenSession.getUserProperties())
55 | .withCurrentWorkingDirectory(
56 | Paths.get(mavenSession.getRequest().getBaseDirectory()))
57 | .withSessionRootDirectory(mavenSession
58 | .getRequest()
59 | .getMultiModuleProjectDirectory()
60 | .toPath())
61 | .combinePropertyKeyNamingStrategy(PropertyKeyNamingStrategies.translated(
62 | PropertyKeyNamingStrategies.translationTableFromPropertiesFile(mavenSession
63 | .getRequest()
64 | .getMultiModuleProjectDirectory()
65 | .toPath()
66 | .resolve(".mvn")
67 | .resolve("nisse-translation.properties")),
68 | PropertyKeyNamingStrategies.sourcePrefixed(),
69 | PropertyKeyNamingStrategies.defaultStrategy()))
70 | .build();
71 | Map properties = nisseManager.createProperties(configuration);
72 | if (dump) {
73 | logger.info("Dumping {} properties", properties.size());
74 | properties.forEach((k, v) -> logger.info("{}={}", k, v));
75 | }
76 | logger.info("Injecting {} properties into project", properties.size());
77 | properties.forEach((k, v) -> mavenProject.getProperties().setProperty(k, v));
78 | } catch (IOException e) {
79 | throw new MojoExecutionException("Error while creating Nisse configuration", e);
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/sources/mvn-source/src/main/java/eu/maveniverse/maven/nisse/source/mvn/MvnPropertySource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | package eu.maveniverse.maven.nisse.source.mvn;
9 |
10 | import eu.maveniverse.maven.nisse.core.NisseConfiguration;
11 | import eu.maveniverse.maven.nisse.core.PropertySource;
12 | import java.io.InputStream;
13 | import java.nio.file.FileSystem;
14 | import java.nio.file.FileSystems;
15 | import java.nio.file.Files;
16 | import java.nio.file.Path;
17 | import java.nio.file.Paths;
18 | import java.util.Collections;
19 | import java.util.HashMap;
20 | import java.util.Map;
21 | import java.util.Properties;
22 | import javax.inject.Named;
23 | import javax.inject.Singleton;
24 |
25 | /**
26 | * mvn source: gives access to current Maven version, uses {@code "maven.version"} property.
27 | */
28 | @Singleton
29 | @Named(MvnPropertySource.NAME)
30 | public class MvnPropertySource implements PropertySource {
31 | public static final String NAME = "mvn";
32 |
33 | private static final String VERSION = "version";
34 | private static final String VERSION_MAJOR = "major";
35 | private static final String VERSION_MINOR = "minor";
36 | private static final String VERSION_MAJOR_MINOR = "majorMinor";
37 | private static final String VERSION_PATCH = "patch";
38 | private static final String VERSION_QUALIFIER = "qualifier";
39 |
40 | @Override
41 | public String getName() {
42 | return NAME;
43 | }
44 |
45 | @Override
46 | public Map getProperties(NisseConfiguration configuration) {
47 | String mavenVersion = configuration.getConfiguration().get("maven.version");
48 | HashMap result = new HashMap<>();
49 | if (mavenVersion != null) {
50 | result.put(VERSION, mavenVersion);
51 | if (mavenVersion.contains("-")) {
52 | int qIdx = mavenVersion.indexOf('-');
53 | result.put(VERSION_QUALIFIER, mavenVersion.substring(qIdx + 1));
54 | mavenVersion = mavenVersion.substring(0, qIdx);
55 | }
56 | String[] elems = mavenVersion.split("\\.");
57 | result.put(VERSION_MAJOR, elems[0]);
58 | result.put(VERSION_MINOR, elems[1]);
59 | result.put(VERSION_MAJOR_MINOR, elems[0] + "." + elems[1]);
60 | result.put(VERSION_PATCH, elems[2]);
61 | }
62 | Properties mavenBuildProperties = getMavenBuildProperties(configuration);
63 | if (!mavenBuildProperties.isEmpty()) {
64 | mavenBuildProperties.stringPropertyNames().forEach(k -> result.put(k, mavenBuildProperties.getProperty(k)));
65 | }
66 | return Collections.unmodifiableMap(result);
67 | }
68 |
69 | private static Properties getMavenBuildProperties(NisseConfiguration configuration) {
70 | String mavenHome = configuration.getConfiguration().get("maven.home");
71 | String mavenVersion = configuration.getConfiguration().get("maven.version");
72 | Properties properties = new Properties();
73 | try {
74 | if (mavenHome != null && mavenVersion != null) {
75 | Path mavenCoreJarPath = Paths.get(mavenHome).resolve("lib/maven-core-" + mavenVersion + ".jar");
76 | if (Files.isRegularFile(mavenCoreJarPath)) {
77 | try (FileSystem fs = FileSystems.newFileSystem(mavenCoreJarPath, (ClassLoader) null);
78 | InputStream input =
79 | Files.newInputStream(fs.getPath("/org/apache/maven/messages/build.properties"))) {
80 | properties.load(input);
81 | }
82 | }
83 | }
84 | } catch (Exception e) {
85 | // ignore
86 | }
87 | return properties;
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/extension3/src/main/java/eu/maveniverse/maven/nisse/extension3/internal/NisseConfigurationProcessor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | package eu.maveniverse.maven.nisse.extension3.internal;
9 |
10 | import static java.util.Objects.requireNonNull;
11 |
12 | import eu.maveniverse.maven.nisse.core.NisseConfiguration;
13 | import eu.maveniverse.maven.nisse.core.NisseManager;
14 | import eu.maveniverse.maven.nisse.core.PropertyKeyNamingStrategies;
15 | import eu.maveniverse.maven.nisse.core.Version;
16 | import eu.maveniverse.maven.nisse.core.simple.SimpleNisseConfiguration;
17 | import java.nio.file.Paths;
18 | import java.util.Map;
19 | import java.util.Properties;
20 | import javax.inject.Inject;
21 | import javax.inject.Named;
22 | import javax.inject.Singleton;
23 | import org.apache.maven.cli.CliRequest;
24 | import org.apache.maven.cli.configuration.ConfigurationProcessor;
25 | import org.apache.maven.cli.configuration.SettingsXmlConfigurationProcessor;
26 | import org.eclipse.sisu.Priority;
27 | import org.slf4j.Logger;
28 | import org.slf4j.LoggerFactory;
29 |
30 | @Singleton
31 | @Named
32 | @Priority(200)
33 | final class NisseConfigurationProcessor implements ConfigurationProcessor {
34 | private final Logger logger = LoggerFactory.getLogger(getClass());
35 | private final NisseManager nisseManager;
36 | private final SettingsXmlConfigurationProcessor settingsXmlConfigurationProcessor;
37 |
38 | @Inject
39 | public NisseConfigurationProcessor(
40 | NisseManager nisseManager, SettingsXmlConfigurationProcessor settingsXmlConfigurationProcessor) {
41 | this.nisseManager = requireNonNull(nisseManager, "nisseManager");
42 | this.settingsXmlConfigurationProcessor =
43 | requireNonNull(settingsXmlConfigurationProcessor, "settingsXmlConfigurationProcessor");
44 | }
45 |
46 | @Override
47 | public void process(CliRequest request) throws Exception {
48 | settingsXmlConfigurationProcessor.process(request);
49 |
50 | logger.info("Maveniverse Nisse {} loaded", Version.version());
51 |
52 | // create properties and push what we got into CLI user properties
53 | Properties userProperties = request.getUserProperties();
54 | NisseConfiguration configuration = SimpleNisseConfiguration.builder()
55 | .withSystemProperties(request.getSystemProperties())
56 | .withUserProperties(request.getUserProperties())
57 | .withCurrentWorkingDirectory(Paths.get(request.getWorkingDirectory()))
58 | .withSessionRootDirectory(
59 | request.getMultiModuleProjectDirectory().toPath())
60 | .combinePropertyKeyNamingStrategy(PropertyKeyNamingStrategies.translated(
61 | PropertyKeyNamingStrategies.translationTableFromPropertiesFile(
62 | request.getMultiModuleProjectDirectory()
63 | .toPath()
64 | .resolve(".mvn")
65 | .resolve("nisse-translation.properties")),
66 | PropertyKeyNamingStrategies.sourcePrefixed(),
67 | PropertyKeyNamingStrategies.defaultStrategy()))
68 | .build();
69 | Map nisseProperties = nisseManager.createProperties(configuration);
70 | logger.info("Nisse injecting {} properties into User Properties", nisseProperties.size());
71 | if (Boolean.parseBoolean(request.getUserProperties().getProperty("nisse.dump", "false"))) {
72 | nisseProperties.forEach((k, v) -> logger.info("{}={}", k, v));
73 | }
74 | nisseProperties.forEach((k, v) -> {
75 | if (!userProperties.containsKey(k)) {
76 | request.getUserProperties().setProperty(k, v);
77 | }
78 | });
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/plugin3/src/main/java/eu/maveniverse/maven/nisse/plugin3/DumpPropertiesMojo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023-2024 Maveniverse Org.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v2.0
5 | * which accompanies this distribution, and is available at
6 | * https://www.eclipse.org/legal/epl-v20.html
7 | */
8 | package eu.maveniverse.maven.nisse.plugin3;
9 |
10 | import eu.maveniverse.maven.nisse.core.NisseConfiguration;
11 | import eu.maveniverse.maven.nisse.core.NisseManager;
12 | import eu.maveniverse.maven.nisse.core.PropertyKeyNamingStrategies;
13 | import eu.maveniverse.maven.nisse.core.simple.SimpleNisseConfiguration;
14 | import java.io.File;
15 | import java.io.IOException;
16 | import java.io.OutputStream;
17 | import java.nio.file.Files;
18 | import java.nio.file.Paths;
19 | import java.util.Map;
20 | import java.util.Properties;
21 | import javax.inject.Inject;
22 | import org.apache.maven.execution.MavenSession;
23 | import org.apache.maven.plugin.AbstractMojo;
24 | import org.apache.maven.plugin.MojoExecutionException;
25 | import org.apache.maven.plugins.annotations.Mojo;
26 | import org.apache.maven.plugins.annotations.Parameter;
27 | import org.slf4j.Logger;
28 | import org.slf4j.LoggerFactory;
29 |
30 | /**
31 | * Nisse dump-properties Mojo that dumps created properties to output.
32 | * Is mostly usable as some diagnostic/setup check.
33 | */
34 | @Mojo(name = "dump-properties", threadSafe = true)
35 | public class DumpPropertiesMojo extends AbstractMojo {
36 | private final Logger logger = LoggerFactory.getLogger(getClass());
37 |
38 | @Inject
39 | private MavenSession mavenSession;
40 |
41 | @Inject
42 | private NisseManager nisseManager;
43 |
44 | /**
45 | * If set, the dump will write out {@link java.util.Properties} into this file, otherwise the dump goes out
46 | * to logger.
47 | */
48 | @Parameter(property = "nisse.output")
49 | private File output;
50 |
51 | @Override
52 | public void execute() throws MojoExecutionException {
53 | try {
54 | NisseConfiguration configuration = SimpleNisseConfiguration.builder()
55 | .withSystemProperties(mavenSession.getSystemProperties())
56 | .withUserProperties(mavenSession.getUserProperties())
57 | .withCurrentWorkingDirectory(
58 | Paths.get(mavenSession.getRequest().getBaseDirectory()))
59 | .withSessionRootDirectory(mavenSession
60 | .getRequest()
61 | .getMultiModuleProjectDirectory()
62 | .toPath())
63 | .combinePropertyKeyNamingStrategy(PropertyKeyNamingStrategies.translated(
64 | PropertyKeyNamingStrategies.translationTableFromPropertiesFile(mavenSession
65 | .getRequest()
66 | .getMultiModuleProjectDirectory()
67 | .toPath()
68 | .resolve(".mvn")
69 | .resolve("nisse-translation.properties")),
70 | PropertyKeyNamingStrategies.sourcePrefixed(),
71 | PropertyKeyNamingStrategies.defaultStrategy()))
72 | .build();
73 | Map properties = nisseManager.createProperties(configuration);
74 | if (output == null) {
75 | logger.info("Dumping {} properties", properties.size());
76 | properties.forEach((k, v) -> logger.info("{}={}", k, v));
77 | } else {
78 | logger.info("Dumping {} properties to {}", properties.size(), output);
79 | try (OutputStream outputStream = Files.newOutputStream(output.toPath())) {
80 | Properties props = new Properties();
81 | props.putAll(properties);
82 | props.store(outputStream, null);
83 | }
84 | }
85 | } catch (IOException e) {
86 | throw new MojoExecutionException("Error while creating Nisse configuration", e);
87 | }
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/plugin3/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 |
15 | eu.maveniverse.maven.nisse
16 | nisse
17 | 0.6.4-SNAPSHOT
18 |
19 |
20 | eu.maveniverse.maven.plugins
21 | nisse-plugin3
22 | maven-plugin
23 |
24 | ${project.groupId}:${project.artifactId}
25 |
26 |
27 |
28 |
29 | eu.maveniverse.maven.nisse
30 | core
31 |
32 |
33 | *
34 | *
35 |
36 |
37 |
38 |
39 | eu.maveniverse.maven.nisse.sources
40 | file-source
41 |
42 |
43 | eu.maveniverse.maven.nisse.sources
44 | jgit-source
45 |
46 |
47 | eu.maveniverse.maven.nisse.sources
48 | mvn-source
49 |
50 |
51 | eu.maveniverse.maven.nisse.sources
52 | os-source
53 |
54 |
55 |
56 |
57 | org.slf4j
58 | slf4j-api
59 | provided
60 |
61 |
62 | org.apache.maven.plugin-tools
63 | maven-plugin-annotations
64 | ${version.maven-plugin-tools}
65 | provided
66 |
67 |
68 | org.apache.maven
69 | maven-core
70 | ${maven3Version}
71 | provided
72 |
73 |
74 | org.apache.maven
75 | maven-model
76 | ${maven3Version}
77 | provided
78 |
79 |
80 |
81 | javax.inject
82 | javax.inject
83 | provided
84 |
85 |
86 | org.eclipse.sisu
87 | org.eclipse.sisu.inject
88 | provided
89 |
90 |
91 |
92 |
93 | org.junit.jupiter
94 | junit-jupiter-api
95 | test
96 |
97 |
98 | org.slf4j
99 | slf4j-simple
100 | test
101 |
102 |
103 |
104 |
105 |
106 |
107 | org.apache.maven.plugins
108 | maven-plugin-plugin
109 |
110 | nisse
111 | ${requireRuntimeMavenVersion.range}
112 |
113 | [1.8,)
114 |
115 |
116 |
117 |
118 |
119 |
--------------------------------------------------------------------------------
/it/extension4-its/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 | 4.0.0
13 |
14 |
15 | eu.maveniverse.maven.nisse.it
16 | it
17 | 0.6.4-SNAPSHOT
18 |
19 |
20 | extension4-its
21 | pom
22 |
23 | ${project.groupId}:${project.artifactId}
24 |
25 |
26 | true
27 |
28 |
29 |
30 |
31 | eu.maveniverse.maven.nisse
32 | extension4
33 |
34 |
35 |
36 |
37 |
38 | run-its
39 |
40 |
41 |
42 | org.apache.maven.plugins
43 | maven-dependency-plugin
44 |
45 |
46 | prepare-maven-distro
47 |
48 | unpack
49 |
50 | generate-test-resources
51 |
52 |
53 |
54 | org.apache.maven
55 | apache-maven
56 | ${maven4Version}
57 | bin
58 | zip
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 | org.apache.maven.plugins
67 | maven-invoker-plugin
68 |
69 | ${skipInvoker}
70 | ${project.build.directory}/dependency/apache-maven-${maven4Version}
71 | ${project.build.directory}/it
72 | ${project.build.directory}/it-repo
73 | true
74 |
75 | */pom.xml
76 |
77 | setup
78 | verify
79 | false
80 |
81 | !ci-friendly
82 |
83 |
84 |
85 | integration-test
86 | none
87 |
88 |
89 | run-its
90 |
91 | install
92 | run
93 |
94 | integration-test
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 | jdk17+
103 |
104 | [17,)
105 |
106 |
107 | false
108 |
109 |
110 |
111 |
112 |
--------------------------------------------------------------------------------