perdian / macosappbundler-maven-plugin

Maven plugin for creating a native macOS bundle containing all dependencies required by a Maven project
Apache License 2.0
46 stars 14 forks source link

Question: where does system environment come from (and how to change it)? #49

Closed jpage4500 closed 1 month ago

jpage4500 commented 3 months ago

Hi @perdian - This isn't an issue at all.. this library has worked great for me!

My question just is how the system environment is set? I noticed when running my app if I call System.getenv() and look for the PATH this is what I get:

PATH : /usr/bin:/bin:/usr/sbin:/sbin

I have several other folders set in my PATH (set in ~/.profile) so those aren't getting picked up.

FWIW here's how my app is setup (pom.xml)

            <plugin>
                <groupId>de.perdian.maven.plugins</groupId>
                <artifactId>macosappbundler-maven-plugin</artifactId>
                <version>1.19.0</version>
                <configuration>
                    <plist>
                        <CFBundleIconFile>resources/device-manager.icns</CFBundleIconFile>
                        <JVMMainClassName>com.jpage4500.devicemanager.MainApplication</JVMMainClassName>
                        <CFBundleDisplayName>Android Device Manager</CFBundleDisplayName>
                        <CFBundleDevelopmentRegion>English</CFBundleDevelopmentRegion>
                        <CFBundleTypeExtensions>
                            <string>apk</string>
                        </CFBundleTypeExtensions>
                    </plist>
                    <jdk>
                        <!-- set to true to package entire JRE (NOTE: resulting app won't be compatible with both arm and x86 macs)-->
                        <include>false</include>
                        <!--<location>/Applications/Android Studio Preview.app/Contents/jbr/Contents/Home</location>-->
                    </jdk>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>bundle</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
perdian commented 3 months ago

I'm actually not really sure 😎

My assumption is that ~/.profile is only loaded from a shell, so if you start your application from /Applications/Something.app/Contents/MacOS/JavaLauncher then the environment variables should be taken from the shell. Otherwise the "regular" environment variables will be used.