Skip to content

Commit bdd99e1

Browse files
committed
Add API to pass user properties in IProjectConfiguration
1 parent 8351fde commit bdd99e1

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/MavenProjectFacade.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,8 @@ private static final class MavenProjectConfiguration implements IProjectConfigur
650650

651651
private final String profiles;
652652

653+
private final Map<String, String> userProperties;
654+
653655
public MavenProjectConfiguration(IProjectConfiguration baseConfiguration, File multiModuleProjectDirectory) {
654656
if(baseConfiguration == null) {
655657
//we should really forbid this but some test seem to pass null!
@@ -658,6 +660,7 @@ public MavenProjectConfiguration(IProjectConfiguration baseConfiguration, File m
658660
this.multiModuleProjectDirectory = multiModuleProjectDirectory;
659661
this.mappingId = baseConfiguration.getLifecycleMappingId();
660662
this.properties = Map.copyOf(baseConfiguration.getConfigurationProperties());
663+
this.userProperties = Map.copyOf(baseConfiguration.getUserProperties());
661664
this.resolveWorkspace = baseConfiguration.isResolveWorkspaceProjects();
662665
this.profiles = baseConfiguration.getSelectedProfiles();
663666
}
@@ -667,6 +670,11 @@ public Map<String, String> getConfigurationProperties() {
667670
return properties;
668671
}
669672

673+
@Override
674+
public Map<String, String> getUserProperties() {
675+
return userProperties;
676+
}
677+
670678
@Override
671679
public boolean isResolveWorkspaceProjects() {
672680
return resolveWorkspace;

org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/IProjectConfiguration.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,22 @@
2626
*/
2727
public interface IProjectConfiguration {
2828

29+
/**
30+
* Additional properties of a project can be stored in the org.eclipse.m2e.core.prefs file under the key
31+
* <code>properties</code>, will be handled as user-properties
32+
*
33+
* @return return project configuration properties
34+
*/
2935
Map<String, String> getConfigurationProperties();
3036

37+
/**
38+
* User properties are stored in the <code>.mvn/maven.config</code> file with <code>-Dkey=value</code>, they are
39+
* therefore not persisted in the project configuration
40+
*
41+
* @return the user properties
42+
*/
43+
Map<String, String> getUserProperties();
44+
3145
boolean isResolveWorkspaceProjects();
3246

3347
String getSelectedProfiles();

org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/ResolverConfiguration.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ public class ResolverConfiguration implements Serializable, IProjectConfiguratio
4545

4646
private Properties properties;
4747

48+
private Map<String, String> userProperties;
49+
4850
private File multiModuleProjectDirectory;
4951

5052
public ResolverConfiguration() {
@@ -91,6 +93,14 @@ public Map<String, String> getConfigurationProperties() {
9193
return Collections.unmodifiableMap(map);
9294
}
9395

96+
@Override
97+
public Map<String, String> getUserProperties() {
98+
if(userProperties == null) {
99+
return Collections.emptyMap();
100+
}
101+
return userProperties;
102+
}
103+
94104
public void setProperties(Properties properties) {
95105
this.properties = properties;
96106
}
@@ -158,13 +168,15 @@ public boolean equals(Object obj) {
158168
return this.resolveWorkspaceProjects == other.resolveWorkspaceProjects
159169
&& Objects.equals(this.selectedProfiles, other.selectedProfiles)
160170
&& Objects.equals(this.lifecycleMappingId, other.lifecycleMappingId)
161-
&& Objects.equals(this.properties, other.properties)
171+
&& Objects.equals(this.getProperties(), other.getProperties())
172+
&& Objects.equals(this.getUserProperties(), other.getUserProperties())
162173
&& Objects.equals(this.multiModuleProjectDirectory, other.multiModuleProjectDirectory);
163174
}
164175

165176
@Override
166177
public int hashCode() {
167-
return Objects.hash(resolveWorkspaceProjects, selectedProfiles, lifecycleMappingId, properties,
178+
return Objects.hash(resolveWorkspaceProjects, selectedProfiles, lifecycleMappingId, getProperties(),
179+
getUserProperties(),
168180
multiModuleProjectDirectory);
169181
}
170182

0 commit comments

Comments
 (0)