Unknown packaging: eclipse-target-definition - eclipse-rcp

I'm trying to build an application based on the Eclipse 4 RCP platform and built with Tycho. I followed the article http://blog.vogella.com/2013/01/03/tycho-advanced/ to use a PDE target definition, and the following error occurs when building my project:
[ERROR] Unknown packaging: eclipse-target-definition
My project's modules architecture is adapted from the EclipseCon 2013 Tycho Demo, plus the target module:
- mybundle.myproject.bundle
- mybundle.myproject.bundle.tests
- mybundle.myproject.feature
- mybundle.myproject.parent
- mybundle.myproject.target
I'm using tycho 0.18.1, and the pom.xml from the mybundle.myproject.target module that generates the error is:
<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>
<artifactId>mybundle.myproject.repository</artifactId>
<packaging>eclipse-repository</packaging>
<parent>
<groupId>mybundle</groupId>
<artifactId>mybundle.myproject.parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
</project>
For further info, the full debug log is here: http://pastebin.com/dMEckvsH
Is there something I'm missing? The eclipse-target-definition packaging should work with this Tycho version.

The problem cause of the problem is in the debug output you have linked. Compare the output before the failure ...
[DEBUG] Extension realms for project mybundle:mybundle.myproject.target:eclipse-target-definition:0.0.1-SNAPSHOT: (none)
[DEBUG] Looking up lifecyle mappings for packaging eclipse-target-definition from ClassRealm[plexus.core, parent: null]
... with the output of a previous, successful lookup of one of Tycho's packaging types:
[DEBUG] Extension realms for project mybundle:mybundle.myproject.repository:eclipse-repository:0.0.1-SNAPSHOT: [ClassRealm[extension>org.eclipse.tycho:tycho-maven-plugin:0.18.1, parent: sun.misc.Launcher$AppClassLoader#affc70]]
[DEBUG] Looking up lifecyle mappings for packaging eclipse-repository from ClassRealm[project>mybundle:mybundle.myproject.parent:0.0.1-SNAPSHOT, parent: ClassRealm[maven.api, parent: null]]
Here is what you can read from the output: The project mybundle.myproject.target doesn't have any build extensions (i.e. in particular not the Tycho build extension) configured. From the second line of debug output, this seems to be because the project doesn't have the parent mybundle.myproject.parent configured like the other modules.

Related

How to use maven to generate different artifactID with different scala version?

I'm writing a library for scala 2.10 and scala 2.11.
When I install this library to maven local repository or publish to maven central. I want the artifactID of the library to have different suffixes, e.g. like:
org.apache.spark:spark-core_2.10:1.6.3 &
org.apache.spark:spark-core_2.11:1.6.3
This is easy in sbt, but my project is built in maven.
Is there a plugin that allows me to add the suffix to my artifactID easily according to different maven profile? So I can install and publish 2 different versions from a single project codebase.
Thanks a lot for your opinion!
I do this using Maven properties, e.g.
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<name>my-package</name>
<version>1.2.3</version>
<artifactId>${project.name}_${scala.compat.version}</artifactId>
...
</project>
You can set the scala.compat.version property either directly in the POM (if you only want one version), or in profiles (if you want to choose between multiple):
<properties>
<scala.compat.version>2.12</scala.compat.version>
</properties>
You can also specify it manually via the CLI, like mvn -Dscala.compat.version=2.12 package
Using the same property in your dependencies will ensure they match the chosen Scala version, e.g.
<dependency>
<groupId>org.typelevel</groupId>
<artifactId>cats-core_${scala.compat.version}</artifactId>
<version>2.1.1</version>
</dependency>
Note that this isn't ideal, since it generates the following Maven warning:
[WARNING] Some problems were encountered while building the effective model for org.example:my-package_2.12:jar:1.2.3
[WARNING] 'artifactId' contains an expression but should be a constant. # org.example:${project.name}_${scala.compat.version}:1.2.3, /private/tmp/nix-build-my-package_2.12-1.2.3.jar.drv-0/my-package-src/pom.xml, line 6, column 15
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.

How to do a modular project architecture with Maven in Eclipse?

First of all im a little newbie in Maven+Eclipse world, so please excuse me if im not explaining myself good.
Im trying to implement Maven to existing Java old projects, the architecture im trying to achive is something like this (i put an image to explain myself a little better):
The project Utils have the most of the libs, that genericlly will be used for the other projects, and some classes that will be useful for the others (like date comparison method and mathematic method etc...), this project is working well with mvn install, generating the respective .war file.
The questions are:
The N Web Modules projects must have the project Utils as a
depedency and the most of dependencies too. I
don't know how to achive this in the pom.xml of N Web Modules
projects.
I don't know if it is posible in
Eclipse+Maven: Try to do some Parent Web Project that
implements the other projects and in one single mvn install the
parent project build and install the rest of the childs
(including Utils and N Web Modules).
I hope you can orientate and help me with this.
I think you are looking for Multi-Module projects
http://books.sonatype.com/mvnex-book/reference/multimodule.html
You can put various subprojects in one larger project and build them all at once. Furthermore, modules can depend on other modules (as long as this is not circular) and they are build in the correct order.
The project Utils have the most of the libs, that genericlly will be
used for the other projects, and some classes that will be useful for
the others (like date comparison method and mathematic method etc...),
this project is working well with mvn install, generating the
respective .war file.
One advise, you should extract classes used by other projects in a maven project with a JAR packaging and not leave them in a WAR packaging.
In Maven, generally, dependencies are provided as JAR.
It may also be provided as WAR by configuring the maven-war-plugin with some specific properties such as attachClasses but it looks like a trick and it also may create side effects.
Here are some information on how to do it.
But the documentation doesn't advise this way :
If you need to re-use this JAR/WAR in another project, the recommended
approach is to move the classes to a separate module that builds a
JAR, and then declare a dependency on that JAR from your webapp as
well as from any other projects that need it.
About your two questions.
The N Web Modules projects must have the project Utils as a dependency
and the most of dependencies too. I don't know how to achive this in
the pom.xml of N Web Modules projects.
Just include it as a dependency in the dependencies element of the consumer project :
<?xml version="1.0" encoding="UTF-8"?>
<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>mygroup</groupId>
<artifactId>project1-consumer</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
...
<dependencies>
<dependency>
<groupId>mygroup</groupId>
<artifactId>util</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
...
</dependencies>
</project>
I don't know if it is posible in Eclipse+Maven: Try to do some Parent
Web Project that implements the other projects and in one single mvn
install the parent project build and install the rest of the childs
(including Utils and N Web Modules).
What you are looking for is designing a multi-module project.
It relies on a aggregator pom that declares each module.
Note that this module has to be specified with a pom packaging as it doesn't produce a consumable artifact.
You could define something like that :
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>mygroup</groupId>
<artifactId>myaggregatorpom</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>util</module>
<module>project1-consumer</module>
<module>project2-consumer</module>
</modules>
</project>

"No such file:" error in jenkins when integrating with Maven build

I have recently started using Jenkins as a CI tool for my Maven Selenium automation project.
The path of my local eclipse workspace is:
/media/user/Data/Automation_Scripts
and the complete path of the pom.xml file used to execute the project is:
/media/user/Data/Automation_Scripts/[project_name]/pom.xml
Now, I have installed Jenkins and added a Maven project to it. When I try to enter the path my project's pom.xml file in the 'Root POM' text field under 'Build' I get following error:
No such file: ‘/media/user/Data/Automation_Scripts/test/pom.xml’
Whereas if I navigate to the same path the pom.xml file is present. When I build the Maven project in Jenkins, following error is shown:
Started by user Test Building in workspace
/var/lib/jenkins/jobs/TEST/workspace Parsing POMs ERROR: No such file
/media/user/Data/Automation_Scripts/test/pom.xml Perhaps you need to
specify the correct POM file path in the project configuration?
Finished: FAILURE
Update:
I created a pom.xml file in my jenkins workspace which is located at:
/var/lib/jenkins/jobs/TEST/workspace
In this pom file have given path of my actual pom.xml (which is located in another folder) in the following way:
<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>
<name>Maven Default Project</name>
<artifactId>jenkins_test</artifactId>
<parent>
<groupId>ca.test</groupId>
<artifactId>maven_test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>/media/user/Data/Automation_Scripts/test/pom.xml</relativePath>
</parent>
</project>
Still I am getting following error now:
Building in workspace /var/lib/jenkins/jobs/TEST/workspace
Parsing POMs
ERROR: Failed to parse POMs
org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM: Could not find artifact ca.test:maven_test:pom:0.0.1-SNAPSHOT and 'parent.relativePath' points at wrong local POM # line 6, column 9
at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:364)
at hudson.maven.MavenEmbedder.buildProjects(MavenEmbedder.java:361)
at hudson.maven.MavenEmbedder.readProjects(MavenEmbedder.java:331)
at hudson.maven.MavenModuleSetBuild$PomParser.invoke(MavenModuleSetBuild.java:1301)
at hudson.maven.MavenModuleSetBuild$PomParser.invoke(MavenModuleSetBuild.java:1098)
at hudson.FilePath.act(FilePath.java:1018)
at hudson.FilePath.act(FilePath.java:996)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.parsePoms(MavenModuleSetBuild.java:960)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:679)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
at hudson.model.Run.execute(Run.java:1720)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:531)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:404)
Finished: FAILURE
I guess there is something wrong with the relative path. Can you tell me what I am missing here?
Try providing relative path instead of actual absolute path.
By default jenkins job considers path as workspace path.
Make pom.xml available in workspace of the job and provide path as just file name I.e pom.xml

