Skip to content

Commit

Permalink
Merge branch 'eclipse-tycho:tycho-4.0.x' into tycho-4.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
kevloral authored Dec 22, 2023
2 parents d116bc4 + 049acfb commit 3283144
Show file tree
Hide file tree
Showing 17 changed files with 292 additions and 119 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/verify-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ concurrency:
on:
pull_request:
branches:
- 'master'
- 'tycho-4.0.x'

jobs:
build:
Expand Down Expand Up @@ -69,5 +69,5 @@ jobs:
-Dmaven.wagon.httpconnectionManager.ttlSeconds=120
-DskipTests
-Pbree-libs
-Dtycho.version=4.0.0-SNAPSHOT
-Dtycho.version=4.0.5-SNAPSHOT
clean verify
4 changes: 2 additions & 2 deletions .github/workflows/verify-platform2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ concurrency:
on:
pull_request:
branches:
- 'master'
- 'tycho-4.0.x'

jobs:
build:
Expand Down Expand Up @@ -69,6 +69,6 @@ jobs:
-Pbuild-individual-bundles
-Pbree-libs
-Dmaven.test.failure.ignore=true
-Dtycho.version=4.0.0-SNAPSHOT
-Dtycho.version=4.0.5-SNAPSHOT
-T1C
clean verify
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
import org.eclipse.equinox.p2.core.spi.IAgentServiceFactory;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
import org.eclipse.tycho.IRepositoryIdManager;
import org.eclipse.tycho.version.TychoVersion;

@Component(role = IAgentServiceFactory.class, hint = "org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager")
public class RemoteArtifactRepositoryManagerAgentFactory implements IAgentServiceFactory {

@Requirement
@Requirement
Logger logger;

@Requirement
Expand All @@ -33,26 +34,25 @@ public class RemoteArtifactRepositoryManagerAgentFactory implements IAgentServic
@Requirement
MavenAuthenticator authenticator;

@Override
public Object createService(IProvisioningAgent agent) {
IArtifactRepositoryManager plainRepoManager = (IArtifactRepositoryManager) new ArtifactRepositoryComponent()
.createService(agent);
if (getDisableP2MirrorsConfiguration()) {
plainRepoManager = new P2MirrorDisablingArtifactRepositoryManager(plainRepoManager,
logger);
}
@Override
public Object createService(IProvisioningAgent agent) {
IArtifactRepositoryManager plainRepoManager = (IArtifactRepositoryManager) new ArtifactRepositoryComponent()
.createService(agent);
if (getDisableP2MirrorsConfiguration()) {
plainRepoManager = new P2MirrorDisablingArtifactRepositoryManager(plainRepoManager, logger);
}
return new RemoteArtifactRepositoryManager(plainRepoManager, repositoryIdManager, authenticator);
}
}

private boolean getDisableP2MirrorsConfiguration() {
String key = "tycho.disableP2Mirrors";
private boolean getDisableP2MirrorsConfiguration() {
String key = "tycho.disableP2Mirrors";
String value = System.getProperty(key);

boolean disableP2Mirrors = Boolean.parseBoolean(value);
if (disableP2Mirrors && logger.isDebugEnabled()) {
String message = key + "=" + value + " -> ignoring mirrors specified in p2 artifact repositories";
logger.debug(message);
}
return disableP2Mirrors;
}
if (value != null) {
logger.info("Using " + key
+ " to disable P2 mirrors is deprecated, use the property eclipse.p2.mirrors instead, see https://tycho.eclipseprojects.io/doc/"
+ TychoVersion.getTychoVersion() + "/SystemProperties.html for details.");
return Boolean.parseBoolean(value);
}
return false;
}
}
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<commonsCompressVersion>1.25.0</commonsCompressVersion>
<plexusVersion>2.1.1</plexusVersion>
<plexusUtilsVersion>3.5.1</plexusUtilsVersion>
<plexusCompilerVersion>2.14.1</plexusCompilerVersion>
<plexusCompilerVersion>2.14.2</plexusCompilerVersion>
<cipherVersion>2.1.0</cipherVersion>
<pluginToolsVersion>3.10.2</pluginToolsVersion>
<jgit-version>6.8.0.202311291450-r</jgit-version>
Expand Down Expand Up @@ -386,7 +386,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<version>3.12.0</version>
<configuration>
<source>${min.jdk.version}</source>
<target>${min.jdk.version}</target>
Expand Down
9 changes: 9 additions & 0 deletions src/site/markdown/SystemProperties.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,12 @@ Name | Value | Default | Documentation
--- | --- | ---
tycho.comparator.showDiff | true / false | false | If set to true if text-like files show a unified diff of possible differences in files
tycho.comparator.threshold | bytes | 5242880 (~5MB) | gives the number of bytes for content to be compared semantically, larger files will only be compared byte-by-byte

