Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MRELEASE-1144] Upgrade to Parent 42 #216

Merged
merged 1 commit into from
Jun 9, 2024
Merged

[MRELEASE-1144] Upgrade to Parent 42 #216

merged 1 commit into from
Jun 9, 2024

Conversation

michael-o
Copy link
Member

This closes #216

Following this checklist to help us incorporate your
contribution quickly and easily:

  • Make sure there is a JIRA issue filed
    for the change (usually before you start working on it). Trivial changes like typos do not
    require a JIRA issue. Your pull request should address just this issue, without
    pulling in other changes.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Format the pull request title like [MRELEASE-XXX] - Fixes bug in ApproximateQuantiles,
    where you replace MRELEASE-XXX with the appropriate JIRA issue. Best practice
    is to use the JIRA issue title in the pull request title and in the first line of the
    commit message.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Run mvn clean verify -Prun-its to make sure basic checks pass. A more thorough check will
    be performed on your pull request automatically.

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

asfgit pushed a commit that referenced this pull request Jun 8, 2024
@michael-o
Copy link
Member Author

@cstamas Can you help and have a look at the failure? subproject2 depends on subproject1 (in compile scope) which has junit in test scope, but some some reason that is dragged into subproject1 as test as well.
The code which builds is:

    protected List<MavenProject> createReactorProjects(String sourcePath, String targetPath, String executionRoot)
            throws Exception {
        final Path testCaseRootFrom =
                Paths.get(getBasedir(), "src/test/resources").resolve(Paths.get("projects", sourcePath));

        final Path testCaseRootTo = getWorkingDirectory(targetPath);

        // Recopy the test resources since they are modified in some tests
        Files.walkFileTree(testCaseRootFrom, new SimpleFileVisitor<Path>() {

            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                Path relPath = testCaseRootFrom.relativize(file);

                if (!relPath.toFile().getName().startsWith("expected-")) {
                    Files.createDirectories(testCaseRootTo.resolve(relPath).getParent());

                    Files.copy(file, testCaseRootTo.resolve(relPath), StandardCopyOption.REPLACE_EXISTING);
                }

                return FileVisitResult.CONTINUE;
            }
        });

        Path projectFile;
        if (executionRoot == null) {
            projectFile = testCaseRootTo.resolve("pom.xml");
        } else {
            projectFile = testCaseRootTo.resolve(Paths.get(executionRoot, "pom.xml"));
        }

        List<ArtifactRepository> repos = Collections.singletonList(
                new DefaultArtifactRepository("central", getRemoteRepositoryURL(), new DefaultRepositoryLayout()));

        Repository repository = new Repository();
        repository.setId("central");
        repository.setUrl(getRemoteRepositoryURL());

        Profile profile = new Profile();
        profile.setId("profile");
        profile.addRepository(repository);

        ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest();
        buildingRequest.setLocalRepository(localRepository);
        buildingRequest.setRemoteRepositories(repos);
        buildingRequest.setPluginArtifactRepositories(repos);
        buildingRequest.setRepositoryMerging(RepositoryMerging.REQUEST_DOMINANT);
        DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession();
        repositorySession.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory()
                .newInstance(repositorySession, new LocalRepository(localRepository.getBasedir())));
        buildingRequest.setRepositorySession(repositorySession);
        buildingRequest.addProfile(profile);
        buildingRequest.setActiveProfileIds(Collections.singletonList(profile.getId()));
        buildingRequest.setResolveDependencies(true);

        List<ProjectBuildingResult> buildingResults =
                projectBuilder.build(Collections.singletonList(projectFile.toFile()), true, buildingRequest);

        List<MavenProject> reactorProjects = new ArrayList<>();
        for (ProjectBuildingResult buildingResult : buildingResults) {
            reactorProjects.add(buildingResult.getProject());
        }

        WorkspaceReader simpleReactorReader = new SimpleReactorWorkspaceReader(reactorProjects);
        repositorySession.setWorkspaceReader(simpleReactorReader);

        ProjectSorter sorter = new ProjectSorter(reactorProjects);
        reactorProjects = sorter.getSortedProjects();

        List<MavenProject> resolvedProjects = new ArrayList<>(reactorProjects.size());
        for (MavenProject project : reactorProjects) {
            MavenProject resolvedProject =
                    projectBuilder.build(project.getFile(), buildingRequest).getProject();

            // from LifecycleDependencyResolver
            if (resolvedProject.getDependencyArtifacts() == null) {
                try {
                    resolvedProject.setDependencyArtifacts(
                            resolvedProject.createArtifacts(artifactFactory, null, null));
                } catch (InvalidDependencyVersionException e) {
                    throw new LifecycleExecutionException(e);
                }
            }

            // TODO .... understand why this is working ... :-)
            // why projectBuilder doesn't resolve and set in proper way DependencyArtifacts and Artifacts
            if (resolvedProject.getDependencyArtifacts().size()
                            >= resolvedProject.getArtifacts().size()
                    && resolvedProject.getDependencyArtifacts().stream().noneMatch(a -> a.getVersion() == null)) {
                resolvedProject.setArtifacts(resolvedProject.getDependencyArtifacts());
            }

            resolvedProjects.add(resolvedProject);
        }
        return resolvedProjects;
    }

from org.apache.maven.shared.release.phase.AbstractReleaseTestCase.

I am down to
grafik

@michael-o
Copy link
Member Author

I think I have found it, stay put...

@michael-o michael-o requested a review from cstamas June 9, 2024 00:58
@michael-o
Copy link
Member Author

Resolution problem is gone, but still for some reason junit is added as a test dep to subproject2 which does not make sense...

asfgit pushed a commit that referenced this pull request Jun 9, 2024
@michael-o michael-o changed the title [MRELEASE-1144] Upgrade to Parent 42 and Maven 3.6.3 [MRELEASE-1144] Upgrade to Parent 42 Jun 9, 2024
@michael-o
Copy link
Member Author

Maven upgrade will be handled separately

@michael-o
Copy link
Member Author

Moved partially to #217.

@asfgit asfgit merged commit 2142c9e into master Jun 9, 2024
51 checks passed
@michael-o michael-o deleted the MRELEASE-1144 branch June 9, 2024 19:29
@slawekjaranowski slawekjaranowski added the dependencies Pull requests that update a dependency file label Jun 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants