microsoft / vscode-maven

VSCode extension "Maven for Java"
https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-maven
Other
181 stars 88 forks source link

add profile support #956

Closed Eskibear closed 1 year ago

Eskibear commented 1 year ago

https://user-images.githubusercontent.com/2351748/225494284-f37ec98d-ce56-4fb3-82dc-7cabc13b043f.mp4

JFK-DXML commented 12 months ago

@Eskibear

This fails under MacOs on my box because the shell interprets the '!' character before it runs the command. Any way of tweaking this so that Bash and Zsh you could get it to use the Maven alternative syntax -P-disableThisProfile,enableThisProfile ?

And is this problem why the java project does not update it's source folders to reflect the change in selected profiles? Or is that another issue?

<profiles>
        <profile>
            <id>multiReleaseJar</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <version>3.0.0</version>
                        <executions>
                            <execution>
                                <id>add-source</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>add-source</goal>
                                </goals>
                                <configuration>
                                    <sources>
                                        <source>src/main/java8</source>
                                    </sources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>3.8.0</version>
                        <executions>
                            <execution>
                                <id>default-compile</id>
                                <configuration>
                                    <release>8</release>
                                </configuration>
                            </execution>
                            <execution>
                                <id>default-testCompile</id>
                                <phase>test-compile</phase>
                                <goals>
                                    <goal>testCompile</goal>
                                </goals>
                                <configuration>
                                    <release>8</release>
                                </configuration>
                            </execution>
                            <execution>
                                <id>compile-java-11</id>
                                <phase>compile</phase>
                                <goals>
                                    <goal>compile</goal>
                                </goals>
                                <configuration>
                                    <release>11</release>
                                    <compileSourceRoots>
                                        <compileSourceRoot>${project.basedir}/src/main/java11</compileSourceRoot>
                                    </compileSourceRoots>
                                    <multiReleaseOutput>true</multiReleaseOutput>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>jdk8</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <version>3.0.0</version>
                        <executions>
                            <execution>
                                <id>add-source</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>add-source</goal>
                                </goals>
                                <configuration>
                                    <sources>
                                        <source>src/main/java8</source>
                                    </sources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>3.8.1</version>
                        <configuration>
                            <source>1.8</source>
                            <target>1.8</target>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
            <dependencies>
                <dependency>
                    <groupId>org.testng</groupId>
                    <artifactId>testng</artifactId>
                    <version>7.5.1</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>
        </profile>
        <profile>
            <id>modern</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <version>3.0.0</version>
                        <executions>
                            <execution>
                                <id>add-source</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>add-source</goal>
                                </goals>
                                <configuration>
                                    <sources>
                                        <source>src/main/java11</source>
                                    </sources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>3.8.0</version>
                        <configuration>
                            <release>11</release>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
Eskibear commented 12 months ago

@JFK-DXML

We probably can use - instead of ! to construct the command. See https://maven.apache.org/guides/introduction/introduction-to-profiles.html#deactivating-a-profile A issue created to track it.

And is this problem why the java project does not update it's source folders to reflect the change in selected profiles? Or is that another issue?

Probably not, @jdneo would know more about source folder related stuffs.