Skip to content

Commit 032d6de

Browse files
authored
Fix: plugin ignores its own POM configuration due to wrong coordinates; re-enable integration tests (#114)
1 parent c18543d commit 032d6de

File tree

133 files changed

+1038
-563
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+1038
-563
lines changed

changes.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
<action type="update" dev="sseifert">
3232
Update dependencies.
3333
</action>
34+
<action type="fix" dev="sseifert" issue="114">
35+
Fix: Plugin ignores its own POM configuration due to wrong coordinates.
36+
</action>
3437
</release>
3538

3639
<release version="3.2.0" date="2022-09-29">

pom.xml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,6 @@ under the License.
9898
<distribution.snapshotRepositoryUrl>https://central.sonatype.com/repository/maven-snapshots</distribution.snapshotRepositoryUrl>
9999
<distribution.releaseRepositoryId>sonatype-central</distribution.releaseRepositoryId>
100100
<distribution.releaseRepositoryUrl>https://central.sonatype.com</distribution.releaseRepositoryUrl>
101-
102-
<!-- Skip integration tests by default -->
103-
<skipITs>true</skipITs>
104101
</properties>
105102

106103
<dependencies>
@@ -179,7 +176,7 @@ under the License.
179176
<dependency>
180177
<groupId>org.codehaus.plexus</groupId>
181178
<artifactId>plexus-utils</artifactId>
182-
<version>3.0.24</version>
179+
<version>3.2.1</version>
183180
<scope>compile</scope>
184181
</dependency>
185182
<dependency>
@@ -341,6 +338,12 @@ under the License.
341338
<version>${surefire.version}</version>
342339
</dependency>
343340
</dependencies>
341+
<configuration>
342+
<systemPropertyVariables>
343+
<maven.home>${maven.home}</maven.home>
344+
</systemPropertyVariables>
345+
<argLine>${maven.test.jvmargs}</argLine>
346+
</configuration>
344347
</plugin>
345348
<plugin>
346349
<groupId>org.apache.rat</groupId>
@@ -549,12 +552,6 @@ under the License.
549552
<goal>integration-test</goal>
550553
<goal>verify</goal>
551554
</goals>
552-
<configuration>
553-
<systemPropertyVariables>
554-
<maven.home>${maven.home}</maven.home>
555-
</systemPropertyVariables>
556-
<argLine>${maven.test.jvmargs}</argLine>
557-
</configuration>
558555
</execution>
559556
</executions>
560557
</plugin>

src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2048,7 +2048,7 @@ private String getProjectNameTemplateForMavenProject( MavenProject mavenProject
20482048
Build build = mavenProject.getBuild();
20492049
if ( build != null )
20502050
{
2051-
String eclipsePlugin = "org.apache.maven.plugins:maven-eclipse-plugin";
2051+
String eclipsePlugin = "io.wcm.devops.maven.plugins:eclipse-maven-plugin";
20522052
Plugin plugin = (Plugin) build.getPluginsAsMap().get( eclipsePlugin );
20532053
if ( plugin == null && build.getPluginManagement() != null )
20542054
{

src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseAjdtWriter.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public void write()
8181
{
8282

8383
// check if it's necessary to create project specific settings
84-
Properties ajdtSettings = new Properties();
84+
Properties ajdtSettings = new SortedProperties();
8585

8686
IdeDependency[] deps = config.getDeps();
8787
int ajdtDepCount = 0;
@@ -118,10 +118,11 @@ public void write()
118118
{
119119
oldAjdtSettingsFile = ajdtSettingsFile;
120120

121-
Properties oldsettings = new Properties();
121+
Properties oldsettings = new SortedProperties();
122122
oldsettings.load( new FileInputStream( oldAjdtSettingsFile ) );
123123

124-
Properties newsettings = (Properties) oldsettings.clone();
124+
Properties newsettings = new SortedProperties();
125+
newsettings.putAll( oldsettings );
125126
newsettings.putAll( ajdtSettings );
126127

127128
if ( !oldsettings.equals( newsettings ) )
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package org.apache.maven.plugin.eclipse.writers;
2+
3+
/*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing,
15+
* software distributed under the License is distributed on an
16+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
* KIND, either express or implied. See the License for the
18+
* specific language governing permissions and limitations
19+
* under the License.
20+
*/
21+
22+
import java.util.Collections;
23+
import java.util.Enumeration;
24+
import java.util.Map;
25+
import java.util.Properties;
26+
import java.util.Set;
27+
import java.util.TreeMap;
28+
import java.util.TreeSet;
29+
30+
/**
31+
* A {@link Properties} subclass that writes its entries in sorted (alphabetical) key order.
32+
* <p>
33+
* The standard {@link Properties#store} method iterates over keys in hash-table order, which
34+
* is non-deterministic and differs between JVM versions. Using this class ensures that generated
35+
* {@code .prefs} files have a stable, predictable layout regardless of the JVM used.
36+
* </p>
37+
* <p>
38+
* Both {@link #keys()} (used by Java 8's {@code store}) and {@link #entrySet()} (used by Java 11+
39+
* {@code store}) are overridden to enforce alphabetical ordering.
40+
* </p>
41+
*/
42+
public class SortedProperties
43+
extends Properties
44+
{
45+
46+
private static final long serialVersionUID = 1L;
47+
48+
/** Overridden for Java 8 compatibility: {@code Properties.store} used {@code keys()} there. */
49+
@Override
50+
public synchronized Enumeration<Object> keys()
51+
{
52+
return Collections.enumeration( new TreeSet<>( super.keySet() ) );
53+
}
54+
55+
/**
56+
* Overridden for Java 11+: {@code Properties.store} iterates via {@code entrySet()} in those
57+
* versions and would bypass the {@link #keys()} override.
58+
*/
59+
@Override
60+
public Set<Map.Entry<Object, Object>> entrySet()
61+
{
62+
TreeMap<Object, Object> sorted = new TreeMap<>();
63+
for ( Map.Entry<Object, Object> e : super.entrySet() )
64+
{
65+
sorted.put( e.getKey(), e.getValue() );
66+
}
67+
return sorted.entrySet();
68+
}
69+
}

src/main/java/org/apache/maven/plugin/eclipse/writers/workspace/EclipseSettingsWriter.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.apache.maven.plugin.MojoExecutionException;
3232
import org.apache.maven.plugin.eclipse.Messages;
3333
import org.apache.maven.plugin.eclipse.writers.AbstractEclipseWriter;
34+
import org.apache.maven.plugin.eclipse.writers.SortedProperties;
3435
import org.apache.maven.plugin.ide.IdeUtils;
3536

3637
/**
@@ -61,7 +62,7 @@ public void write()
6162
{
6263

6364
// check if it's necessary to create project specific settings
64-
Properties coreSettings = new Properties();
65+
Properties coreSettings = new SortedProperties();
6566

6667
String source = IdeUtils.getCompilerSourceVersion( config.getProject() );
6768
String encoding = IdeUtils.getCompilerSourceEncoding( config.getProject() );
@@ -144,10 +145,11 @@ public void write()
144145
{
145146
oldCoreSettingsFile = coreSettingsFile;
146147

147-
Properties oldsettings = new Properties();
148+
Properties oldsettings = new SortedProperties();
148149
oldsettings.load( new FileInputStream( oldCoreSettingsFile ) );
149150

150-
Properties newsettings = (Properties) oldsettings.clone();
151+
Properties newsettings = new SortedProperties();
152+
newsettings.putAll( oldsettings );
151153
newsettings.putAll( coreSettings );
152154

153155
if ( !oldsettings.equals( newsettings ) )

0 commit comments

Comments
 (0)