I'm trying to build my eclipse-plugin using tycho.
My package com.mycompany.math requires org.apache.commons.math-1.2.0, which is installed in my p2-repository.
The dependency is defined in the MANIFEST.MF of org.mycompany.math:
Require-Bundle: org.apache.commons.math;bundle-version="1.2.0",
During my build, i get the error-message that the org.apache.commons.math-classes could not resolved.
Before the build start's, maven/tycho downloaded the 2.1.0-version.
So, my question is, why maven/tycho download's 2.1.0, when i defined in the MANIFEST.MF that i use 1.2.0.
You can see in my parent pom.xml that i defined three p2-repository's. The last one, contains my required 1.2.0-version.
My parent pom.xml:
<project...>
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>com.mycompany.build</artifactId>
<version>3.1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Build</name>
<description>Parent POM for full builds</description>
<modules>
<!-- my modules -->
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<tycho-version>0.16.0</tycho-version>
</properties>
<repositories>
<!-- configure p2 repository to resolve against -->
<repository>
<id>juno</id>
<layout>p2</layout>
<url>http://download.eclipse.org/releases/juno/</url>
</repository>
<repository>
<id>orbit</id>
<layout>p2</layout>
<url>http://download.eclipse.org/tools/orbit/downloads/drops/S20121021123453/repository/</url>
</repository>
<repository> <-- CONTAINS ORG.APACHE.COMMONS.MATH-1.2.0 !
<id>comp</id>
<layout>p2</layout>
<url>http:our-adress.com/p2/</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<!-- enable tycho build extension -->
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho-version}</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<pomDependencies>consider</pomDependencies>
<environments>
<environment>
<os>linux</os>
<ws>gtk</ws>
<arch>x86</arch>
</environment>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86</arch>
</environment>
</environments>
</configuration>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
</dependencyManagement>
And my com.company.math pom.xml
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>com.mycompany.math</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>Math</name>
<packaging>eclipse-plugin</packaging>
<parent>
<groupId>com.mycompany</groupId>
<artifactId>com.mycompany.build</artifactId>
<version>3.1.0-SNAPSHOT</version>
<relativePath>../com.mycompany.build</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>commons-math</groupId>
<artifactId>commons-math</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
The problem is that your Require-Bundle statement is too general:
With Require-Bundle: org.apache.commons.math;bundle-version="1.2.0" you actually specify that you need the math bundle in version 1.2.0 or any later version.
You should specify that you only want 1.2.0 or compatible versions. This can be done with Require-Bundle: org.apache.commons.math;bundle-version="[1.2.0,2.0.0)". This statement prevents that your bundle will be wired against the (apparently incompatible) 2.1 version of the math bundle at runtime (which is also important!), and it will probably also fix your build problem.
Tycho may still resolve against a higher 1.x version of the math bundle for building, if such a version is present in the target platform (i.e. in your case any of the configured p2 repository or amongst the POM dependencies). If this is the case, but you want to enforce that the 1.2 version is used in the build, you need to control the content of your target platform. (The Maven <dependencyManagement> is not enough, because it doesn't have an effect on the p2 repositories you configured.) You can do this by specifying filters in Tycho's target platform configuration:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<filters>
<filter>
<type>eclipse-plugin</type>
<id>org.apache.commons.math</id>
<restrictTo>
<version>1.2.0</version>
</restrictTo>
</filter>
</filters>
</configuration>
</plugin>
Related
I am looking to add a dependency to my pom.xml file
The dependency is a library allowing to manipulate Bluetooth Low Energy devices. Here is the link : TinyB
Here is also the github of the library : intel-iot-devkit/tinyb
When I copy and paste the snippet code to add the dependency, I get the following error after Maven tries to resolve the dependencies :
Could not find artifact intel-iot-devkit:tinyb:pom:0.5.1 in central (https://repo.maven.apache.org/maven2)
Could this be because the artifact is located in the OpenHab repository ? Then if this may cause the problem, how to solve it ?
Here is a copy of my pom.xml file :
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.HAcare</groupId>
<artifactId>HAcare_Connector</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>15.0.1</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>15.0.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/intel-iot-devkit/tinyb -->
<dependency>
<groupId>intel-iot-devkit</groupId>
<artifactId>tinyb</artifactId>
<version>0.5.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.6</version>
<executions>
<execution>
<!-- Default configuration for running -->
<!-- Usage: mvn clean javafx:run -->
<id>default-cli</id>
<configuration>
<mainClass>org.HAcare.App</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
And here is the code snippet I added to pom.xml :
<dependency>
<groupId>intel-iot-devkit</groupId>
<artifactId>tinyb</artifactId>
<version>0.5.1</version>
</dependency>
There is a second repository where it is possible to use this library by adding a dependency to the pom.xml file. Indeed it seems that the libraries are stored on the repository of openHAB.
To proceed you must first :
Add a repositories section in the pom.xml file
Here is a snippet code:
<repositories>
<repository>
<id>openHAB</id>
<name>openHabTinyB</name>
<url>https://openhab.jfrog.io/openhab/libs-release/</url>
</repository>
</repositories>
You have to add the following dependency:
Here is a snippet code:
<!-- https://mvnrepository.com/artifact/org.openhab.osgiify/intel-iot-devkit.tinyb -->
<dependency>
<groupId>org.openhab.osgiify</groupId>
<artifactId>intel-iot-devkit.tinyb</artifactId>
<version>0.5.1</version>
</dependency>
We have a utility library that has improved over the time. Now there is this idea to also deploy this library to another repository. However, due to some constraints there we need to change the groupId during that (the content of the JAR shouldn't change).
The current pom.xml looks like this:
<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>com.sjngm.common</groupId>
<artifactId>common-lib</artifactId>
<version>1.0.5-SNAPSHOT</version>
<packaging>jar</packaging>
<distributionManagement>
<repository>
<id>ta</id>
<url>http://archiva.local/archiva/repository/ta/</url>
</repository>
<snapshotRepository>
<id>archiva.snapshots</id>
<url>http://archiva.local/archiva/repository/snapshots/</url>
</snapshotRepository>
</distributionManagement>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.5.4.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- plenty of that -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<!-- ... -->
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<!-- ... -->
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<!-- ... -->
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<!-- ... -->
</plugin>
</plugins>
</build>
</project>
The new groupId could be something like com.sjngmaway.common.
I noticed relocation, but I don't understand how I can use it for my task:
That seems to be a one-time thing, but we'll use this in parallel.
Can I put this in the same pom.xml? With profiles or something? At least the <distributionManagement> is different.
If that should be another pom.xml should I add a <dependency> there? Or can I refer to or import my current pom.xml?
Or is this all just misleading and I need some other approach?
How do I proceed?
Since I'm not the Maven-genius it would be nice if you could use my snippet from above rather than just explain it in words what I can do :) Thanks!
You can add the deploy:deploy-file goal to the deploy phase of your Maven Build http://maven.apache.org/plugins/maven-deploy-plugin/deploy-file-mojo.html
It is meant to make additional deployments in addition to the standard one.
I am developing one maven plugin which will be used to override default maven lifecycle.To resolve dependencies (eclipse and other) , I want to use tycho. So I cofigured maven project to convert it into eclipse-plugin-project.
Heres my 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>
<groupId>com.test.maven.plugin</groupId>
<artifactId>test-maven-plugin</artifactId>
<version>0.0.1</version>
<packaging>eclipse-plugin</packaging>
<name>test-maven-plugin</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<!-- add Mars repository to resolve dependencies -->
<repository>
<id>Mars</id>
<layout>p2</layout>
<url>http://download.eclipse.org/releases/mars/</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<!-- enable tycho build extension -->
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>0.23.0</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>
Now , as my packaging type is 'eclipse-plugin' , it is not generating plugin.xml file while installing project (mvn install). If I do the packaging type as 'maven-plugin' , it generates plugin.xml , but it does resolve dependencies using tycho.
Any thoughts for combining both?
I want to do the simplest Maven build with Tycho, but couldn't get it working. My project has only one pom.xml file, there are no parent or sibling POMs.
When I run mvn clean install I get lots of compilation errors which entries such as:
[ERROR] /dir/file.java:[8,33] package org.eclipse.core.commands does not exist
This is how my POM file looks like:
<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>com.mygroup</groupId>
<artifactId>myartifact</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>myartifact</name>
<description>Maven stuff</description>
<properties>
<tycho.version>0.20.0</tycho.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<luna-repo.url>http://download.eclipse.org/releases/luna</luna-repo.url>
<kepler-repo.url>http://download.eclipse.org/releases/kepler</kepler-repo.url>
</properties>
<repositories>
<repository>
<id>luna</id>
<url>${luna-repo.url}</url>
<layout>p2</layout>
</repository>
<repository>
<id>kepler</id>
<url>${kepler-repo.url}</url>
<layout>p2</layout>
</repository>
</repositories>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<pde>true</pde>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho.version}</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho.version}</version>
<configuration>
<environments>
<environment>
<os>linux</os>
<ws>gtk</ws>
<arch>x86</arch>
</environment>
<environment>
<os>linux</os>
<ws>gtk</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86</arch>
</environment>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>macosx</os>
<ws>cocoa</ws>
<arch>x86_64</arch>
</environment>
</environments>
</configuration>
</plugin>
</plugins>
</build>
</project>
This is how my manifest file looks like:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: pluginname
Bundle-SymbolicName: pluginname;singleton:=true
Bundle-Version: 1.0.0.SNAPSHOT
Bundle-Activator: com.mygroup.pluginname.ui.Activator
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.core.resources,
org.eclipse.ui.ide,
org.apache.commons.io;bundle-version="2.0.1"
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
I don't really know what I am missing here.
Your project doesn't specify a packaging type, so it defaults to jar. For jar projects, Tycho doesn't do anything, so all your otherwise correct configuration has no effect.
To activate Tycho, you need to add the configuration
<packaging>eclipse-plugin</packaging>
Then, Tycho will resolve the build class path according to the dependencies you have declared in the OSGi manifest.
Note that Tycho doesn't use the maven-compiler-plugin, so after activating Tycho this configuration has no effect. Also, I have no experience with the maven-eclipse-plugin in combination with Tycho. Instead of that plugin, I would recommend to use M2Eclipse for importing the project in Eclipse.
You need to add a dependency for the set of libraries you are using in your source code.
Maven isn't being told to obtain or manage them, so Eclipse doesn't know they exist. When you are trying to import them in your source code and compile, it's generating the error you are seeing.
Ex:
<dependencies>
...
<dependency>
<groupId>org.eclipse.core</groupId>
<artifactId>commands</artifactId>
<version>3.3.0-I20070605-0010</version>
</dependency>
...
</dependencies>
See the eclipse repository for the info required for other libraries.
EDIT: To fix your SWT compilation error, follow the steps shown on the SWT-repo project's webpage. An example for the win32 Intel x86/x64 architecture:
<dependency>
<groupId>org.eclipse.swt</groupId>
<artifactId>org.eclipse.swt.win32.win32.x86_64</artifactId>
<version>4.4</version>
</dependency>
Change yours based on your platform.
I want to generate a er-diagram from a database integrated in the maven lifecycle.
SchemaSpy generates the er-diagram and with the maven-schemaspy-plugin it should be possible to integrate this in the lifecyle-process.
(If anyone has a better idea for this please let me know)
I tried it with the following simple pom.xml (which only should generate the er-diagram); but the plugin doesn't start; it couldn't even be downloaded:
<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.schemaspy</groupId>
<artifactId>SchemaSpyGenerateDB_02</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>SchemaSpyGenerateDB_02</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>maven-plugins</groupId>
<artifactId>maven-schemaspy-plugin</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>maven-plugins</groupId>
<artifactId>maven-schemaspy-plugin</artifactId>
<version>1.0</version>
<type>plugin</type>
</dependency>
</dependencies>
<!-- To use the report goals in your POM or parent POM -->
<reporting>
<plugins>
<plugin>
<groupId>maven-plugins</groupId>
<artifactId>maven-schemaspy-plugin</artifactId>
<version>1.1</version>
<configuration>
<databaseType>derby</databaseType>
<database>JPACertifiaction_Relationship</database>
<host>localhost</host>
<port>1527</port>
<user>user</user>
<password>password</password>
</configuration>
</plugin>
</plugins>
</reporting>
</project>
The command
mvn site:site
causes the message
The POM for maven-plugins:maven-schemaspy-plugin:jar:1.0 is missing, no dependency information available
The POM for maven-plugins:maven-schemaspy-plugin:plugin:1.0 is missing, no dependency information available
I've also tried it with the following settings with no success:
<dependency>
<groupId>com.wakaleo.schemaspy</groupId>
<artifactId>maven-schemaspy-plugin</artifactId>
<version>5.0.1</version>
</dependency>
....
<reporting>
<plugins>
<plugin>
<groupId>com.wakaleo.schemaspy</groupId>
<artifactId>maven-schemaspy-plugin</artifactId>
<version>5.0.1</version>
....
<repository>
<id>Wakaleo Repository</id>
<url>http://maven.wakaleo.com/mojo/maven-schemaspy-plugin/</url>
</repository>
What me also confuses is that there are different reposititories with different versions 1.0 / 5.0.1 so what is really the official one ?
You don't need the entries
<dependencies>
<dependency>
<groupId>maven-plugins</groupId>
<artifactId>maven-schemaspy-plugin</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>maven-plugins</groupId>
<artifactId>maven-schemaspy-plugin</artifactId>
<version>1.0</version>
<type>plugin</type>
</dependency>
</dependencies>
delete them. When you define a plugin (plugin section later) it gots downloaded by maven automatically. Your error message says that 1.0 is missing, but your plugin is 1.1, so it doesn'T fit to your dependencies anyway.
The maven-schemaspy-plugin and the com.wakaleo.schemaspy plugin are different plugins from different authors. None of them is the "official schemaspy" maven plugin. I was only able to solve it with the wakaleo plugin (with maven 3). The other plugin seams not to be available any more.
With Maven 3 the site generation changed, see site generation in Maven 3. As mentioned in this blog entry you have to include the plugin in this way (note that the versioning has changed):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.1</version>
<configuration>
<reportPlugins>
<plugin>
<groupId>com.wakaleo.schemaspy</groupId>
<artifactId>maven-schemaspy-plugin</artifactId>
<version>1.0.4</version>
<configuration>
<databaseType>derby</databaseType>
<database>JPACertifiaction_Relationship</database>
<host>localhost</host>
<port>1527</port>
<user>user</user>
<password>password</password>
</configuration>
</plugin>
</reportPlugins>
</configuration>
</plugin>
</plugins>
</build>
and you need the link to the repository:
<pluginRepositories>
<pluginRepository>
<id>Wakaleo Repository</id>
<url>http://www.wakaleo.com/maven/repos/</url>
</pluginRepository>
</pluginRepositories>
Then the plugin starts. The rest is up to you :-)