Unresolveable build extension: Plugin org.eclipse.tycho:tycho-maven - maven

I am using 'Tycho'(Maven) for eclipse plugin project build .
I am getting the error :
Unresolveable build extension: Plugin org.eclipse.tycho:tycho-maven-plugin:0.22.0 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.eclipse.tycho:tycho-maven-plugin:jar:0.22.0: Could not transfer artifact org.eclipse.tycho:tycho-maven-plugin:pom:0.22.0 from/to central (https://repo.maven.apache.org/maven2): connect timed out -> [Help 2]
POM.xml 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>tycho_example</groupId>
<artifactId>com.codeandme.tycho.plugin</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<tycho.version>0.22.0</tycho.version>
</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>
<!-- enable tycho build extension -->
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho.version}</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>

I am sure your problem is solved. However, for others who have the same error,the solution is :
Include the tag <pluginManagement> in parent pom.xml file. <pluginManagement> is only a way to share the same plugin configuration across all your project modules.Here is sample parent pom.xml file
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>${tycho-groupid}</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho-version}</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>${tycho-groupid}</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<resolver>p2</resolver>
<environments>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86</arch>
</environment>
<environment>
<os>macosx</os>
<ws>cocoa</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>linux</os>
<ws>gtk</ws>
<arch>x86_64</arch>
</environment>
</environments>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

This can't be solved by adding
<PluginManagement>
...
</PluginManagement>
It's simply because the eclipse m2e connector can't download these plugins from a repo.
Open your Maven Console and see if it prints something after you saved your pom.xml
it probably will tell you, that it couldn't acces the repo or no maven settings.xml is assigned to the m2e connector.
Find the full Solution here:
Maven: unresolvable build extension

Related

Plugin.xml file is not found /generated for eclipse plugin project

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?

Classes from required Eclipse plugins are missing when building with Maven

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.

No SCM URL was provided to perform the release from

I am trying to use maven release plugin and after that automate this using nexus.
Here is my 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ozge.net</groupId>
<artifactId>com.ozge.net</artifactId>
<version>1.1- snapshot</version>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<tagBase>svn://local/exekuce/com.ozge.net</tagBase>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<scm>
<tag>HEAD</tag>
<connection>scm:svn:svn://[svnusername]:[svn password]#local/exekuce/com.ozge.net</connection>
<developerConnection>scm:svn:svn://[svnusername]:[svn password]#local/exekuce/com.ozge.net</developerConnection>
<url>scm:svn:svn://[svnusername]:[svn password]#local/exekuce/com.ozge.net</url>
</scm>
<distributionManagement>
<repository>
<id>OzgeRelease</id>
<url>http://localhost:8081/nexus/content/repositories/OzgeRelease</url>
</repository>
</distributionManagement>
</project>
after I ran the command mvn release:perform on command prompt
it says
No SCM URL was provided to perform the release from
I believe I provided.
Anybody here tried to maven-subversion-nexus-hudson for automating builds?
Try to perform release:clean first.
mvn release:clean
Then try again.

Maven/Tycho takes the wrong bundle-version

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>

Can I use property file in maven pom.xml for flyway configuration

