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

Regression: IllegalArgumentException configuring project that uses tycho and bundle plugins #4

Open
martiell opened this issue Oct 24, 2011 · 17 comments

Comments

@martiell
Copy link

The pom below can be imported and used with m2e-tycho 0.5.0.201108311102.
However, m2e-tycho 0.6.0.201110151902 fails to import the project with the following error.

An internal error occurred during: "Importing Maven projects".
java.lang.IllegalArgumentException
    at org.sonatype.tycho.m2e.internal.OsgiBundleProjectConfigurator.generateBundleManifest(OsgiBundleProjectConfigurator.java:76)
    at org.sonatype.tycho.m2e.internal.OsgiBundleProjectConfigurator.configureRawClasspath(OsgiBundleProjectConfigurator.java:178)
    at org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.invokeJavaProjectConfigurators(AbstractJavaProjectConfigurator.java:180)
    at org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.configure(AbstractJavaProjectConfigurator.java:128)
    at org.eclipse.m2e.core.project.configurator.AbstractLifecycleMapping.configure(AbstractLifecycleMapping.java:72)
    at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationManager.java:302)
    at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.configureNewMavenProject(ProjectConfigurationManager.java:234)
    at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.importProjects(ProjectConfigurationManager.java:150)
    at org.eclipse.m2e.core.ui.internal.wizards.MavenImportWizard$1.doCreateMavenProjects(MavenImportWizard.java:164)
    at org.eclipse.m2e.core.ui.internal.wizards.AbstractCreateMavenProjectsOperation.run(AbstractCreateMavenProjectsOperation.java:73)
    at org.eclipse.m2e.core.ui.internal.wizards.MavenImportWizard$3.runInWorkspace(MavenImportWizard.java:249)
    at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
<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>1-SNAPSHOT</version>
  <packaging>bundle</packaging>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.report.outputEncoding>UTF-8</project.report.outputEncoding>
  </properties>

  <build>
    <plugins>

      <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>tycho-packaging-plugin</artifactId>
        <version>0.13.0</version>
        <executions>
          <execution>
            <id>timestamp</id>
            <phase>validate</phase>
            <goals>
              <goal>build-qualifier</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <version>2.3.5</version>
        <extensions>true</extensions>
        <executions>
          <execution>
            <id>bundle-manifest</id>
            <phase>process-classes</phase>
            <goals>
              <goal>manifest</goal>
            </goals>
            <configuration>
              <instructions>
                <Bundle-Version>${unqualifiedVersion}.${buildQualifier}</Bundle-Version>
              </instructions>
              <manifestLocation>META-INF</manifestLocation>
            </configuration>
          </execution>
        </executions>
      </plugin>

    </plugins>

  </build>
</project>

Furthermore, it fails to interpolate the Bundle-Version correctly:
After running process-classes through Eclipse, the manifest looks like this:

Manifest-Version: 1.0
Built-By: martin
Build-Jdk: 1.6.0_24
Bundle-Version: ${unqualifiedVersion}.${buildQualifier}
Tool: Bnd-1.43.0
Bundle-Name: test
Bnd-LastModified: 1319476527351
Created-By: Apache Maven Bundle Plugin
Bundle-ManifestVersion: 2
Bundle-SymbolicName: test

Using m2e-tycho 0.5, the version is correctly interpolated:

Manifest-Version: 1.0
Built-By: martin
Build-Jdk: 1.6.0_24
Bundle-Version: 1.201110241723
Tool: Bnd-1.43.0
Bundle-Name: test
Bnd-LastModified: 1319477010015
Created-By: Apache Maven Bundle Plugin
Bundle-ManifestVersion: 2
Bundle-SymbolicName: test
@mcculls
Copy link

mcculls commented Oct 24, 2011

Note: when using the m2eclipse-tycho configurator you don't need the extra execution to place the bnd-generated manifest under /META-INF/. If you remove the "bundle-manifest" execution you should be able to import the project.

Of course the configurator should probably be more robust and ignore / provide a better warning about the extra execution.

@mcculls
Copy link

mcculls commented Oct 24, 2011

Also, the issue about the Bundle-Version is caused by the instructions being tied to the manifest execution rather than the main plugin configuration. If you move the instructions up after removing the execution then you should get the interpolated version as expected.

@martiell
Copy link
Author

So... how can I get the timestamp in the Bundle-Version?

I have an Eclipse plugin with some pom-first dependencies.
The reason I want a timestamp in the Bundle-Version for the the pom-first dependencies is to allow the plugin and its dependencies to be updated from one snapshot version to another. Before I set the Bundle-Version to include a timestamp, the dependencies were not upgraded with the plugin because their version had not changed.

@martiell
Copy link
Author

(Sorry, your second reply took a while to arrive)

Here's what I have now:

      <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>tycho-packaging-plugin</artifactId>
        <version>0.13.0</version>
        <executions>
          <execution>
            <id>timestamp</id>
            <phase>validate</phase>
            <goals>
              <goal>build-qualifier</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <version>2.3.5</version>
        <extensions>true</extensions>
        <configuration>
          <instructions>
            <Bundle-Version>${unqualifiedVersion}.${buildQualifier}</Bundle-Version>
          </instructions>
        </configuration>
      </plugin>

Even after "Update Project Configuration" and a clean, the version is still not interpolated correctly:

$ cat target/classes/META-INF/MANIFEST.MF 
Manifest-Version: 1.0
Built-By: martin
Build-Jdk: 1.6.0_24
Bundle-Version: ${unqualifiedVersion}.${buildQualifier}
Tool: Bnd-1.43.0
Bundle-Name: test
Bnd-LastModified: 1319478486446
Created-By: Apache Maven Bundle Plugin
Bundle-ManifestVersion: 2
Bundle-SymbolicName: test

@mcculls
Copy link

mcculls commented Oct 24, 2011

Not entirely sure how the 0.13.0 tycho-packaging-plugin is supposed to play with the new configurator, but if you want to amend the qualifier to add a timestamp then you can use bnd macros. Also note that since the new configurator should work better wrt. inter-project dependencies, you might find that you don't actually need to the timestamp in the qualifier anymore (although it can still be useful if you're deploying outside of Eclipse).

Example using bnd macros to replace SNAPSHOT with a simple timestamp ( see http://www.aqute.biz/Bnd/Macros )

<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>1-SNAPSHOT</version>
  <packaging>bundle</packaging>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.report.outputEncoding>UTF-8</project.report.outputEncoding>
  </properties>

  <build>
    <plugins>

      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <version>2.3.5</version>
        <extensions>true</extensions>
        <configuration>
          <instructions>
            <Bundle-Version>$(replace;$(project.version);SNAPSHOT;$(tstamp))</Bundle-Version>
          </instructions>
        </configuration>
      </plugin>

    </plugins>
  </build>

</project>

@martiell
Copy link
Author

Thanks for the bnd tip. I'm a bit worried about using two different sources of timestamps. I'm not sure if that has any implications, but I'll give it a go tomorrow.

I don't follow your point about inter-project dependencies. To reiterate: the reason I'm using the build qualifier is to make it easier to install and update snapshot versions in an Eclipse installation.

Typically I'll install a snapshot of our plugin my main Eclipse installation every few days (dogfood, and all that). If the Bundle-Version doesn't have a build qualifier timestamp, then the bundle doesn't get updated when the feature is upgraded. (So I want the build qualifier regardless.)

@martiell
Copy link
Author

Hi Stuart,

I've made the changes you suggest, but am getting CNFEs when I try to run the plugin and bundles.
What's the most appropriate forum to discuss this? The Tycho mailing list?

Martin

@mcculls
Copy link

mcculls commented Oct 25, 2011

On 25 Oct 2011, at 13:44, Martin [email protected] wrote:

Hi Stuart,

I've made the changes you suggest, but am getting CNFEs when I try to run the plugin and bundles.
What's the most appropriate forum to discuss this? The Tycho mailing list?

If you can trace the CNFE to missing imports in the manifests created by the bundleplugin then it's probably better to use the Felix list - can you point me to the source or provide a testcase?

You might also want to try the 2.4.0-SNAPSHOT of the bundleplugin as it includes an update to bnd and other fixes.

Martin

Reply to this email directly or view it on GitHub:
https://github.com/sonatype/m2eclipse-tycho/issues/4#issuecomment-2516518

@martiell
Copy link
Author

I think the manifests are OK. The maven build works, and the plugins are installable.
And I've been able to run the plugin through Eclipse using m2e-tycho 0.5.

It's just the upgrade to m2e-tycho 0.6 I'm struggling with. I'll try to put together a test case.

@BohoCode
Copy link

I'm getting this problem too. It seems to have the knock on effect of preventing the project from being seen as part of the workspace in the OSGi run configurations. - Meaning you can't use the built in OSGi run and debug support in eclipse.

I've tried all day to find a work around and simply can't. @martiell - I'm also using m2e-tycho 0.6. I can also confirm that if I remove the maven-bundle-plugin I don't get this exception. However, I also don't get a built bundle!

@mcculls
Copy link

mcculls commented Apr 18, 2012

@BohoCode can you provide a test project? Also make sure you're using the latest maven-bundle-plugin (2.3.7) and the latest m2eclipse-tycho (https://repository.sonatype.org/content/repositories/forge-sites/m2eclipse-tycho/0.6.0/N/0.6.0.201202131819/)

@martiell
Copy link
Author

@BohoCode I use the following in the parent pom for pom-first (i.e. maven-bundle-plugin) projects.

The trick seems to be configuring the lifecycle mapping to execute the build-qualifier goal on pom-first projects (but not manifest-first projects).

    <pluginManagement>
      <plugins>

        <plugin>
          <groupId>org.eclipse.tycho</groupId>
          <artifactId>tycho-packaging-plugin</artifactId>
          <version>${tycho.version}</version>
          <executions>
            <execution>
              <id>timestamp</id>
              <phase>validate</phase>
              <goals>
                <goal>build-qualifier</goal>
              </goals>
            </execution>
          </executions>
        </plugin>

        <plugin>
          <groupId>org.apache.felix</groupId>
          <artifactId>maven-bundle-plugin</artifactId>
          <extensions>true</extensions>
          <configuration>
            <manifestLocation>META-INF</manifestLocation>
            <instructions>
              <Bundle-Version>${unqualifiedVersion}.${buildQualifier}</Bundle-Version>
            </instructions>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.eclipse.m2e</groupId>
          <artifactId>lifecycle-mapping</artifactId>
          <version>1.0.0</version>
          <configuration>
            <lifecycleMappingMetadata>
              <pluginExecutions>
                <pluginExecution>
                  <pluginExecutionFilter>
                    <groupId>org.eclipse.tycho</groupId>
                    <artifactId>tycho-packaging-plugin</artifactId>
                    <versionRange>[${tycho.version},)</versionRange>
                    <goals>
                      <goal>build-qualifier</goal>
                    </goals>
                  </pluginExecutionFilter>
                  <action>
                    <execute/>
                  </action>
                </pluginExecution>
              </pluginExecutions>
            </lifecycleMappingMetadata>
          </configuration>
        </plugin>

      </plugins>
    </pluginManagement>

@BohoCode
Copy link

Thanks @martiell - that worked for me. No more import exceptions.

@BohoCode
Copy link

@mcculls - I'll try and get a test project somewhere, but it's very hard to post code from work! May have to wait until I can set something up from home.

@sebplorenz
Copy link

This bug is quite old but I had the same problem today. For me the solution was to set the packaging type in the pom to jar.

@sslavic
Copy link

sslavic commented Sep 3, 2014

I had same issue while importing current Apache Avro svn trunk (1.8.0-SNAPSHOT) into Eclipse (4.4) with m2e (1.5.0) and Tycho Project Configurators (0.7.0).
Thanks @sebplorenz for mentioning the workaround.

@thomasmey
Copy link

Hi,

I get a similar error when using the org.sonatype.tycho.m2e plugin version 0.7.0.20130929:
!ENTRY org.eclipse.m2e.core 4 0 2014-11-16 13:54:44.389
!MESSAGE Could not update project jetty-server configuration
!STACK 0
java.lang.IllegalArgumentException
at org.sonatype.tycho.m2e.internal.OsgiBundleProjectConfigurator.generateBundleManifest(OsgiBundleProjectConfigurator.java:76)
at org.sonatype.tycho.m2e.internal.OsgiBundleProjectConfigurator.configureRawClasspath(OsgiBundleProjectConfigurator.java:178)
at org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.invokeJavaProjectConfigurators(AbstractJavaProjectConfigurator.java:173)
at org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.configure(AbstractJavaProjectConfigurator.java:129)
at org.eclipse.m2e.core.project.configurator.AbstractLifecycleMapping.configure(AbstractLifecycleMapping.java:120)
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager$3.call(ProjectConfigurationManager.java:477)
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager$3.call(ProjectConfigurationManager.java:1)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:166)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:142)
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationManager.java:470)
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration0(ProjectConfigurationManager.java:408)
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager$2.call(ProjectConfigurationManager.java:321)
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager$2.call(ProjectConfigurationManager.java:1)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:166)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:142)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:96)
at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1344)
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationManager.java:318)
at org.eclipse.m2e.core.ui.internal.UpdateMavenProjectJob.runInWorkspace(UpdateMavenProjectJob.java:77)
at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

pom is:
http://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/tree/jetty-server/pom.xml

any ideas how to fix this bug?

akfaircg added a commit to akfaircg/aem-project-archetype that referenced this issue May 18, 2017
According to the issue reported in the following link tesla/m2eclipse-tycho#4 , m2eclipse plugin doesn't need extra execution step to place the generated manifest under /META-INF/. The configurator of the m2eclipse plugin does not ignore this step which generates illegalArgumentException during the create/ import of the AEM project in/to Eclipse.
akfaircg added a commit to akfaircg/aem-project-archetype that referenced this issue May 18, 2017
Removed executions tag and its subtags.According to this [issue](tesla/m2eclipse-tycho#4), this extra execution step interferes with m2eclipse plugin configurator. the plugin does not ignore this step which generates illegalArgumentException during the create/import of the AEM project in/to Eclipse.
rombert pushed a commit to adobe/aem-project-archetype that referenced this issue May 24, 2017
This also fixes adobe/aem-eclipse-developer-tools#78

Removed executions tag and its subtags. According to [1] this extra execution
step interferes with m2eclipse plugin configurator. the plugin does not ignore
this step which generates illegalArgumentException during the create/import
of the AEM project in/to Eclipse.

[1]: tesla/m2eclipse-tycho#4
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

6 participants