I want to use the plugin "Dockerfile Maven" to build docker images from my project. When I add this plugin into my pom.xml
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>${dockerfile-maven-version}</version>
<executions>
<execution>
<id>default</id>
<goals>
<goal>build</goal>
<goal>push</goal>
</goals>
</execution>
</executions>
<configuration>
<repository>spotify/foobar</repository>
<tag>${project.version}</tag>
<buildArgs>
<JAR_FILE>${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
</configuration>
</plugin>
I am getting an error on the first line of my pom:
Failure to find com.spotify:dockerfile-maven-plugin:jar:${dockerfile-maven-version} in https://
repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the
update interval of central has elapsed or updates are forced
Do I need to configure something? I can't find anyone with the same problem. This is my pom.xml configuration:
<?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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>de.leuphana</groupId>
<artifactId>ArticleMicroService</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>ArticleMicroService</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
<spring-cloud.version>Greenwich.SR1</spring-cloud.version>
</properties>
Where did you define the value for variabledockerfile-maven-version?
You should add it to the properties
<properties>
<java.version>11</java.version>
<spring-cloud.version>Greenwich.SR1</spring-cloud.version>
<dockerfile-maven-version>1.4.10</dockerfile-maven-version>
</properties>
Looks like you need to define dockerfile-maven-version in the section of your POM
Add to properties:
<dockerfile-maven-version>1.4.10</dockerfile-maven-version>
Related
I'm trying to use maven friendly ci for my multi-module project. My project has three levels of parent child hierarchy, i.e., my parent project has few child projects and those child projects has many other child projects within them.
I have added a sample of my pom files below. My parent pom has a flatten plugin as well, everything works fine in my local machine. But when I build it from Jenkins, it doesn't work. And I get the below error
Error
[ERROR] [ERROR] Some problems were encountered while processing the
POMs: [FATAL] Non-resolvable parent POM for
com.faskan:child-module:[unknown-version]:
Could not transfer artifact
com.faskan:parent-module:pom:${revision} from/to nexus
Parent project's pom.xml
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
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>org.faskan</groupId>
<artifactId>global-parent-dependency</artifactId>
<version>1.1.0</version>
</parent>
<groupId>org.faskan</groupId>
<artifactId>parent-module</artifactId>
<version>${revision}</version>
<packaging>pom</packaging>
<name>project parent pom</name>
<properties>
<revision>21.15.0-SNAPSHOT</revision>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>1.2.2</version>
<configuration>
</configuration>
<executions>
<!-- enable flattening -->
<execution>
<id>flatten</id>
<phase>process-resources</phase>
<goals>
<goal>flatten</goal>
</goals>
</execution>
<!-- ensure proper cleanup -->
<execution>
<id>flatten.clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
...
</project>
Child project's pom.xml
<?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>
<artifactId>child-module</artifactId>
<parent>
<groupId>org.faskan</groupId>
<artifactId>parent-module</artifactId>
<version>${revision}</version>
</parent>
<name>child admin</name>
<packaging>jar</packaging>
..
</project>
Child of child project (grand child)
<?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>
<artifactId>grand-child-module</artifactId>
<packaging>jar</packaging>
<name>child of child module</name>
<parent>
<groupId>org.faskan</groupId>
<artifactId>child-module</artifactId>
<version>${revision}</version>
</parent>
..
</project>
I found a similar question How do you get maven child projects to build in Jenkins when using CI Friendly versions?. Not sure if mine is the same because I don't get any parse failure errors.
The following configuration is missing in your parent pom.xml for the flatten plugin:
<configuration>
<updatePomFile>true</updatePomFile>
<flattenMode>resolveCiFriendliesOnly</flattenMode>
</configuration>
I believe you have to add this configuration for ci-friendly projects, as explained here.
In
<parent>
<groupId>org.faskan</groupId>
<artifactId>parent-module</artifactId>
<version>${revision}</version>
</parent>
you can't have ${revision} for version. Maven don't know where to get it. You need to use actual version.
PS: I don't know how you manage to build it locally.
I have encountered a strange bug while trying to deploy new release builds to my company's JFrog.io (fka: ArtifactoryOnline.com) repository. The project I'm working on has multiple maven modules, all under a single parent. When I upload the JAR files that maven builds to JFrog, the generated POM file is being populated with the incorrect parent artifactId.
I spent a great deal of time and could not find any problems with my company's codebase for the project, so I decided if I could reproduce the error from scratch. Thus I made this throwaway project to demonstrate the bug. For those uninterested in downloading the full project, here are the relevant POM files:
The parent POM, "blueberry":
<?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>org.nbyrd</groupId>
<artifactId>blueberry</artifactId>
<packaging>pom</packaging>
<version>1.0</version>
<modules>
<module>blueberryjam</module>
<module>berries</module>
</modules>
</project>
Dependant POM 1: "berries":
<?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">
<parent>
<artifactId>blueberry</artifactId>
<groupId>org.nbyrd</groupId>
<version>1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>berries</artifactId>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Dependant POM 2, "berry-jam":
<?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">
<parent>
<artifactId>blueberry</artifactId>
<groupId>org.nbyrd</groupId>
<version>1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>blueberry-jam</artifactId>
<dependencies>
<dependency>
<groupId>org.nbyrd</groupId>
<artifactId>berries</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</project>
(For what it's worth, all of these POM files were generated in their entirety by JetBrains IntelliJ.)
Pretty straight forward at this point: I have two Maven modules--"berries" and "berry-jam"--that are housed under a central parent module, "blueberry". berry-jam uses berries as a dependency, although I'm not sure if that's relevant to the problem.
When I build the project, I get two JAR files: berries-1.0.jar and berry-jam-1.0.jar. This is as expected. At this point, I would upload these artifacts to Artifactory so that other projects may reference them. And this is where the trouble starts.
When I upload berries-1.0.jar, Artifactory generates the following POM file:
<?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">
<parent>
<artifactId>berries</artifactId>
<groupId>org.nbyrd</groupId>
<version>1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>berries</artifactId>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
As you can see, the generated POM defines the parent artifactId as "berries", which is wrong.
The same problem occurs when I upload berry-jam-1.0.jar:
<?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">
<parent>
<artifactId>blueberry-jam</artifactId>
<groupId>org.nbyrd</groupId>
<version>1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>blueberry-jam</artifactId>
<dependencies>
<dependency>
<groupId>org.nbyrd</groupId>
<artifactId>berries</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</project>
In both cases, I would expect the parentId to be "blueberry", as it is explicitly stated in both of the child-modules' POM files. These incorrect artifactIds make it impossible to use these libraries. If a third-party application attempts to use these libraries, maven will produce the following warning when downloading dependencies and the build will fail:
[WARNING] The POM for org.nbyrd:berries:jar:1.0 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
This functionality used to work correctly in the past when uploading to Artifactory, so I'm not sure if something has changed in how the tool works or if I have simply done something wrong. Any thoughts?
When you use mvn deploy maven deploys the pom.xmlfile as separated artifact. But when you uploads the jar file with artifactory's web ui and asks artifactory to generate the pom file, I guess it generates it from the data presents in the jar. So the artifactory isn't aware about existing of a parent project.
I had similar problem and my guess was that artifactory is trying to fix pom by changing first artifactId value it can find. Not seeing that it's inside parent node.
So I moved parent node below artifactId/version and that worked for me.
<?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>
<artifactId>berries</artifactId>
<version>2.0</version>
<parent>
<artifactId>berries</artifactId>
<groupId>org.nbyrd</groupId>
<version>1.0</version>
</parent>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
I have an Eclipse Maven Project (parent) that hosts three Maven MODULES (it's children). Only the child MODULES have code under "src/main/java/..." (i.e. the PARENT is just a stub place holder for the children).
Each MODULE is independent of one another... I just set it up that way to reduce clutter. =:)
Now the project structure didn't start out this way. Initially it was just one big PARENT and no child MODULES; and everything worked fine. But then I reorganized things within Eclipse (again to reduce clutter) using various moves/refactors, and things stopped working.
The Problem: My source code can't find imported classes now, so my dependency resolution became problematic somewhere. And the problem isn't just seen in Eclipse, but also when I run, say, 'mvn clean install' from the CLI. So I suspect something is wrong with the set of POM files that resulted from my moves/refactors.
Here they are (the PARENT and one CHILD). Am I missing something, or is something incorrect? Maybe I should check something Eclipse, too?
Note that I embedded a couple of little in-line questions inside the POM files below. :)
The PARENT pom.xml file:
<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>someName</name>
<packaging>pom</packaging>
<groupId>someParentGroupId</groupId>
<artifactId>someParentArtifactId</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<jdk.version>1.7</jdk.version>
<example-core.version>0.9.3</example-core.version>
<!-- Intended to be used by some Child/Module.
I hope PARENT/CHILD POM inheritance works that way? -->
</properties>
<dependencies>
<!-- Dependencies are all in the Children/Modules -->
</dependencies>
<!-- ################### BUILD SETTINGS BEGIN ##################### -->
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin> <!-- Used to create an UBER/FAT-JAR. -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<finalName>uber-${project.artifactId}-${project.version}</finalName>
</configuration>
</plugin>
</plugins>
</build>
<!-- ################### BUILD SETTINGS END ####################### -->
<modules>
<module>childModule1</module>
<module>childModule2</module>
<module>chileModule3</module>
</modules>
</project>
Example CHILD pom.xml file:
<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>someParentGroupId</groupId>
<artifactId>someParentArtifactId</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>someChildArtifactId</artifactId>
<!-- I noticed this missing in the Children/Module POM. Is that okay?
<name>
</name>
-->
<dependencies>
<dependency>
<groupId>org.example.somgGroupId</groupId>
<artifactId>example-core</artifactId>
<version>${example-core.version}</version>
</dependency>
</dependencies>
</project>
Again, the problem seems simple. I can't resolve imports (so, naturally, my Classes have import-ralated errors).
Thank you in advance!
name is not a mandatory attribute in pom.xml.
I assume someChildArtifactId is given as an example. If not, the same artifact id should be used in the parent pom.
The goal was to export existing android eclipse project to maven type. To do this, it was required to download .m2 plugin. Right click on project and Configure-->Convert To Maven Project, what opened the window "Create new POM" with:
The question is what should be selected in packaging type while there is only jar/pom/war . I believe there should be "apklib" but when we type it there after pom.xml generation:
<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>X.0.0</modelVersion>
<groupId>Name</groupId>
<artifactId>Artifact</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>apklib</packaging>
</project>
Eclipse response with :
Project build error: Unknown packaging: apklib
Regards
maven has no built-in packaging "apklib", which is probably why youre getting the error.
you havent specified which maven plugin youre using to build android artifacts, but assumming its this one your pom needs to look like this (taken from their samples)
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>com.simpligility.android</groupId>
<artifactId>helloflashlight</artifactId>
<version>1.0.0</version>
<packaging>apk</packaging>
<name>HelloFlashlight</name>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<finalName>${project.artifactId}</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.8.2</version>
<extensions>true</extensions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<configuration>
<sdk>
<!-- platform as api level (api level 16 = platform 4.1)-->
<platform>16</platform>
</sdk>
</configuration>
</plugin>
</plugins>
</build>
</project>
I have one parent project with submodule, I have already read explanation about links, I try to run
mvn clean site
And open Child link from index.html. I also try to run site:run goal from maven-site-plugin and visit:
http://localhost:8080/
So relative link "about" apge from maven site do not work. What is wrong? May be I misunderstood with site working?
See parent and child pom.xml below
Parent pom.xml
<?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>MavenSiteGeneration</groupId>
<artifactId>MavenSiteGeneration</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>Child</module>
</modules>
<description>Main project</description>
<!--<url>main-url</url>-->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.3</version>
<!--<configuration>
<port>9000</port>
<tempWebappDirectory>${basedir}/target/site/tempdir</tempWebappDirectory>
</configuration>-->
</plugin>
</plugins>
</build>
<distributionManagement>
<site>
<id>someid</id>
<url>http://bash.org</url>
</site>
</distributionManagement>
<reporting>
<plugins>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<configuration>
<dependencyLocationsEnabled>false</dependencyLocationsEnabled>
</configuration>
</plugin>
</plugins>
</reporting>
</project>
Child pom.xml
<?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">
<parent>
<artifactId>MavenSiteGeneration</artifactId>
<groupId>MavenSiteGeneration</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<description>Child project</description>
<artifactId>Child</artifactId>
<!--<url>/child</url>-->
<!--<distributionManagement>
<site>
<id>asd</id>
<name>name</name>
<url>/child1112</url>
</site>
</distributionManagement>-->
</project>
Could anybody tell me what is wrong?
P.S. You can see some tag in comments, I have already tried to comment/uncmment. Relative link do not work.
You need to run mvn site:stage first to get a directory that includes the sites of the module and its submodule (by default in target/staging/). This is also explained in the FAQ of the maven-site-plugin.
To run this goal, you need to provide the information in <distributionManagement><site>, as you have in the files posted above.
Running mvn site:run will however still not work, that goal can only be used for single modules.