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

Consider the settings files location in project configuration #1675

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,20 @@ public static void getCliProperties(CommandLine commandLine, BiConsumer<String,
}
}

public static String getAlternateGlobalToolchainsFile(CommandLine commandline) {
if(commandline != null && commandline.hasOption(CLIManager.ALTERNATE_GLOBAL_TOOLCHAINS)) {
return commandline.getOptionValue(CLIManager.ALTERNATE_USER_SETTINGS);
}
return null;
}

public static String getAlternateUserToolchainsFile(CommandLine commandline) {
if(commandline != null && commandline.hasOption(CLIManager.ALTERNATE_USER_TOOLCHAINS)) {
return commandline.getOptionValue(CLIManager.ALTERNATE_USER_TOOLCHAINS);
}
return null;
}

public static void getCliProperty(String property, BiConsumer<String, String> consumer) {
int index = property.indexOf('=');
if(index <= 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,10 @@ private static final class MavenProjectConfiguration implements IProjectConfigur

private List<String> inactiveProfiles;

private String globalSettingsFile;

private String userSettingsFile;

private MavenProjectConfiguration(IProjectConfiguration baseConfiguration) {
if(baseConfiguration == null) {
//we should really forbid this but some test seem to pass null!
Expand All @@ -677,6 +681,8 @@ private MavenProjectConfiguration(IProjectConfiguration baseConfiguration) {
this.profiles = baseConfiguration.getSelectedProfiles();
this.activeProfiles = List.copyOf(baseConfiguration.getActiveProfileList());
this.inactiveProfiles = List.copyOf(baseConfiguration.getInactiveProfileList());
this.globalSettingsFile = baseConfiguration.getGlobalSettingsFile();
this.userSettingsFile = baseConfiguration.getUserSettingsFile();
}

@Override
Expand Down Expand Up @@ -735,6 +741,16 @@ public List<String> getInactiveProfileList() {
return inactiveProfiles;
}

@Override
public String getGlobalSettingsFile() {
return globalSettingsFile;
}

@Override
public String getUserSettingsFile() {
return userSettingsFile;
}

}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ public interface IProjectConfiguration {

File getMultiModuleProjectDirectory();

String getGlobalSettingsFile();

String getUserSettingsFile();

/**
* Computes a hashcode over the contents of the given configuration, that is a semantic hash-code that can be used in
* combination of {@link #contentsEquals(IProjectConfiguration, IProjectConfiguration)}
Expand All @@ -65,7 +69,8 @@ public static int contentsHashCode(IProjectConfiguration configuration) {
return Objects.hash(configuration.isResolveWorkspaceProjects(), configuration.getActiveProfileList(),
configuration.getInactiveProfileList(), configuration.getLifecycleMappingId(),
configuration.getConfigurationProperties(), configuration.getUserProperties(),
configuration.getMultiModuleProjectDirectory());
configuration.getMultiModuleProjectDirectory(), configuration.getGlobalSettingsFile(),
configuration.getUserSettingsFile());
}

public static boolean contentsEquals(IProjectConfiguration configuration, IProjectConfiguration other) {
Expand All @@ -81,7 +86,9 @@ public static boolean contentsEquals(IProjectConfiguration configuration, IProje
&& Objects.equals(configuration.getInactiveProfileList(), other.getInactiveProfileList())
&& Objects.equals(configuration.getConfigurationProperties(), other.getConfigurationProperties())
&& Objects.equals(configuration.getUserProperties(), other.getUserProperties())
&& Objects.equals(configuration.getMultiModuleProjectDirectory(), other.getMultiModuleProjectDirectory());
&& Objects.equals(configuration.getMultiModuleProjectDirectory(), other.getMultiModuleProjectDirectory())
&& Objects.equals(configuration.getGlobalSettingsFile(), other.getGlobalSettingsFile())
&& Objects.equals(configuration.getUserSettingsFile(), other.getUserSettingsFile());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ public class ResolverConfiguration implements Serializable, IProjectConfiguratio

private List<String> userInactiveProfiles;

private String globalSettingsFile;

private String userSettingsFile;

public ResolverConfiguration() {
}

Expand All @@ -79,9 +83,9 @@ public ResolverConfiguration(IProject project) {
public ResolverConfiguration(IProjectConfiguration resolverConfiguration) {
setLifecycleMappingId(resolverConfiguration.getLifecycleMappingId());
setMultiModuleProjectDirectory(resolverConfiguration.getMultiModuleProjectDirectory());
Properties properties2 = new Properties();
properties2.putAll(resolverConfiguration.getConfigurationProperties());
setProperties(properties2);
Properties properties = new Properties();
properties.putAll(resolverConfiguration.getConfigurationProperties());
setProperties(properties);
setResolveWorkspaceProjects(resolverConfiguration.isResolveWorkspaceProjects());
setSelectedProfiles(resolverConfiguration.getSelectedProfiles());
}
Expand Down Expand Up @@ -195,6 +199,16 @@ public File getMultiModuleProjectDirectory() {
return multiModuleProjectDirectory;
}

@Override
public String getGlobalSettingsFile() {
return globalSettingsFile;
}

@Override
public String getUserSettingsFile() {
return userSettingsFile;
}

/**
* @param multiModuleProjectDirectory The multiModuleProjectDirectory to set.
*/
Expand All @@ -209,6 +223,8 @@ public void setMultiModuleProjectDirectory(File multiModuleProjectDirectory) {
userActiveProfiles = new ArrayList<>();
userInactiveProfiles = new ArrayList<>();
MavenProperties.getProfiles(commandLine, userActiveProfiles::add, userInactiveProfiles::add);
globalSettingsFile = MavenProperties.getAlternateGlobalToolchainsFile(commandLine);
userSettingsFile = MavenProperties.getAlternateUserToolchainsFile(commandLine);
} catch(IOException | ParseException ex) {
//can't use it then... :-(
MavenPluginActivator.getDefault().getLog().error("can't read maven args from " + multiModuleProjectDirectory,
Expand Down
Loading