### P2

These properties control the behaviour of P2 used by Tycho

Name | Value | Default | Documentation
--- | --- | ---
eclipse.p2.mirrors | true / false | true | Each p2 site can define a list of artifact repository mirrors, this controls if P2 mirrors should be used. This is independent from configuring mirrors in the maven configuration to be used by Tycho!

4 changes: 4 additions & 0 deletions tycho-api/src/main/java/org/eclipse/tycho/TargetPlatform.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public interface TargetPlatform {
* Key under which the final target platform is stored in the reactor project instances.
*/
String FINAL_TARGET_PLATFORM_KEY = "org.eclipse.tycho.core.TychoConstants/targetPlatform";

/**
* Key under which the preliminary target platform is stored in the reactor project instances.
*/
String PRELIMINARY_TARGET_PLATFORM_KEY = "org.eclipse.tycho.core.TychoConstants/dependencyOnlyTargetPlatform";

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import java.util.stream.Stream;

import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Dependency;
Expand Down Expand Up @@ -610,14 +611,26 @@ public List<String> getClasspathElements() throws MojoExecutionException {
.filter(a -> includedPathes.add(a.getFile().getAbsolutePath())) //
.toList();
for (Artifact artifact : additionalClasspathEntries) {
String path = artifact.getFile().getAbsolutePath();
getLog().debug("Add a pom only classpath entry: " + artifact + " @ " + path);
classpath.add(path);
ArtifactHandler artifactHandler = artifact.getArtifactHandler();
if (artifactHandler.isAddedToClasspath() && inScope(artifact.getScope())) {
String path = artifact.getFile().getAbsolutePath();
getLog().debug("Add a pom only classpath entry: " + artifact + " @ " + path);
classpath.add(path);
}
}
}
return classpath;
}

private boolean inScope(String dependencyScope) {
if (Artifact.SCOPE_COMPILE.equals(getDependencyScope())) {
if (Artifact.SCOPE_TEST.equals(dependencyScope)) {
return false;
}
}
return true;
}