<plugin>
<groupId>com.googlecode.flyway</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>1.7</version>
<configuration>
<driver>com.mysql.jdbc.Driver</driver>
<url>jdbc:mysql://127.0.0.1:3306/db_abc</url>
<user>db_user</user>
<sqlMigrationPrefix>V</sqlMigrationPrefix>
</configuration>
</plugin>
I don't want to mention driver, url and user here. I already have a abc.property on src/main/resources. How can use that file here?
Have a look at the properties-maven-plugin. It allows you to read properties from a file to then use them in your pom.
Add the following plugin defintion:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>src/main/resources/abc.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
If abc.properties contains:
jdbc.driver = com.mysql.jdbc.Driver
jdbc.url = jdbc:mysql://127.0.0.1:3306/db_ab
jdbc.user = db_user
You can then use the properties as follows:
<!-- language: xml -->
<driver>${jdbc.driver}</driver>
<url>${jdbc.url}</url>
<user>${jdbc.user}</user>
in version 3.0 you have to use configFile like :
<configFile>src/main/resources/db/config/flyway.properties</configFile>
In my opinion, the best and the most flexible approach is to:
a) use profiles and filtering - keep all configuration properties for specific profile (development, test, etc.), e.g. in development.properties:
jdbc.url=jdbc:mysql://127.0.0.1:3306/testdb?useSSL=false
jdbc.user=testuser
jdbc.password=testpass
jdbc.driver=com.mysql.jdbc.Driver
Then, in your pom file (possibly in root pom) define a profile, e.g:
...
<profiles>
<profile>
<id>development</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<filters>
<filter>../filters/development.properties</filter>
</filters>
</build>
...
here you can see that development profile is activated by default. If you want to use another profile set it with
-p [profile-id]
b) set flyway.properties with filtered values - your flyway.properties should sit e.g. in src/main/resources and the values should be used from the parameters defined in the profile properties file:
flyway.driver = ${jdbc.driver}
flyway.url = ${jdbc.url}
flyway.user = ${jdbc.user}
flyway.password = ${jdbc.password}
c) reference flyway.properties from build directory - use simple plugin configuration (I really like clean poms):
...
<build>
<resources>
<!-- This way we instruct maven to inject values from filters into the resources -->
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<configuration>
<configFile>${project.build.directory}/classes/flyway.properties</configFile>
<locations>
<location>classpath:migration/mysql</location>
</locations>
</configuration>
</plugin>
</plugins>
</build>
...
Don't forget to enable filtering in resources as shown in many examples here. My flyway-maven-plugin version is 3.2.1 and it is managed in pluginManagement in parent pom, therefore version is not visible here. I also use explicit sql scripts with locations configuration.
There are several ways to deal with this. One approach is to do it the other way around.
That means that the properties to use are saved as properties inside the pom.xml and that the file abc.properties only has placeholders that will be filled in at build time.
I will show you how it can be configured.
This is what the pom.xml will look 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.stackoverflow</groupId>
<artifactId>Q12619446</artifactId>
<version>1.0-SNAPSHOT</version>
<name>${project.artifactId}-${project.version}</name>
<properties>
<jdbc.driver>com.mysql.jdbc.Driver</jdbc.driver>
<jdbc.url>jdbc:mysql://127.0.0.1:3306/db_abc</jdbc.url>
<jdbc.user>db_user</jdbc.user>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.googlecode.flyway</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>1.7</version>
<configuration>
<driver>${jdbc.driver}</driver>
<url>${jdbc.url}</url>
<user>${jdbc.user}</user>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
</project>
And this will be your src/main/resources/abc.properties (use the key names of your choice):
jdbcDriver = ${jdbc.driver}
jdbcUrl = ${jdbc.url}
jdbcUser = ${jdbc.user}
After the build the target/classes/abc.properties will look like this:
jdbcDriver = com.mysql.jdbc.Driver
jdbcUrl = jdbc:mysql://127.0.0.1:3306/db_abc
jdbcUser = db_user
As stated this is only one of several ways to do it. It might not suit your exact needs but it could.
Garry,
there is one more way not to place database connection parameters to your pom-file. In particular, one can add them to settings.xml file in .m2 sub-folder of the user's folder [1]. The benefit is that the db paraneters do not live in the project folder and are not transmitted to the repository, so each developer may use her own settings.
The example of the settings file could look like the example below.
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<profiles>
<profile>
<id>fw</id>
<properties>
<flyway.url>jdbc:oracle:thin:#//localhost:1521/xe</flyway.url>
<flyway.user>Your login</flyway.user>
<flyway.password>Your password</flyway.password>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>fw</activeProfile>
</activeProfiles>
</settings>
After that your can modify your pom-file according to the following snippet.
<?xml version="1.0"?>
<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>
...
<dependencies>
...
</dependencies>
<profiles>
<profile>
<id>fw</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>3.2.1</version>
<configuration>
<url>${flyway.url}</url>
<user>${flyway.user}</user>
<password>${flyway.password}</password>
</configuration>
<dependencies>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0.1.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
In the example above Oracle's driver is used, but you can replace it with the required one.
To print current settings execute the following.
mvn help:effective-settings
In version 3.x you have configFile option
By default- flyway.properties in the same directory as the project POM.
You can add external property file in configuration section of pom or can be pass when running maven goal example-
command line-
mvn <goal> -Dflyway.configFile=myConfig.properties
Pom file-
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>3.2.1</version>
<configuration>
<driver/>
<url/>
<user/>
<password/>
<baselineVersion>1.0</baselineVersion>
<baselineDescription>Base Migration</baselineDescription>
<skip>false</skip>
<configFile>myConfig.properties</configFile>
</configuration>
</plugin>

Resources