Tycho build fails with "No content specified for p2 repository" although there is a category.xml - eclipse

The Eclipse plug-in Markdown-Editor doesn't build with Maven/Tycho. The build fails with the message
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-p2-repository-plugin:0.18.1:assemble-repository (default-assemble-repository)
on project markdown.editor.site: No content specified for p2 repository -> [Help 1]
The similar configuration StartExplorer plugin works fine:
category.xml:
<?xml version="1.0" encoding="UTF-8"?>
<site>
<feature url="features/markdown.editor.feature_1.0.0.jar" id="markdown.editor.feature" version="1.0.0">
<category name="markdowneditor"/>
</feature>
<category-def name="markdowneditor" label="Markdown Editor">
<description>
Extend the text editor to provide good Markdown support.
</description>
</category-def>
</site>
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.winterwell.markdown</groupId>
<artifactId>markdown.editor.parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>markdown.editor.site</artifactId>
<packaging>eclipse-repository</packaging>
<name>Markdown Editor (site)</name>
<description>Markdown Editor (site)</description>
</project>
Related to tycho-p2-repository-plugin fails with "No content specified for p2 repository"
and How to correctly specify eclipse-plugins in category.xml of tycho eclipse-repository?

If version is defined with -SNAPSHOT``, then incategory.xmlversion should have.qualifier`
<feature url="features/markdown.editor.feature_1.0.0.jar" id="markdown.editor.feature" version="1.0.0.qualifier">

Related

Maven/Eclipse does not copy my tests resources to the target/test-classes directory

When I try to debug my unit tests with Eclipse, my resources are not found (getResourceAsStream returns null) because maven/Eclipse? does not copy them to the target/test-classes. Why are the test classes build but resources not copied?
I did post the answer to this question with the question.
I am using Eclipse 2022-09 with m2e 2.0.1... Maven 3.8.5, maven-resources-plugin 3.2.0.
the pom
<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>MyArticactId</artifactId>
<packaging>jar</packaging>
<name>MyName</name>
<parent>
<groupId>MyGropupId</groupId>
<artifactId>ParentArtifactId</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<properties>
<maven.test.skip>true</maven.test.skip>
</properties>
<dependencies>
...
</dependencies>
</project>
Learned the hard way that Eclipse compiled the test classes to the target/test-classes directory but did not copy the resources if maven.test.skip is set to true.
<maven.test.skip>true</maven.test.skip>
I have to set maven.test.skip to false to be able to debug tests that require resources. It would have been easier to identify the configuration problem had Eclipse not generated the test class files (the same way Maven does not).
ref: https://bugs.eclipse.org/bugs/show_bug.cgi?id=407636

Adding a local Maven project as a dependency in another local Maven project

I have a local java application that I have recently converted to a Maven project. My goal is to add my recently converted maven project to another Maven project as a dependency in Eclipse STS.
The temporary path of the recently converted maven project is C:\Users\nconnor2\Desktop and the path of the soon-to-be parent Maven project is C:\Users\nconnor2\Desktop\adoudrepo.
I'm really struglling to wrap my head around how maven works when dealing with local maven project.
The pom of my new maven project 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>
<groupId>TB2TUBSync</groupId>
<artifactId>TB2TUBSync</artifactId>
<version>1.5</version>
</project>
The pom of my soon-to-be parent Maven project is
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.bellmts</groupId>
<artifactId>test</artifactId>
<name>TB2TUBSyncWeb</name>
<packaging>war</packaging>
<version>1.0.0-SNAPSHOT</version>
What I have been trying to do is to include my new maven project as a module in my soon-to-be parent maven project but I get an error that I can't include a module in another maven project with war packaging.
At the end of the day I need to access methods from TB2TUBSync (new maven) in TB2TUBSyncWeb (soon-to-be parent maven).
You'll want to leverage the WAR Plugin to generate both JARs and the WAR file, then you can publish the jars to your local repository with mvn clean install. At that point you can import them into the other POM with dependency resolution.
It's detailed at https://eureka.ykyuen.info/2009/10/30/maven-dependency-on-jarwar-package/ .

When automating Eclipse's "Export as Feature", Maven/Tycho doesn't see my plugin

I have a plugin and a feature project in my workspace. When I export the feature manually via File > Export As > Feature everything works well. I'm trying to write an automatic plugin building and exporting script to get rid of this chore. I converted feature project to Maven project and filled pom.xml with:
<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>MyProject</groupId>
<artifactId>NMGDBPluginFeature</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-feature</packaging>
<properties>
<tycho-version>0.22.0</tycho-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>eclipse-luna</id>
<layout>p2</layout>
<url>http://download.eclipse.org/releases/luna</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho-version}</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>
However script throws:
[ERROR] Cannot resolve project dependencies:
[ERROR] Software being installed: NMGDBPluginFeature.feature.group 1.0.0.qualifier
[ERROR] Missing requirement: NMGDBPluginFeature.feature.group 1.0.0.qualifier requires 'GDBFifoBlocks [1.0.0.gdbfifoblocks]' but it could not be found
How could that happen? I thought pom.xml uses feature.xml of project, doesn't it? What is a proper configuration?
So far, your configuration looks good. However you currently only have an automated build for your feature, but not the for the plugin. Unlike the Eclipse export wizard, eclipse-feature only processes the feature.xml - and it expects that the referenced plugins are built elsewhere.
So what you need to do is to set up a Maven reactor which includes both an eclipse-feature and an eclipse-plugin project. Here is how you do this:
Make your current pom.xml the parent POM: Change the packaging to pom, adapt the artifactId to something which makes sense (e.g. MyProject.parent), and move the pom.xml into a new general project in your workspace.
Add a pom.xml in the root of the feature project:
<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>
<parent>
<groupId>MyProject</groupId>
<artifactId>MyProject.parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>relative/path/to/parent/project</relativePath>
</parent>
<artifactId>NMGDBPluginFeature</artifactId>
<packaging>eclipse-feature</packaging>
</project>
Add another pom.xml in the root of the plugin project, which is the same as the one above except for the artifactId - this needs to be the same as the plugin's Bundle-SymbolicName - and the packaging which needs to be eclipse-plugin.
Include the plugin and feature projects in the Maven reactor by adding a <modules> section in the parent POM with the paths to these projects:
<modules>
<module>relative/path/to/plugin/project</module>
<module>relative/path/to/feature/project</module>
</modules>
Note that the paths need to be adapted so that they are correct for the project locations on disk (which may be different to what is shown in the Eclipse workspace). The paths need to be relative, so they probably start with ../.
Now you can trigger a Maven build on your parent POM, and the feature should be able to resolve the reference to your plugin. In Eclipse, you can trigger the Maven build from the context menu of the pom.xml file. Or, if you also convert the parent project to a Maven project, the you can also run Maven builds from the context menu of the project root.

build maven downstream projects in eclipse

When Jenkins builds a project it automatically builds all downstream projects. That is, all projects that are dependent on the project beiing built. Is it possible to replicate that behaviour in Eclipse with m2eclipse?
You mean modules?
check this link:
This is the basic idea:
<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/maven4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>exampleApp</name>
<packaging>pom</packaging>
<modules>
<module>dependency1</module>
<module>dependency12</module>
<module>mainProject</module>
</modules>
</project>

Creating multi module Maven Projects in Eclipse

Trying to create a multi module maven project in eclipse.
Parent Pom.xml
<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>parent</groupId>
<artifactId>proj1</artifactId>
<version>${myversion}</version>
<packaging>pom</packaging>
<properties>
<myversion>1.0.0</myversion>
</properties>
<modules>
<module>child1</module>
<module>child2</module>
</modules>
</project>
Child-Module 1 Pom.xml
<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>
<parent>
<artifactId>proj1</artifactId>
<groupId>parent</groupId>
<version>${myversion}</version>
</parent>
<groupId>parent</groupId>
<artifactId>child1</artifactId>
<version>${myversion}</version>
</project>
Child Module 2 Pom.xml
<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>
<parent>
<artifactId>proj1</artifactId>
<groupId>parent</groupId>
<version>${myversion}</version>
</parent>
<groupId>parent</groupId>
<artifactId>child2</artifactId>
<version>${myversion}</version>
<dependencies>
<dependency>
<groupId>parent</groupId>
<artifactId>child1</artifactId>
<version>${myversion}</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
If I use mvn clean install on command line from the parent folder I can build find. All the projects are build successfully.
But in eclipse I keep getting an error for Child Module 2 pom.xml
Description Resource Path Location Type
parent:child1:1.0.0:jar Missing:
----------
1) parent:proj1:pom:${myversion}
----------
1 required artifact is missing.
for artifact:
parent:proj1:pom:${myversion}
from the specified remote repositories:
central (http://repo1.maven.org/maven2, releases=true, snapshots=false)
pom.xml /child2 line 1 Maven Problem
I need to achieve 2 things
1. have a maven property define the version in the parent pom file.
2. use this property to define the version in all the child modules.
What should I do? I am stuck. Please help.
I am using Eclipse Galileo with m2Eclipse
This can't work, you can't get the version of the parent to use from the parent (and actually, properties don't get substituted in the parent element, see MNG-624). So you need to hard code the version and your parent POM should be:
<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>parent</groupId>
<artifactId>proj1</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<modules>
<module>child1</module>
<module>child2</module>
</modules>
</project>
And in your child POM 1. you need to hardcode the version in /project/parent/version 2. you don't need to specify the <version> (you inherit it) 3. use the ${project.version} property in dependencies.
<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>
<parent>
<artifactId>proj1</artifactId>
<groupId>parent</groupId>
<version>1.0.0</version>
</parent>
<groupId>parent</groupId>
<artifactId>child2</artifactId>
<!--version>${myversion}</version--> <!-- Inherited -->
<dependencies>
<dependency>
<groupId>parent</groupId>
<artifactId>child1</artifactId>
<version>${project.version}</version> <!-- use the built-in property here -->
<!--type>jar</type--> <!-- This is a default, you can omit it -->
<!--scope>compile</scope--> <!-- This is a default, you can omit it -->
</dependency>
</dependencies>
</project>
Versionless parent elements will be supported in Maven 3.1.
See also
Missing artifact error in Maven
Eliminate Maven POM Redundancy
Maven 3 - Worth it???