diff --git a/.build/update-pom-property b/.build/update-pom-property new file mode 100755 index 0000000..026d371 --- /dev/null +++ b/.build/update-pom-property @@ -0,0 +1,25 @@ +#!/usr/bin/sh + +set -e + +if [ $# -lt 2 ] || [ $# -gt 3 ]; then + printf "Usage: %s [path]\n" "$0" + printf " path defaults to current directory\n" + exit 1 +fi + +PROP_NAME="$1" +NEW_VALUE="$2" +SEARCH_PATH="${3:-.}" + +find "$SEARCH_PATH" \ + \( -type d -name src -o -type d -name target \) -prune -o \ + -type f -name pom.xml -print | +while read -r pom; do + sed -i \ + "s|\(<[[:space:]]*${PROP_NAME}[[:space:]]*>[[:space:]]*\)[^<]*\([[:space:]]*\)|\1${NEW_VALUE}\2|g" \ + "$pom" +done + +printf "Updated %s to %s under %s\n" "${PROP_NAME}" "${NEW_VALUE}" "${SEARCH_PATH}" + diff --git a/.mvn/extensions.xml b/.mvn/extensions.xml index e983533..4e99a7c 100644 --- a/.mvn/extensions.xml +++ b/.mvn/extensions.xml @@ -22,6 +22,6 @@ net.runeduniverse.tools.maven.r4m r4m-maven-extension - 1.0.1 + 1.1.1 diff --git a/Jenkinsfile b/Jenkinsfile index 434cd4a..27a4f99 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,22 +1,29 @@ -def evalValue(expression, path) { +def evalValue(expression, path = null) { return sh( returnStdout: true, - script: "mvn org.apache.maven.plugins:maven-help-plugin:evaluate -Dexpression=${ expression } -q -DforceStdout -pl=${ path } | tail -1") + script: "mvn org.apache.maven.plugins:maven-help-plugin:evaluate -Dexpression=${ expression } -q -DforceStdout ${ path==null ? '' : ('-pl='+path) } | tail -1") } -def installArtifact(mod) { +def getToolchainId(mod) { + if(mod.hasTag('jdk-11')) + return 'toolchain-openjdk-11'; + return 'toolchain-openjdk-1-8-0'; +} + +def installArtifact(mod, parent = null) { if(!mod.active()) { skipStage() return } + def relPath = (parent == null ? '.' : mod.relPathFrom(parent)) // get module metadata - def groupId = evalValue('project.groupId', mod.relPathFrom('maven-parent')) - def artifactId = evalValue('project.artifactId', mod.relPathFrom('maven-parent')) - def version = evalValue('project.version', mod.relPathFrom('maven-parent')) + def groupId = evalValue('project.groupId', relPath) + def artifactId = evalValue('project.artifactId', relPath) + def version = evalValue('project.version', relPath) echo "Building: ${ groupId }:${ artifactId }:${ version }" try { - sh "mvn-dev -P ${ REPOS },toolchain-openjdk-1-8-0,install -pl=${ mod.relPathFrom('maven-parent') }" + sh "mvn-dev -P ${ REPOS },${ getToolchainId(mod) },ci-install -pl=${ relPath }" } finally { - def baseName="${ artifactId }-${ version }" + def baseName = "${ artifactId }-${ version }" // create spec .pom in target/ path sh "cp -T '${ mod.path() }/pom.xml' '${ mod.path() }/target/${ baseName }.pom'" // archive artifacts @@ -45,7 +52,29 @@ def installArtifact(mod) { } } -node { +def testArtifacts(toolchainId, tag, parent, flags = []) { + stage(tag) { + def mods = getModules(withTags: [ 'test', tag ]); + + if(!mods) { + skipStage() + return + } + + def modPaths = mods.collect({ it.relPathFrom(parent) }).join(','); + def testFlags = flags.collect({ "-D${ it }" }).join(' '); + + sh "mvn-dev -P ${ REPOS },${ toolchainId },ci-test-build -pl=${ modPaths } ${ testFlags }" + sh "mvn-dev --fail-never -P ${ REPOS },${ toolchainId },ci-test-exec,test-system -pl=${ modPaths } ${ testFlags }" + // check tests, archive reports in case junit flags errors + junit '*/target/surefire-reports/*.xml' + if(currentBuild.resultIsWorseOrEqualTo('UNSTABLE')) { + archiveArtifacts artifacts: '*/target/surefire-reports/*.xml' + } + } +} + +node( label: 'linux' ) { withModules { tool(name: 'maven-latest', type: 'maven') @@ -72,27 +101,29 @@ node { addModule id: 'maven-parent', path: '.', name: 'Maven Parent', tags: [ 'parent' ] addModule id: 'java-utils-bom', path: 'java-utils-bom', name: 'Bill of Materials', tags: [ 'bom' ] - addModule id: 'java-utils-async-api', path: 'java-utils-async-api', name: 'Java Async Utils [API]', tags: [ 'build1a', 'pack-jar' ] - addModule id: 'java-utils-async', path: 'java-utils-async', name: 'Java Async Utils', tags: [ 'test', 'build1', 'pack-jar' ] - addModule id: 'java-utils-chain-api', path: 'java-utils-chain-api', name: 'Java Chain Library [API]', tags: [ 'build2a', 'pack-jar' ] - addModule id: 'java-utils-chain', path: 'java-utils-chain', name: 'Java Chain Library', tags: [ 'test', 'build2', 'pack-jar' ] - addModule id: 'java-utils-common-api', path: 'java-utils-common-api', name: 'Java Common Utils [API]', tags: [ 'build1a', 'pack-jar' ] - addModule id: 'java-utils-common', path: 'java-utils-common', name: 'Java Common Utils', tags: [ 'test', 'build1', 'pack-jar' ] - addModule id: 'java-utils-conditional-api', path: 'java-utils-conditional-api', name: 'Java Conditional Utils [API]', tags: [ 'build2a', 'pack-jar' ] - addModule id: 'java-utils-conditional', path: 'java-utils-conditional', name: 'Java Conditional Utils', tags: [ 'test', 'build2', 'pack-jar' ] - addModule id: 'java-utils-config-api', path: 'java-utils-config-api', name: 'Java Config Utils [API]', tags: [ 'build1a', 'pack-jar' ] - addModule id: 'java-utils-config', path: 'java-utils-config', name: 'Java Config Utils', tags: [ 'test', 'build1', 'pack-jar' ] - addModule id: 'java-utils-errors', path: 'java-utils-errors', name: 'Java Error Handling Library', tags: [ 'test', 'build1', 'pack-jar' ] - addModule id: 'java-utils-logging-api', path: 'java-utils-logging-api', name: 'Java Logging Tools [API]', tags: [ 'build1a', 'pack-jar' ] - addModule id: 'java-utils-logging', path: 'java-utils-logging', name: 'Java Logging Tools', tags: [ 'test', 'build1', 'pack-jar' ] - addModule id: 'java-utils-maven3-api', path: 'java-utils-maven3-api', name: 'Java Maven3 Utils [API]', tags: [ 'build1a', 'pack-jar' ] - addModule id: 'java-utils-maven3', path: 'java-utils-maven3', name: 'Java Maven3 Utils', tags: [ 'test', 'build1', 'pack-jar' ] - addModule id: 'java-utils-maven3-ext-api', path: 'java-utils-maven3-ext-api', name: 'Java Maven3 Extension Utils [API]', tags: [ 'build3a', 'pack-jar' ] - addModule id: 'java-utils-maven3-ext', path: 'java-utils-maven3-ext', name: 'Java Maven3 Extension Utils', tags: [ 'test', 'build3', 'pack-jar' ] - addModule id: 'java-utils-plexus', path: 'java-utils-plexus', name: 'Java Plexus Utils', tags: [ 'test', 'build2', 'pack-jar' ] - addModule id: 'java-utils-scanner-api', path: 'java-utils-scanner-api', name: 'Java Scanner [API]', tags: [ 'build2a', 'pack-jar' ] - addModule id: 'java-utils-scanner', path: 'java-utils-scanner', name: 'Java Scanner', tags: [ 'test', 'build2', 'pack-jar' ] + addModule id: 'java-utils-async-api', path: 'java-utils-async-api', name: 'Java Async Utils [API]', tags: [ 'build1a', 'pack-jar', 'jdk-1.8.0' ] + addModule id: 'java-utils-async', path: 'java-utils-async', name: 'Java Async Utils', tags: [ 'test', 'build1', 'pack-jar', 'jdk-1.8.0' ] + addModule id: 'java-utils-chain-api', path: 'java-utils-chain-api', name: 'Java Chain Library [API]', tags: [ 'build2a', 'pack-jar', 'jdk-1.8.0' ] + addModule id: 'java-utils-chain', path: 'java-utils-chain', name: 'Java Chain Library', tags: [ 'test', 'build2', 'pack-jar', 'jdk-1.8.0' ] + addModule id: 'java-utils-common-api', path: 'java-utils-common-api', name: 'Java Common Utils [API]', tags: [ 'build1a', 'pack-jar', 'jdk-1.8.0' ] + addModule id: 'java-utils-common', path: 'java-utils-common', name: 'Java Common Utils', tags: [ 'test', 'build1', 'pack-jar', 'jdk-1.8.0' ] + addModule id: 'java-utils-conditional-api', path: 'java-utils-conditional-api', name: 'Java Conditional Utils [API]', tags: [ 'build2a', 'pack-jar', 'jdk-1.8.0' ] + addModule id: 'java-utils-conditional', path: 'java-utils-conditional', name: 'Java Conditional Utils', tags: [ 'test', 'build2', 'pack-jar', 'jdk-1.8.0' ] + addModule id: 'java-utils-config-api', path: 'java-utils-config-api', name: 'Java Config Utils [API]', tags: [ 'build1a', 'pack-jar', 'jdk-1.8.0' ] + addModule id: 'java-utils-config', path: 'java-utils-config', name: 'Java Config Utils', tags: [ 'test', 'build1', 'pack-jar', 'jdk-1.8.0' ] + addModule id: 'java-utils-errors', path: 'java-utils-errors', name: 'Java Error Handling Library', tags: [ 'test', 'build1', 'pack-jar', 'jdk-1.8.0' ] + addModule id: 'java-utils-logging-api', path: 'java-utils-logging-api', name: 'Java Logging Tools [API]', tags: [ 'build1a', 'pack-jar', 'jdk-1.8.0' ] + addModule id: 'java-utils-logging', path: 'java-utils-logging', name: 'Java Logging Tools', tags: [ 'test', 'build1', 'pack-jar', 'jdk-1.8.0' ] + addModule id: 'java-utils-maven3-api', path: 'java-utils-maven3-api', name: 'Java Maven3 Utils [API]', tags: [ 'build1a', 'pack-jar', 'jdk-1.8.0' ] + addModule id: 'java-utils-maven3', path: 'java-utils-maven3', name: 'Java Maven3 Utils', tags: [ 'test', 'build1', 'pack-jar', 'jdk-1.8.0' ] + addModule id: 'java-utils-maven3-ext-api', path: 'java-utils-maven3-ext-api', name: 'Java Maven3 Extension Utils [API]', tags: [ 'build3a', 'pack-jar', 'jdk-1.8.0' ] + addModule id: 'java-utils-maven3-ext', path: 'java-utils-maven3-ext', name: 'Java Maven3 Extension Utils', tags: [ 'test', 'build3', 'pack-jar', 'jdk-1.8.0' ] + addModule id: 'java-utils-plexus', path: 'java-utils-plexus', name: 'Java Plexus Utils', tags: [ 'test', 'build2', 'pack-jar', 'jdk-1.8.0' ] + addModule id: 'java-utils-scanner-api', path: 'java-utils-scanner-api', name: 'Java Scanner [API]', tags: [ 'build2a', 'pack-jar', 'jdk-1.8.0' ] + addModule id: 'java-utils-scanner', path: 'java-utils-scanner', name: 'Java Scanner', tags: [ 'test', 'build2', 'pack-jar', 'jdk-1.8.0' ] } + def parentMod = getModule(id: 'maven-parent'); + def bomMod = getModule(id: 'java-utils-bom'); stage('Init Modules') { sshagent (credentials: ['RunedUniverse-Jenkins']) { @@ -101,7 +132,7 @@ node { mod.activate( !mod.hasTag('skip') && sh( returnStdout: true, - script: "git-check-version-tag ${ mod.id() } ${ mod.relPathFrom('maven-parent') }" + script: "git-check-version-tag ${ mod.id() } ${ mod.relPathFrom(parentMod) }" ) == '1' ); } @@ -112,50 +143,56 @@ node { } stage('Update Maven Repo') { + echo 'purging local maven repository' + sh "mvn-dev -P ${ REPOS } dependency:purge-local-repository -DactTransitively=false -DreResolve=false" + + echo 'caching validation dependencies' + sh "mvn-dev -P ${ REPOS },ci-validate dependency:resolve-plugins dependency:resolve -U --fail-never" + if(checkAllModules(match: 'all', active: false)) { - skipStage() - return + echo 'skipping build dependency download » unused' + } else { + echo 'caching build dependencies' + sh "mvn-dev -P ${ REPOS },ci-install dependency:resolve -U --fail-never" } - sh "mvn-dev -P ${ REPOS } dependency:purge-local-repository -DactTransitively=false -DreResolve=false" - sh "mvn-dev -P ${ REPOS },install,validate dependency:go-offline -U --fail-never" } stage('Code Validation') { - sh "mvn-dev -P ${ REPOS },validate,license-apache2-approve,license-epl-v10-approve --fail-at-end -T1C" + sh "mvn-dev -P ${ REPOS },ci-validate,license-apache2-approve,license-epl-v10-approve --fail-at-end -T1C" } bundleContext { stage('Install Maven Parent') { - installArtifact( getModule(id: 'maven-parent') ); + installArtifact( parentMod ); } stage('Install - BOMs') { perModule(withTagIn: [ 'bom' ]) { - installArtifact( module ); + installArtifact( getModule(), parentMod ); } } stage('Build [1st Level]') { perModule(withTagIn: [ 'build1a' ]) { - installArtifact( module ); + installArtifact( getModule(), parentMod ); } perModule(withTagIn: [ 'build1' ]) { - installArtifact( module ); + installArtifact( getModule(), parentMod ); } } stage('Build [2nd Level]') { perModule(withTagIn: [ 'build2a' ]) { - installArtifact( module ); + installArtifact( getModule(), parentMod ); } perModule(withTagIn: [ 'build2' ]) { - installArtifact( module ); + installArtifact( getModule(), parentMod ); } } stage('Build [3rd Level]') { perModule(withTagIn: [ 'build3a' ]) { - installArtifact( module ); + installArtifact( getModule(), parentMod ); } perModule(withTagIn: [ 'build3' ]) { - installArtifact( module ); + installArtifact( getModule(), parentMod ); } } @@ -164,13 +201,13 @@ node { skipStage() return } - sh "mvn-dev -P ${ REPOS },toolchain-openjdk-1-8-0,build-tests" - sh "mvn-dev --fail-never -P ${ REPOS },toolchain-openjdk-1-8-0,test-junit-jupiter,test-system" - // check tests, archive reports in case junit flags errors - junit '*/target/surefire-reports/*.xml' - if(currentBuild.resultIsWorseOrEqualTo('UNSTABLE')) { - archiveArtifacts artifacts: '*/target/surefire-reports/*.xml' - } + + echo 'force update bom version for tests -> test for possible collisions caused by this update' + def bomVersion = evalValue('project.version', bomMod.relPathFrom(parentMod)); + def flags = [ "runeduniverse-utils-bom-version=${ bomVersion }" ]; + + testArtifacts('toolchain-openjdk-1-8-0', 'jdk-1.8.0', parentMod, flags); + testArtifacts('toolchain-openjdk-11', 'jdk-11', parentMod, flags); } stage('Package Build Result') { @@ -209,9 +246,9 @@ node { return } deployArtifacts( bundle: mod.id(), repo: 'nexus-runeduniverse>maven-releases' ) - def groupId = evalValue('project.groupId', mod.relPathFrom('maven-parent')) - def artifactId = evalValue('project.artifactId', mod.relPathFrom('maven-parent')) - def version = evalValue('project.version', mod.relPathFrom('maven-parent')) + def groupId = evalValue('project.groupId', mod.relPathFrom(parentMod)) + def artifactId = evalValue('project.artifactId', mod.relPathFrom(parentMod)) + def version = evalValue('project.version', mod.relPathFrom(parentMod)) sshagent (credentials: ['RunedUniverse-Jenkins']) { sh "git tag -a ${ mod.id() }/v${ version } -f -m '[artifact] ${ groupId }:${ artifactId }:${ version }'" sh "git push origin ${ mod.id() }/v${ version }" diff --git a/java-utils-async-api/pom.xml b/java-utils-async-api/pom.xml index bf05ef4..d28b780 100644 --- a/java-utils-async-api/pom.xml +++ b/java-utils-async-api/pom.xml @@ -1,6 +1,6 @@ 1.8 - 2.0.0 + 2.0.1 diff --git a/java-utils-common/src/main/java/net/runeduniverse/lib/utils/common/AbstractDataMap.java b/java-utils-common/src/main/java/net/runeduniverse/lib/utils/common/AbstractDataMap.java index f43147d..a09f9ff 100644 --- a/java-utils-common/src/main/java/net/runeduniverse/lib/utils/common/AbstractDataMap.java +++ b/java-utils-common/src/main/java/net/runeduniverse/lib/utils/common/AbstractDataMap.java @@ -1,5 +1,5 @@ /* - * Copyright © 2025 VenaNocta (venanocta@gmail.com) + * Copyright © 2026 VenaNocta (venanocta@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/java-utils-common/src/main/java/net/runeduniverse/lib/utils/common/CollectionUtils.java b/java-utils-common/src/main/java/net/runeduniverse/lib/utils/common/CollectionUtils.java index e6b9f7d..a38de3c 100644 --- a/java-utils-common/src/main/java/net/runeduniverse/lib/utils/common/CollectionUtils.java +++ b/java-utils-common/src/main/java/net/runeduniverse/lib/utils/common/CollectionUtils.java @@ -1,5 +1,5 @@ /* - * Copyright © 2025 VenaNocta (venanocta@gmail.com) + * Copyright © 2026 VenaNocta (venanocta@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,8 +50,8 @@ public static final T last(final Collection collection) { return deque.getLast(); } for (Iterator i = collection.iterator(); i.hasNext();) { - boolean next = i.hasNext(); final T obj = (T) i.next(); + boolean next = i.hasNext(); if (!next) return obj; } @@ -72,12 +72,12 @@ public static final T lastNotNull(final Collection collection) { // otherwise search everything T value = null; for (Iterator i = collection.iterator(); i.hasNext();) { - boolean next = i.hasNext(); final T obj = (T) i.next(); + boolean next = i.hasNext(); if (obj != null) value = obj; if (!next) - return obj; + return value; } return value; } diff --git a/java-utils-common/src/main/java/net/runeduniverse/lib/utils/common/ComparisonUtils.java b/java-utils-common/src/main/java/net/runeduniverse/lib/utils/common/ComparisonUtils.java index b0ef24f..6388e70 100644 --- a/java-utils-common/src/main/java/net/runeduniverse/lib/utils/common/ComparisonUtils.java +++ b/java-utils-common/src/main/java/net/runeduniverse/lib/utils/common/ComparisonUtils.java @@ -1,5 +1,5 @@ /* - * Copyright © 2025 VenaNocta (venanocta@gmail.com) + * Copyright © 2026 VenaNocta (venanocta@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/java-utils-common/src/main/java/net/runeduniverse/lib/utils/common/HashDataMap.java b/java-utils-common/src/main/java/net/runeduniverse/lib/utils/common/HashDataMap.java index 59dd9c2..7265813 100644 --- a/java-utils-common/src/main/java/net/runeduniverse/lib/utils/common/HashDataMap.java +++ b/java-utils-common/src/main/java/net/runeduniverse/lib/utils/common/HashDataMap.java @@ -1,5 +1,5 @@ /* - * Copyright © 2025 VenaNocta (venanocta@gmail.com) + * Copyright © 2026 VenaNocta (venanocta@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/java-utils-common/src/main/java/net/runeduniverse/lib/utils/common/HashUtils.java b/java-utils-common/src/main/java/net/runeduniverse/lib/utils/common/HashUtils.java index d096ebb..e05ce92 100644 --- a/java-utils-common/src/main/java/net/runeduniverse/lib/utils/common/HashUtils.java +++ b/java-utils-common/src/main/java/net/runeduniverse/lib/utils/common/HashUtils.java @@ -1,5 +1,5 @@ /* - * Copyright © 2025 VenaNocta (venanocta@gmail.com) + * Copyright © 2026 VenaNocta (venanocta@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/java-utils-common/src/main/java/net/runeduniverse/lib/utils/common/LinkedHashDataMap.java b/java-utils-common/src/main/java/net/runeduniverse/lib/utils/common/LinkedHashDataMap.java index b76af7a..0916331 100644 --- a/java-utils-common/src/main/java/net/runeduniverse/lib/utils/common/LinkedHashDataMap.java +++ b/java-utils-common/src/main/java/net/runeduniverse/lib/utils/common/LinkedHashDataMap.java @@ -1,5 +1,5 @@ /* - * Copyright © 2025 VenaNocta (venanocta@gmail.com) + * Copyright © 2026 VenaNocta (venanocta@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/java-utils-common/src/main/java/net/runeduniverse/lib/utils/common/ReflectionUtils.java b/java-utils-common/src/main/java/net/runeduniverse/lib/utils/common/ReflectionUtils.java index 9838302..d34bf69 100644 --- a/java-utils-common/src/main/java/net/runeduniverse/lib/utils/common/ReflectionUtils.java +++ b/java-utils-common/src/main/java/net/runeduniverse/lib/utils/common/ReflectionUtils.java @@ -1,5 +1,5 @@ /* - * Copyright © 2025 VenaNocta (venanocta@gmail.com) + * Copyright © 2026 VenaNocta (venanocta@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/java-utils-common/src/main/java/net/runeduniverse/lib/utils/common/StringUtils.java b/java-utils-common/src/main/java/net/runeduniverse/lib/utils/common/StringUtils.java index ee685c2..4aada57 100644 --- a/java-utils-common/src/main/java/net/runeduniverse/lib/utils/common/StringUtils.java +++ b/java-utils-common/src/main/java/net/runeduniverse/lib/utils/common/StringUtils.java @@ -1,5 +1,5 @@ /* - * Copyright © 2025 VenaNocta (venanocta@gmail.com) + * Copyright © 2026 VenaNocta (venanocta@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/java-utils-common/src/main/java/net/runeduniverse/lib/utils/common/StringVariableGenerator.java b/java-utils-common/src/main/java/net/runeduniverse/lib/utils/common/StringVariableGenerator.java index 617c21c..06ea6d4 100644 --- a/java-utils-common/src/main/java/net/runeduniverse/lib/utils/common/StringVariableGenerator.java +++ b/java-utils-common/src/main/java/net/runeduniverse/lib/utils/common/StringVariableGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright © 2025 VenaNocta (venanocta@gmail.com) + * Copyright © 2026 VenaNocta (venanocta@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/java-utils-common/src/test/java/net/runeduniverse/lib/utils/common/test/CollectionUtilsTest.java b/java-utils-common/src/test/java/net/runeduniverse/lib/utils/common/test/CollectionUtilsTest.java new file mode 100644 index 0000000..f3dab2e --- /dev/null +++ b/java-utils-common/src/test/java/net/runeduniverse/lib/utils/common/test/CollectionUtilsTest.java @@ -0,0 +1,122 @@ +/* + * Copyright © 2026 VenaNocta (venanocta@gmail.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.runeduniverse.lib.utils.common.test; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import net.runeduniverse.lib.utils.common.CollectionUtils; + +public class CollectionUtilsTest { + + protected final List list1; + protected final List list2; + + protected final Set set1; + + protected final Map map1; + + public CollectionUtilsTest() { + // seed test data + + this.list1 = Arrays.asList(// + "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", // + "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"); + this.list2 = Arrays.asList(// + null, "a", "b", "c", "d", "e", null, "f", "g", "h", "i", "j", "k", "l", "m", // + "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", null, "z", null, null); + + this.set1 = new HashSet(this.list1); + + this.map1 = new HashMap<>(); + for (int i = 0; i < 26; i++) { + this.map1.put(i, "" + (char) ('a' + i)); + } + } + + @Test + @Tag("system") + public void first_1() throws InterruptedException { + Assertions.assertEquals("a", CollectionUtils.first(this.list1)); + } + + @Test + @Tag("system") + public void firstNotNull_1() throws InterruptedException { + Assertions.assertEquals("a", CollectionUtils.firstNotNull(this.list2)); + } + + @Test + @Tag("system") + public void last_1() throws InterruptedException { + Assertions.assertEquals("z", CollectionUtils.last(this.list1)); + } + + @Test + @Tag("system") + public void lastNotNull_1() throws InterruptedException { + Assertions.assertEquals("z", CollectionUtils.lastNotNull(this.list2)); + } + + @Test + @Tag("system") + public void copy_list_1() throws InterruptedException { + List obj = CollectionUtils.copy(this.list1, LinkedList::new); + + Assertions.assertInstanceOf(LinkedList.class, obj); + Assertions.assertTrue(this.list1.containsAll(obj) && obj.containsAll(this.list1)); + } + + @Test + @Tag("system") + public void copy_set_1() throws InterruptedException { + Set obj = CollectionUtils.copy(this.set1, LinkedHashSet::new); + + Assertions.assertInstanceOf(LinkedHashSet.class, obj); + Assertions.assertTrue(this.set1.containsAll(obj) && obj.containsAll(this.set1)); + } + + @Test + @Tag("system") + public void copy_map_1() throws InterruptedException { + Map obj = CollectionUtils.copy(this.map1, LinkedHashMap::new); + + Assertions.assertInstanceOf(LinkedHashMap.class, obj); + + Set> entriesMap1 = this.map1.entrySet(); + Set> entriesObj = this.map1.entrySet(); + Assertions.assertTrue(entriesMap1.containsAll(entriesObj) && entriesObj.containsAll(entriesMap1)); + + Assertions.assertEquals("e", this.map1.get(4)); + Assertions.assertEquals("e", obj.get(4)); + Assertions.assertEquals("z", this.map1.get(25)); + Assertions.assertEquals("z", obj.get(25)); + Assertions.assertEquals(null, this.map1.get(26)); + Assertions.assertEquals(null, obj.get(26)); + } +} diff --git a/java-utils-conditional-api/pom.xml b/java-utils-conditional-api/pom.xml index 942c6eb..fce3929 100644 --- a/java-utils-conditional-api/pom.xml +++ b/java-utils-conditional-api/pom.xml @@ -1,6 +1,6 @@ - 2.0.0 + 2.0.1 diff --git a/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/api/ExtensionIndex.java b/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/api/ExtensionIndex.java index ef5a223..d8fbb5a 100644 --- a/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/api/ExtensionIndex.java +++ b/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/api/ExtensionIndex.java @@ -1,5 +1,5 @@ /* - * Copyright © 2025 VenaNocta (venanocta@gmail.com) + * Copyright © 2026 VenaNocta (venanocta@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import org.apache.maven.model.Plugin; import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.classworlds.ClassWorld; import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.eclipse.aether.RepositorySystemSession; @@ -27,13 +28,17 @@ public interface ExtensionIndex { + public static final String REALM_ID_MAVEN_EXT = "maven.ext"; + + public ClassWorld getClassWorld(); + public void discoverExtensions(); - public boolean discoverExtRealm(final ClassRealm realm); + public boolean discoverExtRealm(ClassRealm realm); - public void seedExtensions(final MavenProject mvnProject); + public void seedExtensions(MavenProject mvnProject); - public void discoverPlugins(final RepositorySystemSession repoSysSession, final MavenProject mvnProject); + public void discoverPlugins(RepositorySystemSession repoSysSession, MavenProject mvnProject); public Set getCoreExtensions(); @@ -43,4 +48,6 @@ public interface ExtensionIndex { public Map> getInvalidPlugins(); + public Set findExtensions(String groupId, String artifactId); + } diff --git a/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/api/ExtensionTool.java b/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/api/ExtensionTool.java index 687559c..1c75e86 100644 --- a/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/api/ExtensionTool.java +++ b/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/api/ExtensionTool.java @@ -1,5 +1,5 @@ /* - * Copyright © 2025 VenaNocta (venanocta@gmail.com) + * Copyright © 2026 VenaNocta (venanocta@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/data/api/Extension.java b/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/data/api/Extension.java index b43198e..d8c2abc 100644 --- a/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/data/api/Extension.java +++ b/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/data/api/Extension.java @@ -1,5 +1,5 @@ /* - * Copyright © 2025 VenaNocta (venanocta@gmail.com) + * Copyright © 2026 VenaNocta (venanocta@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,10 +28,16 @@ public interface Extension { + public static final String REALM_ID_PLEXUS_CORE = "plexus.core"; + public static final String REALM_ID_CORE_EXT_PREFIX = "coreExtension>"; + public static final String REALM_ID_BUILD_EXT_PREFIX = "extension>"; + public ClassRealm getClassRealm(); public CodeSource getCodeSource(); + public ExtensionType getType(); + public String getGroupId(); public String getArtifactId(); diff --git a/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/data/api/ExtensionData.java b/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/data/api/ExtensionData.java index d4de942..11e1b3d 100644 --- a/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/data/api/ExtensionData.java +++ b/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/data/api/ExtensionData.java @@ -1,5 +1,5 @@ /* - * Copyright © 2025 VenaNocta (venanocta@gmail.com) + * Copyright © 2026 VenaNocta (venanocta@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/data/api/ExtensionType.java b/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/data/api/ExtensionType.java new file mode 100644 index 0000000..bc398e2 --- /dev/null +++ b/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/data/api/ExtensionType.java @@ -0,0 +1,20 @@ +/* + * Copyright © 2026 VenaNocta (venanocta@gmail.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.runeduniverse.lib.utils.maven3.ext.data.api; + +public enum ExtensionType { + PLEXUS, CORE, BUILD, UNKNOWN +} diff --git a/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/data/api/PluginData.java b/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/data/api/PluginData.java index b50ea72..44c89eb 100644 --- a/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/data/api/PluginData.java +++ b/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/data/api/PluginData.java @@ -1,5 +1,5 @@ /* - * Copyright © 2025 VenaNocta (venanocta@gmail.com) + * Copyright © 2026 VenaNocta (venanocta@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/eventspy/api/EventSpyDispatcherProxy.java b/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/eventspy/api/EventSpyDispatcherProxy.java index 7021ff2..38177f5 100644 --- a/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/eventspy/api/EventSpyDispatcherProxy.java +++ b/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/eventspy/api/EventSpyDispatcherProxy.java @@ -1,5 +1,5 @@ /* - * Copyright © 2025 VenaNocta (venanocta@gmail.com) + * Copyright © 2026 VenaNocta (venanocta@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/indexer/api/PluginBoundRegistry.java b/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/indexer/api/PluginBoundRegistry.java index b2aed79..c51a05c 100644 --- a/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/indexer/api/PluginBoundRegistry.java +++ b/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/indexer/api/PluginBoundRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright © 2025 VenaNocta (venanocta@gmail.com) + * Copyright © 2026 VenaNocta (venanocta@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/indexer/api/ProjectBoundEntry.java b/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/indexer/api/ProjectBoundEntry.java index f883012..424aaf0 100644 --- a/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/indexer/api/ProjectBoundEntry.java +++ b/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/indexer/api/ProjectBoundEntry.java @@ -1,5 +1,5 @@ /* - * Copyright © 2025 VenaNocta (venanocta@gmail.com) + * Copyright © 2026 VenaNocta (venanocta@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/indexer/api/ProjectBoundRegistry.java b/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/indexer/api/ProjectBoundRegistry.java index 258d49f..74c5f9b 100644 --- a/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/indexer/api/ProjectBoundRegistry.java +++ b/java-utils-maven3-ext-api/src/main/java/net/runeduniverse/lib/utils/maven3/ext/indexer/api/ProjectBoundRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright © 2025 VenaNocta (venanocta@gmail.com) + * Copyright © 2026 VenaNocta (venanocta@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/java-utils-maven3-ext/pom.xml b/java-utils-maven3-ext/pom.xml index c3aa4af..e32ce7f 100644 --- a/java-utils-maven3-ext/pom.xml +++ b/java-utils-maven3-ext/pom.xml @@ -1,6 +1,6 @@ - 2.0.0 + 2.0.1 @@ -175,13 +175,6 @@ src/main/plexus src/test/plexus - - - - generate-metadata - - - org.apache.maven.plugins diff --git a/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/DefaultExtensionIndex.java b/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/DefaultExtensionIndex.java index ec29dff..4d74b03 100644 --- a/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/DefaultExtensionIndex.java +++ b/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/DefaultExtensionIndex.java @@ -1,5 +1,5 @@ /* - * Copyright © 2025 VenaNocta (venanocta@gmail.com) + * Copyright © 2026 VenaNocta (venanocta@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,14 +50,13 @@ import static net.runeduniverse.lib.utils.common.CollectionUtils.copy; import static net.runeduniverse.lib.utils.common.CollectionUtils.unmodifiable; +import static net.runeduniverse.lib.utils.maven3.ext.data.api.Extension.REALM_ID_PLEXUS_CORE; +import static net.runeduniverse.lib.utils.maven3.ext.data.api.Extension.REALM_ID_CORE_EXT_PREFIX; +import static net.runeduniverse.lib.utils.maven3.ext.data.api.Extension.REALM_ID_BUILD_EXT_PREFIX; @Component(role = ExtensionIndex.class) public class DefaultExtensionIndex implements ExtensionIndex { - public static final String REALM_ID_PLEXUS_CORE = "plexus.core"; - public static final String REALM_ID_MAVEN_EXT = "maven.ext"; - public static final String REALM_ID_CORE_EXT_PREFIX = "coreExtension>"; - public static final String REALM_ID_BUILD_EXT_PREFIX = "extension>"; public static final String POM_PROP_FILE = "/META-INF/maven/*/*/pom.properties"; // supplier @@ -106,11 +105,16 @@ public DefaultExtensionIndex(final Supplier>> e this.invalidPlugins = new ConcurrentHashMap<>(); } + @Override + public ClassWorld getClassWorld() { + return this.container.getContainerRealm() + .getWorld(); + } + @Override public void discoverExtensions() { - final ClassRealm currentRealm = (ClassRealm) Thread.currentThread() - .getContextClassLoader(); - final ClassWorld world = currentRealm.getWorld(); + final ClassWorld world = this.container.getContainerRealm() + .getWorld(); ClassRealm searchRealm = world.getClassRealm(REALM_ID_MAVEN_EXT); if (searchRealm == null) @@ -226,7 +230,6 @@ protected Set fromExtRealm(final ClassRealm realm) { } else return set; - ext.setClassRealm(realm); set.add(ext); if (!ext.validate()) { @@ -330,10 +333,12 @@ protected void discoverPlugins(final RepositorySystemSession session, final Mave return; } + @Override public Set getCoreExtensions() { return unmodifiable(this.coreExtensions); } + @Override public Map> getExtensions() { final Map> map = this.extMapSupplier.get(); for (Entry> entry : this.extensionMap.entrySet()) { @@ -342,6 +347,7 @@ public Map> getExtensions() { return unmodifiable(map); } + @Override public Map> getExtPlugins() { final Map> map = this.pluginMapSupplier.get(); for (Entry> entry : this.extPlugins.entrySet()) { @@ -350,6 +356,7 @@ public Map> getExtPlugins() { return unmodifiable(map); } + @Override public Map> getInvalidPlugins() { final Map> map = this.pluginMapSupplier.get(); for (Entry> entry : this.invalidPlugins.entrySet()) { @@ -357,4 +364,24 @@ public Map> getInvalidPlugins() { } return unmodifiable(map); } + + @Override + public Set findExtensions(String groupId, String artifactId) { + final Set result = this.extSetSupplier.get(); + final boolean groupFilter = groupId != null; + final boolean artifactFilter = artifactId != null; + for (Entry> entry : this.realmMap.entrySet()) { + final Set set = entry.getValue(); + if (set == null) + continue; + for (Extension ext : set) { + if (groupFilter && !groupId.equals(ext.getGroupId())) + continue; + if (artifactFilter && !artifactId.equals(ext.getArtifactId())) + continue; + result.add(ext); + } + } + return result; + } } diff --git a/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/DefaultExtensionTool.java b/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/DefaultExtensionTool.java index b901382..92e3b87 100644 --- a/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/DefaultExtensionTool.java +++ b/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/DefaultExtensionTool.java @@ -1,5 +1,5 @@ /* - * Copyright © 2025 VenaNocta (venanocta@gmail.com) + * Copyright © 2026 VenaNocta (venanocta@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/MvnCorePatcher.java b/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/MvnCorePatcher.java index 863ca33..a712e77 100644 --- a/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/MvnCorePatcher.java +++ b/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/MvnCorePatcher.java @@ -1,5 +1,5 @@ /* - * Copyright © 2025 VenaNocta (venanocta@gmail.com) + * Copyright © 2026 VenaNocta (venanocta@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package net.runeduniverse.lib.utils.maven3.ext; import java.util.Collection; +import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Objects; @@ -37,20 +38,19 @@ import net.runeduniverse.lib.utils.maven3.ext.data.api.ExtensionData; import net.runeduniverse.lib.utils.maven3.ext.data.api.PluginData; +import static net.runeduniverse.lib.utils.maven3.ext.data.api.Extension.REALM_ID_PLEXUS_CORE; +import static net.runeduniverse.lib.utils.maven3.ext.api.ExtensionIndex.REALM_ID_MAVEN_EXT; + public class MvnCorePatcher { public static final String ERR_FAILED_TO_LOAD_MAVEN_EXTENSION_CLASSREALM = // "Failed to load maven-extension ClassRealm"; - public static final String REALM_ID_PLEXUS_CORE = "plexus.core"; - public static final String REALM_ID_MAVEN_EXT = "maven.ext"; - public static final String REALM_ID_CORE_EXT_PREFIX = "coreExtension>"; - public static final String REALM_ID_BUILD_EXT_PREFIX = "extension>"; - protected final ExtensionIndex extensionIndex; protected boolean coreExtension = false; protected boolean supportBuildExtension = false; + protected boolean m2eDetected = false; // supplier protected ClassRealmFactory extensionRealmFactory = null; // events @@ -118,9 +118,39 @@ public boolean patchMaven(final MavenSession mvnSession, final Patch patch) thro callInfo_PatchingStarted(); - final ClassRealm currentRealm = (ClassRealm) Thread.currentThread() + final ClassWorld world = this.extensionIndex.getClassWorld(); + final String realmIdMavenExt; + + final ClassLoader currentClassLoader = Thread.currentThread() .getContextClassLoader(); - final ClassWorld world = currentRealm.getWorld(); + final ClassRealm currentRealm; + + if (currentClassLoader instanceof ClassRealm) { + currentRealm = (ClassRealm) currentClassLoader; + realmIdMavenExt = REALM_ID_MAVEN_EXT; + } else { + // ---- this case only happens with m2e ---- + // because of that I can not infere how the extension is loaded + // => so I expect that only core-extensions are bootstrapped from outside the + // maven architecture! + if ("org.eclipse.osgi.internal.framework.ContextFinder".equals(currentClassLoader.getClass() + .getCanonicalName())) { + // yep - really sure it's m2e + this.m2eDetected = true; + // note: for some weird reason m2e creates the extension realm + // with id="maven.ext." + realmIdMavenExt = "maven.ext."; + } else { + realmIdMavenExt = REALM_ID_MAVEN_EXT; + } + + this.coreExtension = true; + // try to find the ClassRealm that contains the extensions + ClassRealm searchRealm = world.getClassRealm(realmIdMavenExt); + if (searchRealm == null) + searchRealm = world.getClassRealm(REALM_ID_PLEXUS_CORE); + currentRealm = searchRealm; + } // extLoadState= 2 -> system core ext | 1 -> core ext | 0 -> build ext final short extLoadState; @@ -135,7 +165,7 @@ public boolean patchMaven(final MavenSession mvnSession, final Patch patch) thro extLoadState = 2; } else if (this.coreExtension) { callInfo_SwitchRealmToMavenExt(); - realm = world.getRealm(REALM_ID_MAVEN_EXT); + realm = world.getRealm(realmIdMavenExt); extLoadState = 1; } else if (this.supportBuildExtension) { realm = createExtensionRealm(plexusCore, currentRealm); @@ -155,9 +185,13 @@ public boolean patchMaven(final MavenSession mvnSession, final Patch patch) thro this.extensionIndex.discoverExtensions(); - for (MavenProject mvnProject : mvnSession.getAllProjects()) { - this.extensionIndex.seedExtensions(mvnProject); - this.extensionIndex.discoverPlugins(mvnSession.getRepositorySession(), mvnProject); + final List allProjects = mvnSession.getAllProjects(); + if (allProjects != null) { + // in maven3 this is never null, except when m2e is in play! + for (MavenProject mvnProject : mvnSession.getAllProjects()) { + this.extensionIndex.seedExtensions(mvnProject); + this.extensionIndex.discoverPlugins(mvnSession.getRepositorySession(), mvnProject); + } } final Map> extensions = this.extensionIndex.getExtensions(); @@ -180,7 +214,7 @@ public boolean patchMaven(final MavenSession mvnSession, final Patch patch) thro } finally { callInfo_ResetRealm(); Thread.currentThread() - .setContextClassLoader(currentRealm); + .setContextClassLoader(currentClassLoader); } final Map> invalidPlugins = this.extensionIndex.getInvalidPlugins(); diff --git a/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/config/ConfigBuilder.java b/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/config/ConfigBuilder.java index ea779f8..bfe61fd 100644 --- a/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/config/ConfigBuilder.java +++ b/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/config/ConfigBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright © 2025 VenaNocta (venanocta@gmail.com) + * Copyright © 2026 VenaNocta (venanocta@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/data/DefaultExtension.java b/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/data/DefaultExtension.java index 5294695..349ec88 100644 --- a/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/data/DefaultExtension.java +++ b/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/data/DefaultExtension.java @@ -1,5 +1,5 @@ /* - * Copyright © 2025 VenaNocta (venanocta@gmail.com) + * Copyright © 2026 VenaNocta (venanocta@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,11 +31,13 @@ import net.runeduniverse.lib.utils.common.StringUtils; import net.runeduniverse.lib.utils.maven3.ext.data.api.Extension; +import net.runeduniverse.lib.utils.maven3.ext.data.api.ExtensionType; public class DefaultExtension implements Extension { protected ClassRealm realm = null; protected CodeSource source = null; + protected ExtensionType type = ExtensionType.UNKNOWN; protected String groupId = null; protected String artifactId = null; protected String version = null; @@ -54,6 +56,11 @@ public CodeSource getCodeSource() { return this.source; } + @Override + public ExtensionType getType() { + return this.type; + } + @Override public String getGroupId() { return this.groupId; @@ -91,6 +98,18 @@ public PluginDescriptor getPluginDescriptor(final MavenProject mvnProject) { @Override public void setClassRealm(final ClassRealm realm) { this.realm = realm; + + final String realmId = realm.getId(); + if (realmId == null) + this.type = ExtensionType.UNKNOWN; + else if (REALM_ID_PLEXUS_CORE.equals(realmId)) + this.type = ExtensionType.PLEXUS; + else if (realmId.startsWith(REALM_ID_CORE_EXT_PREFIX)) + this.type = ExtensionType.CORE; + else if (realmId.startsWith(REALM_ID_BUILD_EXT_PREFIX)) + this.type = ExtensionType.BUILD; + else + this.type = ExtensionType.UNKNOWN; } @Override diff --git a/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/data/UnmodifiableExtensionData.java b/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/data/UnmodifiableExtensionData.java index 106c95a..5c28b29 100644 --- a/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/data/UnmodifiableExtensionData.java +++ b/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/data/UnmodifiableExtensionData.java @@ -1,5 +1,5 @@ /* - * Copyright © 2025 VenaNocta (venanocta@gmail.com) + * Copyright © 2026 VenaNocta (venanocta@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/data/UnmodifiablePluginData.java b/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/data/UnmodifiablePluginData.java index 8e0478f..908c0e4 100644 --- a/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/data/UnmodifiablePluginData.java +++ b/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/data/UnmodifiablePluginData.java @@ -1,5 +1,5 @@ /* - * Copyright © 2025 VenaNocta (venanocta@gmail.com) + * Copyright © 2026 VenaNocta (venanocta@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/eventspy/DefaultEventSpyDispatcherProxy.java b/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/eventspy/DefaultEventSpyDispatcherProxy.java index ce9fd07..9f62533 100644 --- a/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/eventspy/DefaultEventSpyDispatcherProxy.java +++ b/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/eventspy/DefaultEventSpyDispatcherProxy.java @@ -1,5 +1,5 @@ /* - * Copyright © 2025 VenaNocta (venanocta@gmail.com) + * Copyright © 2026 VenaNocta (venanocta@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/indexer/APluginBoundRegistry.java b/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/indexer/APluginBoundRegistry.java index 2f7b382..da7e644 100644 --- a/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/indexer/APluginBoundRegistry.java +++ b/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/indexer/APluginBoundRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright © 2025 VenaNocta (venanocta@gmail.com) + * Copyright © 2026 VenaNocta (venanocta@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/indexer/AProjectBoundArchive.java b/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/indexer/AProjectBoundArchive.java index ffebc83..89ad8cd 100644 --- a/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/indexer/AProjectBoundArchive.java +++ b/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/indexer/AProjectBoundArchive.java @@ -1,5 +1,5 @@ /* - * Copyright © 2025 VenaNocta (venanocta@gmail.com) + * Copyright © 2026 VenaNocta (venanocta@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/indexer/AProjectBoundEntry.java b/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/indexer/AProjectBoundEntry.java index a97c97c..e2b18e5 100644 --- a/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/indexer/AProjectBoundEntry.java +++ b/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/indexer/AProjectBoundEntry.java @@ -1,5 +1,5 @@ /* - * Copyright © 2025 VenaNocta (venanocta@gmail.com) + * Copyright © 2026 VenaNocta (venanocta@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/indexer/AProjectBoundRegistry.java b/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/indexer/AProjectBoundRegistry.java index 001bca6..9029343 100644 --- a/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/indexer/AProjectBoundRegistry.java +++ b/java-utils-maven3-ext/src/main/java/net/runeduniverse/lib/utils/maven3/ext/indexer/AProjectBoundRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright © 2025 VenaNocta (venanocta@gmail.com) + * Copyright © 2026 VenaNocta (venanocta@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/java-utils-maven3-ext/src/test/java/net/runeduniverse/lib/utils/maven3/ext/test/package-info.java b/java-utils-maven3-ext/src/test/java/net/runeduniverse/lib/utils/maven3/ext/test/package-info.java index d83f30d..b8519ce 100644 --- a/java-utils-maven3-ext/src/test/java/net/runeduniverse/lib/utils/maven3/ext/test/package-info.java +++ b/java-utils-maven3-ext/src/test/java/net/runeduniverse/lib/utils/maven3/ext/test/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright © 2025 VenaNocta (venanocta@gmail.com) + * Copyright © 2026 VenaNocta (venanocta@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/java-utils-maven3/pom.xml b/java-utils-maven3/pom.xml index 798e3a2..c49b82c 100644 --- a/java-utils-maven3/pom.xml +++ b/java-utils-maven3/pom.xml @@ -1,6 +1,6 @@ - - 1.0.0 - - - - - - - - - - - - - - net.runeduniverse.tools.maven.r4m - r4m-maven-extension - - - - - - - net.runeduniverse.tools.maven.r4m - r4m-maven-extension - - - - - - - - - - - - - - - org.apache.maven.plugins - maven-clean-plugin - - - - - - - - - - - - - - - - - - - com.mycila - license-maven-plugin - - - - - - - org.apache.maven.plugins - maven-install-plugin - - - - - - - - - - - - - - - org.apache.maven.plugins - maven-site-plugin - - - - - - - - - - - org.apache.maven.plugins - maven-site-plugin - - - - - - - - - - - - - - - - - - - - - - - net.runeduniverse.tools.maven.r4m - r4m-maven-extension - - - - - - - - - - - - - - - - - - org.apache.maven.plugins - maven-clean-plugin - - - - - - - - - - - - - - - org.apache.maven.plugins - maven-toolchains-plugin - - - - - - com.mycila - license-maven-plugin - - - - - - net.revelc.code.formatter - formatter-maven-plugin - - - - - - - - - - - org.apache.maven.plugins - maven-resources-plugin - - - - - - - - - - - org.apache.maven.plugins - maven-resources-plugin - - - - - - - - - - org.apache.maven.plugins - maven-install-plugin - - - - - - - - - - - org.apache.maven.plugins - maven-site-plugin - - - - - - - - - - - org.apache.maven.plugins - maven-site-plugin - - - - - - - - - - - - - - - - - - - - jar - - - - - - - - - - - net.revelc.code.formatter - formatter-maven-plugin - - - - - - org.apache.maven.plugins - maven-toolchains-plugin - - - - - - - - - - org.apache.maven.plugins - maven-resources-plugin - - - - - - - - - - org.apache.maven.plugins - maven-resources-plugin - - - - - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - - - - - - - - - - - jar - - - - - - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - - - org.apache.maven.plugins - maven-source-plugin - - - - - - org.apache.maven.plugins - maven-source-plugin - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - - - - - - - - - - - - - - jar - - - - - - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - org.codehaus.plexus - plexus-component-metadata - - - - - - - - - - - - - - - - - - jar - - - - - - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - - - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - - - - - - - - diff --git a/pom.xml b/pom.xml index 8604c0a..9e5d403 100644 --- a/pom.xml +++ b/pom.xml @@ -1,6 +1,6 @@ + 3.10.0 3.1.0 3.1.0 3.2.0 @@ -118,6 +119,9 @@ 3.0.0-M1 2.23.0 4.2.rc1 + + 0.1.0 + 0.1.0 1.8.2 1.8.2 @@ -142,7 +146,7 @@ openjdk-1.8.0 - clean dev/install] + clean dev/install @@ -159,12 +163,12 @@ format - dev/validate + dev/[validate] - debug + ci-debug false @@ -173,34 +177,34 @@ - validate + ci-validate check/[validate]@pipeline - install + ci-install - clean@pipeline - install/install]@pipeline + install/clean@pipeline + install/install@pipeline - build-tests + ci-test-build - junit/test-compile]@pipeline + test/]test@pipeline - test-junit-jupiter + ci-test-exec - junit/validate@pipeline - junit/test@pipeline + test/validate@pipeline + test/[test]@pipeline @@ -229,9 +233,17 @@ + + + runeduniverse-releases + + https://nexus.runeduniverse.net/repository/maven-releases/ + + + - + repo-development @@ -241,6 +253,14 @@ + + + runeduniverse-development + + https://nexus.runeduniverse.net/repository/maven-development/ + + + @@ -397,6 +417,10 @@ + + org.apache.maven.plugins + maven-dependency-plugin + org.apache.maven.plugins maven-clean-plugin @@ -404,13 +428,6 @@ org.apache.maven.plugins maven-toolchains-plugin - - - - toolchain - - - net.revelc.code.formatter @@ -440,9 +457,22 @@ org.apache.maven.plugins maven-install-plugin + + net.runeduniverse.tools.maven.workflow + maven-pipeline-workflow + + + net.runeduniverse.tools.maven.workflow + maven-java-workflow + + + org.apache.maven.plugins + maven-dependency-plugin + ${plugin-maven-dependency-version} + org.apache.maven.plugins maven-clean-plugin @@ -485,7 +515,7 @@ ${plugin-mycila-license-version} - 2025 + 2026 VenaNocta venanocta@gmail.com @@ -595,6 +625,16 @@ maven-install-plugin ${plugin-maven-install-version} + + net.runeduniverse.tools.maven.workflow + maven-pipeline-workflow + ${plugin-workflow-pipeline-version} + + + net.runeduniverse.tools.maven.workflow + maven-java-workflow + ${plugin-workflow-java-version} +