private static boolean isValidLocation(File location) {
if (location == null || !location.exists() || (location.isFile() && location.length() == 0)) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion tycho-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<name>Tycho Core</name>
<description>Core Tycho components</description>
<properties>
<jetty.version>11.0.18</jetty.version>
<jetty.version>11.0.19</jetty.version>
</properties>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public interface DependencyResolver {

PomDependencyCollector resolvePomDependencies(MavenSession session, MavenProject project);

public TargetPlatform computePreliminaryTargetPlatform(MavenSession session, MavenProject project);
public TargetPlatform getPreliminaryTargetPlatform(MavenSession session, MavenProject project);

/**
* @param targetPlatform
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public DependencyArtifacts getDependencyArtifacts(ReactorProject reactorProject)
}
MavenSession mavenSession = getMavenSession(reactorProject);
MavenProject mavenProject = getMavenProject(reactorProject);
TargetPlatform preliminaryTargetPlatform = dependencyResolver.computePreliminaryTargetPlatform(mavenSession,
TargetPlatform preliminaryTargetPlatform = dependencyResolver.getPreliminaryTargetPlatform(mavenSession,
mavenProject);
TargetPlatformConfiguration configuration = projectManager.getTargetPlatformConfiguration(mavenProject);
DependencyResolverConfiguration resolverConfiguration = configuration.getDependencyResolverConfiguration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ public Collection<IRequirement> getAdditionalRequirements() {
return resolverConfiguration.getAdditionalRequirements();
}
};
TargetPlatform preliminaryTargetPlatform = dependencyResolver.computePreliminaryTargetPlatform(mavenSession,
TargetPlatform preliminaryTargetPlatform = dependencyResolver.getPreliminaryTargetPlatform(mavenSession,
mavenProject);
return dependencyResolver.resolveDependencies(mavenSession, mavenProject, preliminaryTargetPlatform,
testResolverConfiguration, configuration.getEnvironments());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*******************************************************************************
* Copyright (c) 2023 Christoph Läubrich 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
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Christoph Läubrich - initial API and implementation
*******************************************************************************/
package org.eclipse.tycho.core.osgitools;

import java.io.File;
import java.util.List;
import java.util.Set;

import org.apache.maven.execution.MavenSession;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.annotations.Component;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.tycho.ArtifactKey;
import org.eclipse.tycho.DefaultArtifactKey;
import org.eclipse.tycho.DependencyArtifacts;
import org.eclipse.tycho.PackagingType;
import org.eclipse.tycho.ReactorProject;
import org.eclipse.tycho.TargetPlatform;
import org.eclipse.tycho.TychoConstants;
import org.eclipse.tycho.core.ArtifactDependencyVisitor;
import org.eclipse.tycho.core.ArtifactDependencyWalker;
import org.eclipse.tycho.core.TychoProject;
import org.eclipse.tycho.core.osgitools.targetplatform.DefaultDependencyArtifacts;
import org.eclipse.tycho.core.resolver.target.ArtifactTypeHelper;
import org.eclipse.tycho.model.Feature;
import org.eclipse.tycho.model.ProductConfiguration;
import org.eclipse.tycho.model.UpdateSite;
import org.eclipse.tycho.targetplatform.P2TargetPlatform;

@Component(role = TychoProject.class, hint = PackagingType.TYPE_ECLIPSE_TARGET_DEFINITION)
public class TargetPlatformProject extends AbstractTychoProject {

@Override
public ArtifactDependencyWalker getDependencyWalker(ReactorProject project) {
return new ArtifactDependencyWalker() {

@Override
public void walk(ArtifactDependencyVisitor visitor) {

}

@Override
public void traverseUpdateSite(UpdateSite site, ArtifactDependencyVisitor visitor) {

}

@Override
public void traverseProduct(ProductConfiguration productConfiguration, ArtifactDependencyVisitor visitor) {

}

@Override
public void traverseFeature(File location, Feature feature, ArtifactDependencyVisitor visitor) {

}
};
}

@Override
public ArtifactKey getArtifactKey(ReactorProject project) {
return new DefaultArtifactKey("target", project.getArtifactId(), project.getVersion());
}

@Override
public DependencyArtifacts getDependencyArtifacts(ReactorProject reactorProject) {
return reactorProject.computeContextValue(TychoConstants.CTX_DEPENDENCY_ARTIFACTS, () -> {
DefaultDependencyArtifacts artifacts = new DefaultDependencyArtifacts(reactorProject);
MavenSession mavenSession = getMavenSession(reactorProject);
MavenProject mavenProject = getMavenProject(reactorProject);
TargetPlatform targetPlatform = dependencyResolver.getPreliminaryTargetPlatform(mavenSession,
mavenProject);
if (targetPlatform instanceof P2TargetPlatform p2) {
Set<IInstallableUnit> installableUnits = p2.getInstallableUnits();
for (IInstallableUnit iu : installableUnits) {
for (IArtifactKey key : iu.getArtifacts()) {
ArtifactKey artifactKey = ArtifactTypeHelper.toTychoArtifactKey(iu, key);
artifacts.addArtifactFile(artifactKey, () -> targetPlatform.getArtifactLocation(artifactKey),
List.of(iu));
}
}
}
return artifacts;
});
}

}
Loading

0 comments on commit 3283144

Please sign in to comment.