trustin / os-maven-plugin

A Maven plugin that sets various useful properties detected from ${os.name} and ${os.arch} properties.
Apache License 2.0
296 stars 66 forks source link

Eclipse (M2E) is happier when this is used as Maven plugin instead of an extension #34

Closed vorburger closed 5 years ago

vorburger commented 6 years ago

This issue was originally titled "Eclipse p2 site to be able to install this for M2E support without having to manually DL and copy a JAR around", but I subsequently found a much simpler / better solution, see comment; this description is as initially submitted, but is no longer what this issue is about - I'm now just suggesting to update the README.

In an ideal world, the process described here https://github.com/trustin/os-maven-plugin#issues-with-eclipse-m2e-or-other-ides as:

If you are using Eclipse, you need to install an additional Eclipse plugin ...). Download os-maven-plugin-1.6.0.jar and put it into the /plugins directory.

could be made much smoother if this project published not only an Eclipse plugin JAR to Maven central, but a full Eclipse p2 site incl. an Eclipse feature. Then one could use the regular Help > Install New Software, or have e.g. an Eclipse Oomph Setup model such as https://github.com/vorburger/opendaylight-eclipse-setup install it, or list it in the M2E known extension catalog so that its (M2E's) wizard proposes to automatically download it with 1 click.

Would you welcome a contribution to this project which adds the required Eclipse feature and p2 site, built via the Tycho Maven extension, and if so would you then be willing to deploy that to Maven central?

This has come up e.g. in the context of https://github.com/coreos/jetcd/issues/340.

vorburger commented 6 years ago

Hey @trustin @hhoffstaette @nmittler @marko-asplund @jimmyMaci re. using os-maven-plugin in Eclipse, check this out:

<project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>test</groupId>
  <artifactId>test</artifactId>
  <version>0.0.1-SNAPSHOT</version>

  <dependencies>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-tcnative-boringssl-static</artifactId>
      <version>2.0.12.Final</version>
      <classifier>${os.detected.classifier}</classifier>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>kr.motd.maven</groupId>
        <artifactId>os-maven-plugin</artifactId>
        <version>1.6.0</version>
        <extensions>true</extensions>
        <executions>
          <execution>
            <phase>validate</phase>
            <goals>
              <goal>detect</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
    <pluginManagement>
      <plugins>
        <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
        <plugin>
          <groupId>org.eclipse.m2e</groupId>
          <artifactId>lifecycle-mapping</artifactId>
          <version>1.0.0</version>
          <configuration>
            <lifecycleMappingMetadata>
              <pluginExecutions>
                <pluginExecution>
                  <pluginExecutionFilter>
                    <groupId>kr.motd.maven</groupId>
                    <artifactId>os-maven-plugin</artifactId>
                    <versionRange>[1.6.0,)</versionRange>
                    <goals>
                      <goal>detect</goal>
                    </goals>
                  </pluginExecutionFilter>
                  <action>
                    <execute></execute>
                  </action>
                </pluginExecution>
              </pluginExecutions>
            </lifecycleMappingMetadata>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
</project>

This works great - and give me working os.detected.classifier in Eclipse, WITHOUT having to _"Download os-maven-plugin-1.6.0.jar and put it into the /plugins directory."_ - cool, no?

Are there any impacts of using it as a plugin with <extensions>true instead of an extension that I'm missing?

Do you want a PR with an update to the README with this?

szab100 commented 6 years ago

Haha, awesome! I got to the exact same conclusion and solution yesterday! I was going to post it here to help others, then found this issue.. I believe this should be used as a plugin and you might even be better remove the extension and Eclipse plugin interfaces implementation (so, as a breaking change) and add the explanation to the README, so users' life can be easier. Unless there are features of the plugin unavailable this way, I haven't tested it for anything else than using it with the protoc compiler maven plugin.

trustin commented 5 years ago

Thank you for the detailed report. @sergei-ivanov has updated the README.md. Will not release 1.6.1.