Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flag to fail on keymap duplicate key item #599

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/it/multipleKeysMap-duplicates-fail/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#
# 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.
#
invoker.buildResult = failure
16 changes: 16 additions & 0 deletions src/it/multipleKeysMap-duplicates-fail/keysmap1.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# 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.
#

commons-beanutils:commons-beanutils:1.7.0 = noSig
commons-logging:commons-logging:1.0.3 = noSig
16 changes: 16 additions & 0 deletions src/it/multipleKeysMap-duplicates-fail/keysmap2.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# 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.
#

commons-beanutils:commons-beanutils:1.7.0 = noSig
commons-logging:commons-logging:1.0.3 = noSig
61 changes: 61 additions & 0 deletions src/it/multipleKeysMap-duplicates-fail/pom-test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~
~ 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>test</groupId>
<artifactId>it-test-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath/>
</parent>

<artifactId>test</artifactId>
<packaging>pom</packaging>

<dependencies>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.7.0</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.simplify4u.plugins</groupId>
<artifactId>pgpverify-maven-plugin</artifactId>
<version>@project.version@</version>
<configuration>
<keysMapLocations>
<keysMapLocation>${project.basedir}/keysmap1.list</keysMapLocation>
<keysMapLocation>${project.basedir}/keysmap2.list</keysMapLocation>
</keysMapLocations>
<failDuplicateKeyItem>true</failDuplicateKeyItem>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
16 changes: 16 additions & 0 deletions src/it/multipleKeysMap-duplicates-fail/postbuild.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* 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.
*/
buildLog = new File(basedir, 'build.log').text

assert buildLog.matches('(?s).*Failing for the duplicate key item was found.*')
16 changes: 16 additions & 0 deletions src/it/multipleKeysMap-duplicates-log/keysmap1.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# 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.
#

commons-beanutils:commons-beanutils:1.7.0 = noSig
commons-logging:commons-logging:1.0.3 = noSig
16 changes: 16 additions & 0 deletions src/it/multipleKeysMap-duplicates-log/keysmap2.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# 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.
#

commons-beanutils:commons-beanutils:1.7.0 = noSig
commons-logging:commons-logging:1.0.3 = noSig
60 changes: 60 additions & 0 deletions src/it/multipleKeysMap-duplicates-log/pom-test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~
~ 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>test</groupId>
<artifactId>it-test-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath/>
</parent>

<artifactId>test</artifactId>
<packaging>pom</packaging>

<dependencies>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.7.0</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.simplify4u.plugins</groupId>
<artifactId>pgpverify-maven-plugin</artifactId>
<version>@project.version@</version>
<configuration>
<keysMapLocations>
<keysMapLocation>${project.basedir}/keysmap1.list</keysMapLocation>
<keysMapLocation>${project.basedir}/keysmap2.list</keysMapLocation>
</keysMapLocations>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
17 changes: 17 additions & 0 deletions src/it/multipleKeysMap-duplicates-log/postbuild.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* 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.
*/
buildLog = new File(basedir, 'build.log').text

assert buildLog.matches('(?m)(?s).*^\\[WARNING] Duplicate key item: noSig in: keysMap: (?-s).*\\/keysmap2.list lineNumber: 15$(?s).*')
assert buildLog.matches('(?m)(?s).*^\\[WARNING] Duplicate key item: noSig in: keysMap: (?-s).*\\/keysmap2.list lineNumber: 16$(?s).*')
15 changes: 15 additions & 0 deletions src/it/multipleKeysMap-no-duplicates/keysmap1.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#
# 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.
#

commons-beanutils:commons-beanutils:1.7.0 = noSig
15 changes: 15 additions & 0 deletions src/it/multipleKeysMap-no-duplicates/keysmap2.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#
# 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.
#

commons-logging:commons-logging:1.0.3 = noSig
61 changes: 61 additions & 0 deletions src/it/multipleKeysMap-no-duplicates/pom-test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~
~ 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>test</groupId>
<artifactId>it-test-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath/>
</parent>

<artifactId>test</artifactId>
<packaging>pom</packaging>

<dependencies>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.7.0</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.simplify4u.plugins</groupId>
<artifactId>pgpverify-maven-plugin</artifactId>
<version>@project.version@</version>
<configuration>
<keysMapLocations>
<keysMapLocation>${project.basedir}/keysmap1.list</keysMapLocation>
<keysMapLocation>${project.basedir}/keysmap2.list</keysMapLocation>
</keysMapLocations>
<failDuplicateKeyItem>true</failDuplicateKeyItem>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
16 changes: 16 additions & 0 deletions src/it/multipleKeysMap-no-duplicates/postbuild.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* 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.
*/
buildLog = new File(basedir, 'build.log').text

assert !buildLog.matches('(?s).*\\[WARNING] Duplicate key item: .*')
14 changes: 14 additions & 0 deletions src/main/java/org/simplify4u/plugins/CheckMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,16 @@ public static class VerificationResult {
@Parameter(property = "pgpverify.reportWrite", defaultValue = "false")
private boolean reportWrite;

/**
* <p>
* Indicate if build should fail if duplicate item is found in key maps.
* </p>
*
* @since 1.19.0
*/
@Parameter(property = "pgpverify.failDuplicateKeyItem", defaultValue = "false")
private boolean failDuplicateKeyItem;

@Override
protected String getMojoName() {
return MOJO_NAME;
Expand Down Expand Up @@ -335,6 +345,10 @@ protected void processVerificationResult(Collection<VerificationResult> verifica
if (verificationResult.stream().anyMatch(result -> result.error)) {
throw new PGPMojoException("Signature errors");
}

if (failDuplicateKeyItem && keysMap.isWithDuplicateKeyItems()) {
throw new DuplicateKeyMapKeyItemException();
}
}


Expand Down
Loading
Loading