Skip to content

Commit

Permalink
Correctly determine the version of the underlying javac tool (#357)
Browse files Browse the repository at this point in the history
Ignore and deprecate CompilerConfiguration values as they are unreliable (and don't
represent the used javac version)

Make test execution more resilient by interpolating settings.xml
correctly and make sure commons-lang 2.0 is resolved prior to unit
testing

This closes #356
  • Loading branch information
kwin authored Feb 3, 2024
1 parent c5edddc commit aa4e8e2
Show file tree
Hide file tree
Showing 7 changed files with 208 additions and 171 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -500,10 +500,20 @@ public void setOptimize(boolean optimize) {
this.optimize = optimize;
}

/**
* @deprecated Don't use any longer because this is just the configured version which does not necessarily match the version
* of the actually executed compiler binary
*/
@Deprecated
public String getCompilerVersion() {
return compilerVersion;
}

/**
* @deprecated Don't use any longer because this is just the configured version which does not necessarily match the version
* of the actually executed compiler binary
*/
@Deprecated
public void setCompilerVersion(String compilerVersion) {
this.compilerVersion = compilerVersion;
}
Expand Down
2 changes: 1 addition & 1 deletion plexus-compiler-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-settings</artifactId>
<artifactId>maven-settings-builder</artifactId>
<version>${mavenVersion}</version>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.properties.internal.SystemProperties;
import org.apache.maven.settings.Settings;
import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader;
import org.apache.maven.settings.building.DefaultSettingsBuilderFactory;
import org.apache.maven.settings.building.DefaultSettingsBuildingRequest;
import org.apache.maven.settings.building.SettingsBuildingRequest;
import org.codehaus.plexus.testing.PlexusTest;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.StringUtils;
import org.hamcrest.io.FileMatchers;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -83,7 +85,13 @@ final void setUpLocalRepo() throws Exception {
if (localRepo == null) {
File settingsFile = new File(System.getProperty("user.home"), ".m2/settings.xml");
if (settingsFile.exists()) {
Settings settings = new SettingsXpp3Reader().read(ReaderFactory.newXmlReader(settingsFile));
SettingsBuildingRequest request = new DefaultSettingsBuildingRequest();
request.setUserSettingsFile(settingsFile);
request.setSystemProperties(SystemProperties.getSystemProperties());
Settings settings = new DefaultSettingsBuilderFactory()
.newInstance()
.build(request)
.getEffectiveSettings();
localRepo = settings.getLocalRepository();
}
}
Expand Down Expand Up @@ -116,7 +124,7 @@ protected List<String> getClasspath() throws Exception {
File file = getLocalArtifactPath("commons-lang", "commons-lang", "2.0", "jar");

assertThat(
"test prerequisite: commons-lang library must be available in local repository, expected ",
"test prerequisite: commons-lang library must be available in local repository at " + file,
file,
FileMatchers.aReadableFile());

Expand Down
Loading

0 comments on commit aa4e8e2

Please sign in to comment.