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

can't use system environment variable? #693

Closed
1013461195 opened this issue Sep 23, 2022 · 4 comments
Closed

can't use system environment variable? #693

1013461195 opened this issue Sep 23, 2022 · 4 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@1013461195
Copy link

1013461195 commented Sep 23, 2022

execute mvnd clean mvnd -version,tip me 'Could not get a real path from path $JAVA_HOME'
image

@gnodet
Copy link
Contributor

gnodet commented Sep 30, 2022

Environment properties are supported using an env. prefix, and with the correct prefix ${ and suffix }, so you may try with

java.home=${env.JAVA_HOME}

@gnodet gnodet added question Further information is requested waiting for feedback Waiting for feedback labels Sep 30, 2022
@1013461195
Copy link
Author

1013461195 commented Oct 9, 2022

thanks, but still can't read system env,
default read ${pwd}/bin/java?
截屏2022-10-09 11 51 57

@1013461195
Copy link
Author

1013461195 commented Oct 9, 2022

my from code source 'org.mvndaemon.mvnd.client.DaemonParameters.javaHome' find use env value is '${JAVA_HOME}'. but 'org.mvndaemon.mvnd.client.DaemonParameters.loadProperties' to first insert 'env.', last result '${JAVA_HOME}' = env.${JAVA_HOME}.
截屏2022-10-09 15 24 44

@shenjianeng
Copy link

yeah, can't read system env.

but you can use that:

// org.mvndaemon.mvnd.client.DaemonParameters#javaHome
public Path javaHome() {
        final Path result = value(Environment.JAVA_HOME)
                .orLocalProperty(provider, suppliedPropertiesPath())
                .orLocalProperty(provider, localPropertiesPath())
                .orLocalProperty(provider, userPropertiesPath())
                .orLocalProperty(provider, globalPropertiesPath())
                .orSystemProperty()
                .orEnvironmentVariable()
                .or(new ValueSource(
                        description -> description.append("java command"), DaemonParameters::javaHomeFromPath))
                .orFail()
                .cache(provider)
                .asPath();
        try {
            return result.toRealPath();
        } catch (IOException e) {
            throw new RuntimeException("Could not get a real path from path " + result);
        }
    }

remove config file ,

use SystemProperty : mvnd clean deploy -Dmaven.test.skip=true -Ptest -Djava.home=/opt/jdk-11.0.17+8/

@gnodet gnodet added this to the 1.0-m7 milestone Jul 3, 2023
@gnodet gnodet added bug Something isn't working and removed question Further information is requested waiting for feedback Waiting for feedback labels Jul 3, 2023
@gnodet gnodet self-assigned this Jul 3, 2023
@gnodet gnodet closed this as completed in c4aaed6 Jul 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants