Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [m2e-users] M2E Update Project issue

Hi Markward,


Thanks for your input. What you describe in your first paragraph certainly fits with my own observations and suggests there may be an issue with m2e (or maybe it’s being stretched beyond its intended functionality – I’m not sure yet).


I’d be interested to see specifically what you did with build-helper-maven-plugin. I had already come across it and read a little about it, but was unsure how I might configure it to help the situation.



We used to have our external libs linked statically. However, when we recently switched to a Maven build process, I wanted to set everything up as neat as possible to help with maintenance in the future. That’s why I’m trying to get Maven to re-package the libraries for OSGi in a standard way. The example I posted was for log4j, and you are right that there are already OSGi versions of it available. However, the same is not necessarily true for all libraries so I need a standard way to build them (two other examples are, and another compound library that I build from net.sourceforge.cssparser:cssparser:0.9.7 and org.w3c.css:sac:1.3).


I’d also be interested in details of how to create the maven-generated p2 repository from a collection of libraries as it might be a good alternative to the repackaging. Could you provide a reference or perhaps even share the relevant part of your pom?



Thanks and Regards,




From: m2e-users-bounces@xxxxxxxxxxx [mailto:m2e-users-bounces@xxxxxxxxxxx] On Behalf Of Markward Schubert
Sent: 22 June 2012 16:18
To: Maven Integration for Eclipse users mailing list
Subject: Re: [m2e-users] M2E Update Project issue


Hi Dave!

I think we have/had a similar issue here. We have plenty of manifest first projects, among them three with a legacy folder named "lib", where some repackaged libs reside. Whenever we change a branch, the ide notices, that the projects are not up to date anymore and suggests a call of "Update Project Configuration". Doing this will in the first call "destroy" these project's project-setup with an error message. Then triggering "Update Project Configuration" again, repairs the project.

Today I was experimenting with the build-helper-maven-plugin.
I am adding the librarie's directory in the plugins configuration and the issue seems to be at least reduced, if not resolved.

But: We have the external libs statically in our projects and do not fetch them as part of the maven build process.

I don't know if i missed something in your requirements, but do you know the Spring Enterprise Bundle Repository at ?

They have osgi-copatible versions of many commonly used libraries. Also we made the experience, that recent versions of popular libraries are osgi compatible in the meantime. We collect these in our project in a maven generated p2-repository, which we use in our targetplatform, so we do not need to repackage them.

Hope I could help a bit.


2012/6/22 Dave Hartnoll <dhartnoll@xxxxxxxxxxxxxxxxx>

I am aware of maven-dependency-plugin not being supported. However, I am fairly certain that my use of it in the project is safe, and is not the cause of the .classpath anomalies I highlighted. As I mentioned in the original post, I am getting similar .classpath issues on a multi-package maven-structured Java project. This other project definitely does not use the maven-dependency-plugin.

It's difficult to re-construct this simple project without maven-dependency-plugin as I need somehow to get the dependent library copied into the workspace. However, I can simply comment-out the references to the plugin after the project has been built for the first time as the library is then always present in target/libs (until a clean is done). After saving the pom with maven-dependency-plugin removed, and re-running Update Project several times, I still see the same .classpath anomolies.


-----Original Message-----
From: m2e-users-bounces@xxxxxxxxxxx [mailto:m2e-users-bounces@xxxxxxxxxxx] On Behalf Of Igor Fedorenko
Sent: 22 June 2012 14:50
To: m2e-users@xxxxxxxxxxx
Subject: Re: [m2e-users] M2E Update Project issue

Running maven-dependency-plugin inside workspace is not supported. From m2e wiki [1]

Beware that m2e does not provide any safeguards against rogue maven plugins that leak classloaders, modify random files inside workspace or throw nasty exceptions to fail the build. Use this as the last resort and make sure you know what you are doing.

Can you reproduce the problem without this?



On 12-06-22 9:23 AM, Dave Hartnoll wrote:
> I am putting together a large Eclipse RCP project using Eclipse 3.7.2, Tycho 0.15.0 and m2e 1.1 latest. On several occasions, I have seen errors along the lines of "The project is not up to date with the pom. Run Update Project" (paraphrasing from memory). This happens more often when updating a project from source control such as when committing changes from one PC and updating on another. The problem is that running Maven->Update Project... does not always resolve the problem immediately - it sometimes has to be run twice - with no net change in any of the project data.
> I've managed to extract and simplify a single small project that can be used to repeat some of the anomalies I am seeing. This project simply repackages a standard jar library (Log4j) as an OSGi plug-in. There may be better ways to do this, and as an aside I'd be interested to hear them, but this is really irrelevant for now as I get similar issues with a larger multi-package maven-structured Java project too.
> The attached .zip contains the necessary Eclipse project files.
>    1. Create a new general project (File->New->Project... then General->Project)
>    2. Copy the contents of the .zip to the project (overwriting the existing .project file).
>    3. Right-click project, choose Run As->Maven build
>    4. In the 'Edit Configuration' dialogue, type 'package' into the Goals field
>    5. Click 'Refresh' tab; click 'Refresh resources upon completion'
>    6. Click 'Run'
> Maven should now download some artifacts and build the OSGi version of the Log4j library.
> Next, open the .classpath from the project so you can see what happens
> during the next steps. (If you can't see .classpath, open the Package
> Explorer menu - the down-pointing white triangle - and select
> 'Filters...'. In the next dialogue, uncheck '.* resources' and click
> OK.)
> Now here is the weird behaviour...
>     a. Right-click the project and select 'Maven->Update Project...'. Click OK in the next dialogue.
>     b. Notice what happens to the contents of .classpath
> Repeat steps a and b a few more times and notice how eventually the project toggles between two states, one of which is OK (but contains more than necessary) and the other which has errors - the .classpath only references a 'classes' folder (that is also not necessary), but loses the reference to the needed library.
> I'm not sure if this is purely an m2e bug or an understanding/configuration issue that has caused m2e to behave strangely. Any help gratefully received. (NB: although I'm using m2e 1.1 latest from sonatype's repo, I'm seeing similar issues with m2e 1.0 from
> Dave.
> P.S. In case anyone can't access the .zip file, I've listed the 5
> files that seed the Eclipse project below
> =====================================================
> =====================================================
> Manifest-Version: 1.0
> Bundle-ManifestVersion: 2
> Bundle-Name: Log4j as OSGI plugin
> Bundle-SymbolicName: jar2plugin.log4j
> Bundle-Version: 1.2.16
> Bundle-ClassPath: target/libs/log4j-1.2.16.jar
> Export-Package: org.apache.log4j,
>   org.apache.log4j.xml
> Bundle-RequiredExecutionEnvironment: JavaSE-1.6
> =====================================================
> .classpath
> =====================================================
> <?xml version="1.0" encoding="UTF-8"?> <classpath>
>       <classpathentry kind="lib" path="target/libs/log4j-1.2.16.jar"/>
> </classpath>
> =====================================================
> .project
> =====================================================
> <?xml version="1.0" encoding="UTF-8"?>
> <projectDescription>
>       <name>jar2plugin.log4j</name>
>       <comment></comment>
>       <projects>
>       </projects>
>       <buildSpec>
>               <buildCommand>
>                       <name>org.eclipse.pde.ManifestBuilder</name>
>                       <arguments>
>                       </arguments>
>               </buildCommand>
>               <buildCommand>
>                       <name>org.eclipse.m2e.core.maven2Builder</name>
>                       <arguments>
>                       </arguments>
>               </buildCommand>
>       </buildSpec>
>       <natures>
>               <nature>org.eclipse.m2e.core.maven2Nature</nature>
>               <nature>org.eclipse.pde.PluginNature</nature>
>               <nature>org.eclipse.jdt.core.javanature</nature>
>       </natures>
> </projectDescription>
> =====================================================
> =====================================================
> bin.includes = META-INF/,\
>                 .,\
>                 target/libs/log4j-1.2.16.jar
> =====================================================
> pom.xml
> =====================================================
> <project xmlns="" xmlns:xsi="" xsi:schemaLocation="">
>    <modelVersion>4.0.0</modelVersion>
>    <groupId>jar2plugin</groupId>
>    <artifactId>jar2plugin.log4j</artifactId>
>    <version>1.2.16</version>
>    <packaging>eclipse-plugin</packaging>
>       <properties>
>               <tycho-version>0.15.0</tycho-version>
>               <>UTF-8</>
>       </properties>
>       <dependencies>
>               <dependency>
>                       <groupId>log4j</groupId>
>                       <artifactId>log4j</artifactId>
>                       <version>1.2.16</version>
>                       <type>jar</type>
>                       <scope>compile</scope>
>               </dependency>
>       </dependencies>
>       <build>
>               <plugins>
>                       <plugin>
>                               <groupId>org.eclipse.tycho</groupId>
>                               <artifactId>tycho-maven-plugin</artifactId>
>                               <version>${tycho-version}</version>
>                               <extensions>true</extensions>
>                       </plugin>
>                       <plugin>
>                               <groupId>org.apache.maven.plugins</groupId>
>                               <artifactId>maven-dependency-plugin</artifactId>
>                               <executions>
>                                       <execution>
>                                               <id>copy-dependencies</id>
>                                               <phase>initialize</phase>
>                                               <goals>
>                                                       <goal>copy-dependencies</goal>
>                                               </goals>
>                                               <configuration>
>                                                       <excludeTransitive>true</excludeTransitive>
>                                                       <includeArtifactIds>log4j</includeArtifactIds>
>                                                       <outputDirectory>target/libs</outputDirectory>
>                                                       <overWriteReleases>true</overWriteReleases>
>                                                       <overWriteSnapshots>true</overWriteSnapshots>
>                                                       <overWriteIfNewer>true</overWriteIfNewer>
>                                               </configuration>
>                                       </execution>
>                               </executions>
>                       </plugin>
>               </plugins>
>               <pluginManagement>
>                       <plugins>
>                               <plugin>
>                                       <groupId>org.eclipse.m2e</groupId>
>                                       <artifactId>lifecycle-mapping</artifactId>
>                                       <version>1.0.0</version>
>                                       <configuration>
>                                               <lifecycleMappingMetadata>
>                                                       <pluginExecutions>
>                                                               <pluginExecution>
>                                                                       <pluginExecutionFilter>
>                                                                               <groupId>org.apache.maven.plugins</groupId>
>                                                                               <artifactId>maven-dependency-plugin</artifactId>
>                                                                               <versionRange>[0.0.0,)</versionRange>
>                                                                               <goals>
>                                                                                       <goal>copy-dependencies</goal>
>                                                                                       <goal>unpack</goal>
>                                                                               </goals>
>                                                                       </pluginExecutionFilter>
>                                                                       <action>
>                                                                               <execute>
>                                                                                       <runOnIncremental>false</runOnIncremental>
>                                                                               </execute>
>                                                                       </action>
>                                                               </pluginExecution>
>                                                       </pluginExecutions>
>                                               </lifecycleMappingMetadata>
>                                       </configuration>
>                               </plugin>
>                       </plugins>
>               </pluginManagement>
>       </build>
> </project>
> _______________________________________________
> m2e-users mailing list
> m2e-users@xxxxxxxxxxx

m2e-users mailing list
m2e-users mailing list


Back to the top