Skip to content

Commit

Permalink
Correctly determine the version of the underlying javac tool
Browse files Browse the repository at this point in the history
Ignore 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 committed Feb 1, 2024
1 parent c5edddc commit eb32403
Show file tree
Hide file tree
Showing 6 changed files with 188 additions and 171 deletions.
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 eb32403

Please sign in to comment.