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

Maven profiles not managed #117

Closed
loryx636 opened this issue Aug 30, 2018 · 12 comments
Closed

Maven profiles not managed #117

loryx636 opened this issue Aug 30, 2018 · 12 comments

Comments

@loryx636
Copy link

Describe the bug
If VS Code is open, and from a terminal (internal or external) launch the execution of the project with "mvnw -PprofileName", the execution exclude the profile, using the default configuration in pom.xml.

Expected behavior
A clear and concise description of what you expected to happen.

Environments (please complete the following information as much as possible):

  • OS: Windows 7
@Eskibear
Copy link
Member

Eskibear commented Sep 1, 2018

Currently you can add "-PprofileName" to entry "maven.executable.options" in settings, e.g. in workspace settings. Then it appends the string when constructing commands.

image

@loryx636
Copy link
Author

loryx636 commented Oct 1, 2018

I try to do this configuration, in user settings, or workspace settings, but without success. The only way to accomplish this is to add the entry on settings.xml under .m2, but this add the same profile to all projects.
immagine

@Eskibear
Copy link
Member

@loryx636 I think it might be the issue of mvnw/mvn, the extension only concat commands for users. What if VS Code is NOT open? Does the maven wrapper work well?

@Eskibear
Copy link
Member

BTW I don't see any problem activating a profile. The value of a property specified in my profile is correct.

image

Closing it now. Feel free to re-open it and provide steps to reproduce if you still have the issue.

@helsonxiao
Copy link

helsonxiao commented Oct 3, 2019

I'm developing in my local docker container. Docker image starts with docker-dev profile by default and it works fine after I execute mvn compile -Pdocker-dev. However, when I save files in VS Code, this plugin will choose another profile(active by default) even if I add the options.

image

    <profile>
      <id>dev</id>
      <properties>
        <spring.profiles.active>dev</spring.profiles.active>
      </properties>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
    </profile>

I tried to remove above activation config. This plugin then chose the default profile and failed to run.

No active profile set, falling back to default profiles: default

P.S.
VS Code Version: 1.38.1
Maven for Java: 0.19.1

@helsonxiao
Copy link

I'm developing in my local docker container. Docker image starts with docker-dev profile by default and it works fine after I execute mvn compile -Pdocker-dev. However, when I save files in VS Code, this plugin will choose another profile(active by default) even if I add the options.

image

    <profile>
      <id>dev</id>
      <properties>
        <spring.profiles.active>dev</spring.profiles.active>
      </properties>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
    </profile>

I tried to remove above activation config. This plugin then chose the default profile and failed to run.

No active profile set, falling back to default profiles: default

P.S.
VS Code Version: 1.38.1
Maven for Java: 0.19.1

I've found the problem. I installed the Java Extension Pack which includes this plugin in VSCode. However, some of them will force build the project when you change files and build without options(like -Pdev or something else you set).

@Eskibear
Copy link
Member

I guess it's vscode-java's setting java.configuration.updateBuildConfiguration. When you set the value to "automatic", it auto build the maven project according to your pom.xml whenever changes are detected. And maven.executable.options is a setting of this Maven extension, which is not honored by vscode-java. This setting only affects the maven commands we assemble and send to the terminal.

@spaghett1c0de
Copy link

@Eskibear I ran into the exact same issue and debugged this for a couple of hours only to realize that it was VS Code. If I quit VS Code, then the command works perfectly. When VS Code is open, it simply ignores the -Pprofile flag and uses the default profile specified in the POM. Not sure if there's a fix for this.

@Eskibear
Copy link
Member

@spaghett1c0de
It sounds strange. As there are a bunch of Java-related extensions, I cannot tell if it's exactly caused by this extension. Can you try disabling all the other extensions (i.e. only enabling Maven for Java), see if the issue still exists?

@spaghett1c0de
Copy link

@Eskibear
That's a great suggestion! I just tested it by disabling every Java extension and left with Maven for Java. It works correctly. 😮 So I tried to enable each of them one by one to see what caused this. 🤔And surprisingly, it's Language Support for Java(TM) by Red Hat extension that is causing this issue. I tested a few times, and I can confirm that this extension somehow causes the maven commands to ignore the -Pprofile flag and uses the default profile specified in the POM.

@Eskibear
Copy link
Member

Good finding. So you might be experiencing the same issue mentioned in #117 (comment)

I'll suggest that you open an issue in their repo. But you may have a try with the setting java.configuration.updateBuildConfiguration to temporarily disable auto build.

@spaghett1c0de
Copy link

@Eskibear
I'll go ahead and post an issue in their repo and see if that gets resolved.

I tried disabling java.configuration.updateBuildConfiguration and it didn't work. :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants