tycho icon indicating copy to clipboard operation
tycho copied to clipboard

tycho-p2-extras-plugin:3.0.0 PluginExecutionException

Open marcellorinaldo opened this issue 2 years ago • 3 comments

Hello, I'm facing these errors while trying to compile my maven project with the plugin tycho-p2-extras-plugin on Tycho v. 3.0.0:

Execution default of goal org.eclipse.tycho.extras:tycho-p2-extras-plugin:3.0.0:publish-features-and-bundles failed: Unable to load the mojo 'publish-features-and-bundles' (or one of its required components) from the plugin 'org.eclipse.tycho.extras:tycho-p2-extras-plugin:3.0.0': com.google.inject.ProvisionException: Unable to provision, see the following errors:
[ERROR] 
[ERROR] 1) Error injecting: private org.eclipse.equinox.p2.core.IProvisioningAgent org.eclipse.tycho.plugins.p2.extras.PublishFeaturesAndBundlesMojo.agent
[ERROR]   while locating org.eclipse.tycho.plugins.p2.extras.PublishFeaturesAndBundlesMojo
[ERROR]   at ClassRealm[plugin>org.eclipse.tycho.extras:tycho-p2-extras-plugin:3.0.0, parent: jdk.internal.loader.ClassLoaders$AppClassLoader@531d72ca] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
[ERROR]   while locating org.apache.maven.plugin.Mojo annotated with @com.google.inject.name.Named(value="org.eclipse.tycho.extras:tycho-p2-extras-plugin:3.0.0:publish-features-and-bundles")
[ERROR] 
[ERROR] 1 error
[ERROR]       role: org.apache.maven.plugin.Mojo
[ERROR]   roleHint: org.eclipse.tycho.extras:tycho-p2-extras-plugin:3.0.0:publish-features-and-bundles: Can not set org.eclipse.equinox.p2.core.IProvisioningAgent field org.eclipse.tycho.plugins.p2.extras.PublishFeaturesAndBundlesMojo.agent to org.eclipse.tycho.p2maven.DefaultProvisioningAgent
[ERROR] -> [Help 1]

I'm currently using Java 17.0.4.1 and Maven 3.8.6. Using Tycho 2.7.5 everything works as expected.

marcellorinaldo avatar Oct 14 '22 13:10 marcellorinaldo

Please make sure that the tycho-maven-plugin is activated in your build with option extension=true as for example here:

https://github.com/eclipse-tycho/tycho/blob/1bda92601f35c79a2a54ae7d9e49ed6f6b826326/demo/itp01/pom.xml#L28-L33

laeubi avatar Oct 14 '22 16:10 laeubi

Thanks for the reply. Interestingly, I've the extension flag already set to true as in the example, but by removing it the plugin gets executed anyways and returns no error.

marcellorinaldo avatar Oct 17 '22 09:10 marcellorinaldo

I have created a simple example to reproduce the issue on this link: https://github.com/marcellorinaldo/issue-example

marcellorinaldo avatar Oct 17 '22 12:10 marcellorinaldo

Having this as well. @laeubi Does tycho-maven-plugin need to be defined in the same pom as the one being executed? I have it in a parent pom which is normally fine for the rest of our build which uses Tycho.

kjsmita6 avatar Nov 02 '22 15:11 kjsmita6

If it is activated in the parent yes, having it in the management section is not enough. If someone can provide an integration-test to demonstrate the issue this would be very helpful.

Another option is to try out the current tycho snapshot build to see if problem is probably already fixed with Tycho 4.x

laeubi avatar Nov 02 '22 15:11 laeubi

If it is activated in the parent yes, having it in the management section is not enough. If someone can provide an integration-test to demonstrate the issue this would be very helpful.

Another option is to try out the current tycho snapshot build to see if problem is probably already fixed with Tycho 4.x

Will try in my spare time

marcellorinaldo avatar Nov 04 '22 14:11 marcellorinaldo

I too have seen exactly the same error. As soon as the <extensions>true</extensions> is removed from the pom, the PublishFeaturesAndBundlesMojo works as expected:

Command: mvn --non-recursive org.eclipse.tycho.extras:tycho-p2-extras-plugin:3.0.1:publish-features-and-bundles

POM fails:

<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>my.group</groupId>
  <artifactId>my.artifact</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>pom</packaging>
  <build>
      <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>tycho-maven-plugin</artifactId>
        <version>3.0.1</version>
        <extensions>true</extensions>
      </plugin>
      <plugin>
        <groupId>org.eclipse.tycho.extras</groupId>
        <artifactId>tycho-p2-extras-plugin</artifactId>
        <version>3.0.1</version>
        <inherited>false</inherited>
        <configuration>
          <append>true</append>
          <compress>true</compress>
          <publishArtifacts>true</publishArtifacts>
        </configuration>
      </plugin>

<!-- other build stuff -->

  <modules>
    <!-- some modules of "eclipse-pugin", "eclipse-feature" and "eclipse-target-definition" -->
  </modules>
</project>

POM works:

<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>my.group</groupId>
  <artifactId>my.artifact</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>pom</packaging>
  <build>
      <plugin>
        <groupId>org.eclipse.tycho.extras</groupId>
        <artifactId>tycho-p2-extras-plugin</artifactId>
        <version>3.0.1</version>
        <inherited>false</inherited>
        <configuration>
          <append>true</append>
          <compress>true</compress>
          <publishArtifacts>true</publishArtifacts>
        </configuration>
      </plugin>

<!-- other build stuff -->

  <modules>
    <!-- some modules of "eclipse-pugin", "eclipse-feature" and "eclipse-target-definition" -->
  </modules>
</project>

But I now need <extensions>true</extensions> in all the child POMs

chrislake avatar Feb 14 '23 10:02 chrislake

the PublishFeaturesAndBundlesMojo works as expected

Can you explain what you expect it to do for a pom project?

laeubi avatar Feb 14 '23 10:02 laeubi

@laeubi ,

The POM is just used for configuration so I don't have to have -Dxxx=yyy on the command line. Therefore I could use an entirely separate POM from the main build POM to do this one step.

As to what I expect though, I have a directory structure with:

root
|-- target
    |-- source
        |-- features
            |-- my.feature_1.0.0.jar
        |-- plugins
            |-- my.plugin.1_1.0.0.jar
            |-- my.plugin.2_1.0.0.jar
            |-- my.plugin.2_1.0.0.jar
-- pom.xml

Upon executing the publish-features-and-bundles goal, I then get a root/target/repository p2 repository complete with artifacts.jar and contents.jar which I then upload in it's entirety to my server for use.

chrislake avatar Feb 15 '23 01:02 chrislake

I have now created a minimal demo project and it works as expsected:

https://github.com/eclipse-tycho/tycho/tree/master/demo/publish-p2

laeubi avatar Feb 16 '23 13:02 laeubi

I can reproduce the error when using the example and additionally enable the tycho-maven-plugin, so maven has some classlaoding issues then, but as the tycho-maven-plugin is not required when using publish-features-and-bundles, so the easiest soloution seems to not enable it together.

laeubi avatar Feb 16 '23 13:02 laeubi

There should be a fix in approx 1 hr when this build has completed:

  • 3.0.3-SNAPSHOT: https://ci.eclipse.org/tycho/job/tycho-github/job/tycho-3.0.x/15/
  • 4.0.0-SNAPSHOT: https://ci.eclipse.org/tycho/job/tycho-github/job/master/122/

Please try out the current tycho snapshot build then and report if you are still seeing issues.

laeubi avatar Feb 16 '23 16:02 laeubi