-
Notifications
You must be signed in to change notification settings - Fork 66
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
Support Maven 4 and JDK 21 at build time #74
Open
gnodet
wants to merge
4
commits into
trustin:master
Choose a base branch
from
gnodet:update-maven
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
src/main/java/kr/motd/maven/os/DetectPropertyContributor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package kr.motd.maven.os; | ||
|
||
import org.apache.maven.api.spi.PropertyContributor; | ||
import org.codehaus.plexus.component.annotations.Component; | ||
import org.codehaus.plexus.logging.Logger; | ||
|
||
import javax.inject.Inject; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Properties; | ||
|
||
@Component(role = PropertyContributor.class) | ||
public class DetectPropertyContributor implements PropertyContributor { | ||
|
||
private final Logger logger; | ||
|
||
@Inject | ||
DetectPropertyContributor(Logger logger) { | ||
super(); | ||
this.logger = logger; | ||
} | ||
|
||
@Override | ||
public void contribute(Map<String, String> map) { | ||
DetectExtension.disable(); | ||
Properties props = new Properties(); | ||
props.putAll(map); | ||
Detector detector = new SimpleDetector(new SimpleSystemPropertyOperations(map), new SimpleFileOperations(), logger); | ||
detector.detect(props, getClassifierWithLikes(map)); | ||
} | ||
|
||
/** | ||
* Inspects the session's user and project properties for the {@link | ||
* DetectMojo#CLASSIFIER_WITH_LIKES_PROPERTY} and separates the property into a list. | ||
*/ | ||
private static List<String> getClassifierWithLikes(Map<String, String> map) { | ||
// Check to see if the project defined the | ||
return DetectMojo.getClassifierWithLikes(map.get(DetectMojo.CLASSIFIER_WITH_LIKES_PROPERTY)); | ||
} | ||
|
||
|
||
private static class SimpleDetector extends Detector { | ||
|
||
private final Logger logger; | ||
|
||
private SimpleDetector(SystemPropertyOperationProvider systemPropertyOperationProvider, FileOperationProvider fileOperationProvider, Logger logger) { | ||
super(systemPropertyOperationProvider, fileOperationProvider); | ||
this.logger = logger; | ||
} | ||
|
||
@Override | ||
protected void log(String message) { | ||
logger.info(message); | ||
} | ||
|
||
@Override | ||
protected void logProperty(String name, String value) { | ||
if (logger.isInfoEnabled()) { | ||
logger.info(name + ": " + value); | ||
} | ||
} | ||
|
||
} | ||
|
||
private static class SimpleSystemPropertyOperations implements SystemPropertyOperationProvider { | ||
final Map<String, String> map; | ||
|
||
private SimpleSystemPropertyOperations(Map<String, String> map) { | ||
this.map = map; | ||
} | ||
|
||
@Override | ||
public String getSystemProperty(String name) { | ||
return System.getProperty(name); | ||
} | ||
|
||
@Override | ||
public String getSystemProperty(String name, String def) { | ||
return System.getProperty(name, def); | ||
} | ||
|
||
@Override | ||
public String setSystemProperty(String name, String value) { | ||
map.put(name, value); | ||
return System.setProperty(name, value); | ||
} | ||
} | ||
|
||
private static class SimpleFileOperations implements FileOperationProvider { | ||
@Override | ||
public InputStream readFile(String fileName) throws IOException { | ||
return Files.newInputStream(Paths.get(fileName)); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,6 +70,7 @@ public Detector(SystemPropertyOperationProvider systemPropertyOperationProvider, | |
} | ||
|
||
protected void detect(Properties props, List<String> classifierWithLikes) { | ||
new Throwable().printStackTrace(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For debugging only? Shall we may remove this before merging? |
||
log("------------------------------------------------------------------------"); | ||
log("Detecting the operating system and CPU architecture"); | ||
log("------------------------------------------------------------------------"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused import