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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2025, 2025 Hannes Wellmann and others.
* Copyright (c) 2025, 2026 Hannes Wellmann and others.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -133,7 +133,7 @@ public void modifyRepositoryMetadata(ModifiedRepositoryDescriptor repository, St
modifyOutputRepository(manager.getMetadataRepository(location.getURL(), location.getId()), outputLocation,
manager::mirrorMetadataRepository, r -> r.executeBatch(m -> modification.accept(r), null));
}
xzCompress(repository, outputLocation);
xzCompress(repository);
}

@FunctionalInterface
Expand All @@ -155,8 +155,9 @@ private <T, R extends IRepository<T>> void modifyOutputRepository(R repository,
}
}

private void xzCompress(ModifiedRepositoryDescriptor repository, Path outputLocation) throws IOException {
private void xzCompress(ModifiedRepositoryDescriptor repository) throws IOException {
if (repository.xzCompress()) {
Path outputLocation = resolveOutputLocation(repository);
XZCompressor xzCompressor = new XZCompressor();
xzCompressor.setPreserveOriginalFile(repository.keepNonXzIndexFiles());
xzCompressor.setRepoFolder(outputLocation.toAbsolutePath().toString());
Expand Down Expand Up @@ -210,7 +211,7 @@ public void modifyCompositeRepository(ModifiedRepositoryDescriptor repository, S
}, modification, CompositeMetadataRepository.PI_REPOSITORY_TYPE,
CompositeMetadataRepositoryFactory.CONTENT_FILENAME);
}
createP2Index(repository.outputLocation(), repository.isMetadata(), repository.isArtifact());
createP2Index(resolveOutputLocation(repository), repository.isMetadata(), repository.isArtifact());
}

private <T, M extends IRepositoryManager<T>, R extends ICompositeRepository<T>> void modifyOutputCompositeRepository(
Expand All @@ -234,15 +235,7 @@ private <T, M extends IRepositoryManager<T>, R extends ICompositeRepository<T>>
throw e;
}
}
Path outputLocation = descriptor.outputLocation();
if (outputLocation == null) {
try {
outputLocation = Path.of(repository.getURL());
} catch (Exception e) {
throw new IllegalStateException(
"Repository is not modifable and no output location is defined: " + repository.getURL(), e);
}
}
Path outputLocation = resolveOutputLocation(descriptor);

modification.accept(state);

Expand All @@ -254,6 +247,20 @@ private <T, M extends IRepositoryManager<T>, R extends ICompositeRepository<T>>
}
}

private static Path resolveOutputLocation(ModifiedRepositoryDescriptor descriptor) {
Path outputLocation = descriptor.outputLocation();
if (outputLocation == null) { // In-place edit
MavenRepositoryLocation repository = descriptor.repository();
try {
outputLocation = Path.of(repository.getURL());
} catch (Exception e) {
throw new IllegalStateException(
"Repository is not modifable and no output location is defined: " + repository.getURL(), e);
}
}
return outputLocation;
}

private static OutputStream createCompositeFileOutputStream(Path directory, String filename, boolean compress)
throws IOException {
Path file = directory.resolve(filename + CompositeArtifactRepository.XML_EXTENSION);
Expand Down
50 changes: 50 additions & 0 deletions tycho-its/projects/issue6251/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2026 Contributors to the Eclipse Foundation
This program and the accompanying materials
are made available under the terms of the Eclipse Public License 2.0
which accompanies this distribution, and is available at
https://www.eclipse.org/legal/epl-2.0/

SPDX-License-Identifier: EPL-2.0
-->
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>tycho-its-project</groupId>
<artifactId>issue6251</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>

<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-repository-plugin</artifactId>
<version>${tycho-version}</version>
<executions>
<execution>
<id>modify-in-place</id>
<phase>initialize</phase>
<goals>
<goal>modify-composite-repository</goal>
</goals>
<configuration>
<repository>
<id>t</id>
<url>${project.baseUri}repo/</url>
</repository>
<repositoryKind>metadata</repositoryKind>
<childrenToAdd>
<child>../child</child>
</childrenToAdd>
<validateChildren>false</validateChildren>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*******************************************************************************
* Copyright (c) 2026 Contributors to the Eclipse Foundation
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package org.eclipse.tycho.test.issue6251;

import static org.junit.jupiter.api.Assertions.assertTrue;

import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;

import org.apache.maven.it.Verifier;
import org.eclipse.tycho.test.AbstractTychoIntegrationTest;
import org.junit.jupiter.api.Test;

public class Issue6251Test extends AbstractTychoIntegrationTest {

@Test
public void modifyCompositeRepositoryInPlaceWritesP2Index() throws Exception {
Verifier verifier = getVerifier("issue6251");

verifier.executeGoals(List.of("initialize"));
verifier.verifyErrorFreeLog();

Path p2Index = Path.of(verifier.getBasedir(), "repo", "p2.index");
assertTrue(Files.exists(p2Index), "p2.index was not written to the in-place repository");
}
}
Loading