class ProjectLock implements AutoCloseable {
        final Lock acquiredAggregatorLock;
        final OwnerReentrantLock acquiredProjectLock;

        ProjectLock(MavenSession session, MojoDescriptor mojoDescriptor) {
            mojos.put(Thread.currentThread(), mojoDescriptor);
            if (session.getRequest().getDegreeOfConcurrency() > 1) {
                boolean aggregator = mojoDescriptor.isAggregator();
                acquiredAggregatorLock = aggregator ? aggregatorLock.writeLock() : aggregatorLock.readLock();
                acquiredProjectLock = getProjectLock(session);
                if (!acquiredAggregatorLock.tryLock()) {
                    Thread owner = aggregatorLock.getOwner();
                    MojoDescriptor ownerMojo = owner != null ? mojos.get(owner) : null;
                    String str = ownerMojo != null ? " The " + ownerMojo.getId() : "An";
                    String msg = str + " aggregator mojo is already being executed "
                            + "in this parallel build, those kind of mojos require exclusive access to "
                            + "reactor to prevent race conditions. This mojo execution will be blocked "
                            + "until the aggregator mojo is done.";
                    warn(msg);
                    acquiredAggregatorLock.lock();
                }
                if (!acquiredProjectLock.tryLock()) {
                    Thread owner = acquiredProjectLock.getOwner();
                    MojoDescriptor ownerMojo = owner != null ? mojos.get(owner) : null;
                    String str = ownerMojo != null ? " The " + ownerMojo.getId() : "A";
                    String msg = str + " mojo is already being executed "
                            + "on the project " + session.getCurrentProject().getGroupId()
                            + ":" + session.getCurrentProject().getArtifactId() + ". "
                            + "This mojo execution will be blocked "
                            + "until the mojo is done.";
                    warn(msg);
                    acquiredProjectLock.lock();
                }
            } else {
                acquiredAggregatorLock = null;
                acquiredProjectLock = null;
            }
        }

        @Override
        public void close() {
            // release the lock in the reverse order of the acquisition
            if (acquiredProjectLock != null) {
                acquiredProjectLock.unlock();
            }
            if (acquiredAggregatorLock != null) {
                acquiredAggregatorLock.unlock();
            }
            mojos.remove(Thread.currentThread());
        }

        private OwnerReentrantLock getProjectLock(MavenSession session) {<FILL_FUNCTION_BODY>}
    }

            SessionData data = session.getSession().getData();
            Map<MavenProject, OwnerReentrantLock> locks = data.computeIfAbsent(PROJECT_LOCKS, ConcurrentHashMap::new);
            return locks.computeIfAbsent(session.getCurrentProject(), p -> new OwnerReentrantLock());
        
<no_super_class>