Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>maven-model-helper</artifactId>
<version>37</version>
<version>40</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
Expand Down
75 changes: 75 additions & 0 deletions src/it/lock/in-profile-mode-remote-parent/expected-pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.foo</groupId>
<artifactId>foo-parent</artifactId>
<version>1.0.0</version>
<relativePath/>
</parent>
<artifactId>bar</artifactId>
<version>999-SNAPSHOT</version>
<name>Bar</name>
<properties>
<compiler-plugin.version>3.12.1</compiler-plugin.version>
<maven.compiler.release>17</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.mvnpm</groupId>
<artifactId>lit</artifactId>
<version>3.1.2</version>
</dependency>
<dependency>
<groupId>org.mvnpm</groupId>
<artifactId>lit-element</artifactId>
<version>4.0.4</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>locker</id>
<activation>
<property>
<name>!unlocked</name>
</property>
</activation>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.mvnpm.at.lit-labs</groupId>
<artifactId>ssr-dom-shim</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>org.mvnpm.at.lit</groupId>
<artifactId>reactive-element</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>org.mvnpm.at.types</groupId>
<artifactId>trusted-types</artifactId>
<version>2.0.7</version>
</dependency>
<dependency>
<groupId>org.mvnpm</groupId>
<artifactId>lit-element</artifactId>
<version>4.0.4</version>
</dependency>
<dependency>
<groupId>org.mvnpm</groupId>
<artifactId>lit-html</artifactId>
<version>3.3.1</version>
</dependency>
<dependency>
<groupId>org.mvnpm</groupId>
<artifactId>lit</artifactId>
<version>3.1.2</version>
</dependency>
</dependencies>
</dependencyManagement>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:lock -Dlocker.mode=IN_PROFILE
31 changes: 31 additions & 0 deletions src/it/lock/in-profile-mode-remote-parent/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.foo</groupId>
<artifactId>foo-parent</artifactId>
<version>1.0.0</version>
<relativePath/>
</parent>
<artifactId>bar</artifactId>
<version>999-SNAPSHOT</version>
<name>Bar</name>
<properties>
<compiler-plugin.version>3.12.1</compiler-plugin.version>
<maven.compiler.release>17</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.mvnpm</groupId>
<artifactId>lit</artifactId>
<version>3.1.2</version>
</dependency>
<dependency>
<groupId>org.mvnpm</groupId>
<artifactId>lit-element</artifactId>
<version>4.0.4</version>
</dependency>
</dependencies>
</project>
22 changes: 22 additions & 0 deletions src/it/lock/in-profile-mode-remote-parent/postbuild.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import static org.assertj.core.api.Assertions.assertThat

import java.nio.file.Files

import org.xmlunit.assertj3.XmlAssert

import io.mvnpm.maven.locker.XmlUnitTestSupport

buildLog = Files.readAllLines(basedir.toPath().resolve("build.log"))
assertThat(buildLog)
.contains("[INFO] Adding 'locker' profile with 6 locked dependencies to the pom.xml...")

lockedPom = basedir.toPath().resolve("pom.xml")
expectedPom = basedir.toPath().resolve("expected-pom.xml")

XmlAssert.assertThat(Files.readString(lockedPom))
.and(Files.readString(expectedPom))
.withNodeFilter(XmlUnitTestSupport.ignoreMvnpmDependencyVersions())
.ignoreWhitespace()
.areIdentical()

true
1 change: 1 addition & 0 deletions src/it/setup/remote-parent/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoker.goals = install
9 changes: 9 additions & 0 deletions src/it/setup/remote-parent/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.foo</groupId>
<artifactId>foo-parent</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<name>Foo Parent</name>
</project>
2 changes: 1 addition & 1 deletion src/main/java/io/mvnpm/maven/locker/mojos/LockMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public void execute() throws MojoExecutionException {
}

LockerPomFileAccessor lockFile = lockFile();
final ParentPom parentPom = getParentPom(lockFile.file);
final Artifacts lockedDependencies = projectDependencies().filter(filters);
final boolean lockFileExists = lockFile.exists();
final Model model = project.getModel();
Expand All @@ -74,6 +73,7 @@ public void execute() throws MojoExecutionException {
if (lockerBomModeEnabled) {
getLog().info(String.format(ROOT, "%s %s", lockFileExists ? "Updating" : "Creating", lockFile.absolutePath()));
final LockerPom lockerPom = DefaultLockerPom.from(lockFile, pomMinimums(), getLog());
final ParentPom parentPom = getParentPom(lockFile.file);
lockerPom.write(parentPom, lockedDependencies);
}

Expand Down