How to create a maven project in eclipse which give a war which in turn contains sub modules as jar?

I am having client requirement that maven project which generate a war which in turn contains submodules as the jar?
let me clarify the question
This is my master pom.xml inside that i am having two modules named child1 and child2.
I need a MasterWebApp.war inside which the child1.jar and child2.jar presents.
If i changing the packaging as war to packaging - pom then error disappeared but i cant get the required war while maven clean install
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.abc</groupId>
<artifactId>MasterWebApp</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>Master Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<org.springframework.version>4.1.7.RELEASE</org.springframework.version>
</properties>
<modules>
<module>child1</module>
<module>child2</module>
</modules>
.......
you can execute two ways.
1) in eclipse.
Right click on project , click on run as --> maven build , give goals as "clean install" will generate war in target folder of your project
2) using command prompt, navigate to directory where pom.xml present and execute below commands
mvn clean install package
it will generate war in target folder
Thanks Raghav, i searched for any alternative way to achieve this, but no more available, so i used the way which u gave the link.
Thanks for the help.

Performing substitutions in Eclipse product configuration file with tycho

I have a Eclipse RCP product which I build with Tycho. After some smaller issues, this is working pretty fine and I have both CI and releases as wanted.
The product in question is provided both as an installable stand-alone RCP application and as an update site so the functionality can be installed in a vanilla Eclipse installation. This works fine as well.
The product have a main feature - which is used on the update site - and I would very much like the feature and the product to have the same version number. As it is today, this version number is mentioned is many places and I would really like to reduce this to just one. I currently have the version number in
the feature.xml of the main feature
the pom.xml of the same feature
the .product file for the product configuration file
the pom.xml of the project with the .product file
the categories.xml file of the update site
the about.mappings file
I have tried to use maven resource filters and that works for the POM files and about.mappings, but not for the rest. This is my current pom.xml for the main feature:
<?xml version="1.0" encoding="UTF-8"?>
<project ...>
<modelVersion>4.0.0</modelVersion>
<artifactId>...main.feature</artifactId>
<version>${product.version}-SNAPSHOT</version>
<packaging>eclipse-feature</packaging>
<parent>
<groupId>...</groupId>
<artifactId>...parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../...parent</relativePath>
</parent>
<build>
<!-- Substitutions: product.version -->
<resources>
<resource>
<directory>.</directory>
<includes>
<include>feature.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</build>
</project>
When running this configuration, I get the following exception from Tycho (or an exception that looks very similar to it):
[ERROR] Internal error: java.lang.IllegalArgumentException -> [Help 1]
org.apache.maven.InternalErrorException: Internal error: java.lang.IllegalArgumentException
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:168)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
Caused by: java.lang.IllegalArgumentException
at org.eclipse.equinox.internal.p2.metadata.VersionParser.parse(VersionParser.java:93)
at org.eclipse.equinox.p2.metadata.Version.create(Version.java:79)
at org.eclipse.tycho.p2.impl.publisher.FeatureDependenciesAction.getVersion(FeatureDependenciesAction.java:126)
at org.eclipse.tycho.p2.impl.publisher.AbstractDependenciesAction.perform(AbstractDependenciesAction.java:79)
... 11 more
(I have cut some lines...)
Basically, the embedded maven process seems to not perform the resource filtering at all for this type of packaging. Or??
I have tried many different things, but I cannot get it to work. My best guess is that I have to configure the lifecycle, but how...
Can anybody help me with this?
this is a known bug:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=362252
You don't need to specify versions explicitly in the categories.xml. Just specify 0.0.0 as version, and Tycho will replace it by the actual version of the included feature.