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

mvn clean install -P "scala-2.12_spark-3.1.2" fails if extra profiles are active #169

Open
jeanmarc opened this issue Feb 22, 2022 · 2 comments

Comments

@jeanmarc
Copy link

Running the command in the title fails the build on my machine, because I have to work with some globally active profiles that are active depending on the location where I am working.
I understand that the build should use exactly one of the profiles defined in the main pom, but the check should (IMO) ignore profiles that do not originate in the pom.

mvn install -P "scala-2.12_spark-3.1.2"
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] spark-monitoring                                                   [pom]
[INFO] spark-listeners                                                    [jar]
[INFO] spark-listeners-loganalytics                                       [jar]
[INFO] 
[INFO] -----------------< com.microsoft.pnp:spark-monitoring >-----------------
[INFO] Building spark-monitoring 1.0.0                                    [1/3]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] 
[INFO] --- maven-enforcer-plugin:3.0.0-M2:enforce (enforce-minimum-maven-version) @ spark-monitoring ---
[INFO] 
[INFO] --- maven-enforcer-plugin:3.0.0-M2:enforce (enforce-only-one-profile-is-active) @ spark-monitoring ---
Only one profile may be active
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for spark-monitoring 1.0.0:
[INFO] 
[INFO] spark-monitoring ................................... FAILURE [  0.467 s]
[INFO] spark-listeners .................................... SKIPPED
[INFO] spark-listeners-loganalytics ....................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.642 s
[INFO] Finished at: 2022-02-22T14:52:21+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M2:enforce (enforce-only-one-profile-is-active) on project spark-monitoring: org.apache.maven.plugins.enforcer.EvaluateBeanshell failed with message:
[ERROR] The expression "String activeProfiles = "[Profile {id: scala-2.12_spark-3.1.2, source: pom}, Profile {id: nexus, source: settings.xml}]";
[ERROR]                                         int indexOf =activeProfiles.indexOf("Profile");
[ERROR]                                         if (indexOf == -1) {
[ERROR]                                             print("No active profile");
[ERROR]                                             return false;
[ERROR]                                         }
[ERROR] 
[ERROR]                                         if (indexOf != activeProfiles.lastIndexOf("Profile")) {
[ERROR]                                             print("Only one profile may be active");
[ERROR]                                             return false;
[ERROR]                                         }
[ERROR] 
[ERROR]                                         return true;" is not true.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

I suggest the check is updated to look for the number of profiles with a source: pom instead of just any active profile.

@jeanmarc
Copy link
Author

A possible fix might be to look for profile ids that start with scala:

                                <evaluateBeanshell>
                                    <condition><![CDATA[
                                        String activeProfiles = "${project.activeProfiles}";
                                        int indexOf =activeProfiles.indexOf("Profile {id: scala-");
                                        if (indexOf == -1) {
                                            print("No active profile");
                                            return false;
                                        }

                                        if (indexOf != activeProfiles.lastIndexOf("Profile {id: scala-")) {
                                            print("Only one profile may be active");
                                            return false;
                                        }

                                        return true;
                                    ]]></condition>
                                </evaluateBeanshell>

@jeanmarc
Copy link
Author

There has been no response so far. Is this project still actively maintained?

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

No branches or pull requests

1 participant