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
22 changes: 12 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,26 @@ RUN chmod +x mvnw
RUN mkdir -p .mvn
COPY .mvn/wrapper .mvn/wrapper

# First, copy in just the pom.xml files and fetch the dependencies:
# First, copy in the pom.xml files (and any checked-in jars) and fetch the dependencies into a real image layer.
# This layer depends on the POMs, the checked-in jars, and the Maven wrapper (copied above), so it stays cached
# until one of those changes; dependency downloads are reused whenever the source changes but those inputs don't.
COPY --from=poms /usr/src/ .
# I don't know why we need all three either.
RUN --mount=type=cache,target=/tmp/m2_repo,id=openfire_build ./mvnw -e -B dependency:resolve-plugins -Dmaven.test.skip -Dmaven.repo.local=/tmp/m2_repo
RUN --mount=type=cache,target=/tmp/m2_repo,id=openfire_build ./mvnw -e -B de.qaware.maven:go-offline-maven-plugin:resolve-dependencies -Dmaven.repo.local=/tmp/m2_repo
RUN ./mvnw -e -B dependency:resolve-plugins -Dmaven.test.skip -Dmaven.repo.local=/tmp/m2_repo
RUN ./mvnw -e -B de.qaware.maven:go-offline-maven-plugin:resolve-dependencies -Dmaven.repo.local=/tmp/m2_repo
# The go-offline plugin and dependency:resolve-plugins do not reliably resolve BOM POMs referenced
# via <scope>import</scope> in <dependencyManagement>. Fetch them explicitly so they are present
# in the cache before the offline build runs. Add any newly introduced BOMs here in the same way.
RUN --mount=type=cache,target=/tmp/m2_repo,id=openfire_build \
./mvnw -e -B dependency:get -DgroupId=org.codehaus.plexus -DartifactId=plexus-utils -Dpackaging=jar -Dversion=1.1 -Dmaven.repo.local=/tmp/m2_repo && \
./mvnw -e -B dependency:get -DgroupId=org.junit -DartifactId=junit-bom -Dpackaging=pom -Dversion=5.13.4 -Dmaven.repo.local=/tmp/m2_repo && \
./mvnw -e -B dependency:get -DgroupId=org.mockito -DartifactId=mockito-bom -Dpackaging=pom -Dversion=5.22.0 -Dmaven.repo.local=/tmp/m2_repo
# in the repository before the offline build runs. Add any newly introduced BOMs here in the same way.
RUN ./mvnw -e -B dependency:get -DgroupId=org.codehaus.plexus -DartifactId=plexus-utils -Dpackaging=jar -Dversion=1.1 -Dmaven.repo.local=/tmp/m2_repo && \
./mvnw -e -B dependency:get -DgroupId=org.junit -DartifactId=junit-bom -Dpackaging=pom -Dversion=6.1.0 -Dmaven.repo.local=/tmp/m2_repo && \
./mvnw -e -B dependency:get -DgroupId=org.mockito -DartifactId=mockito-bom -Dpackaging=pom -Dversion=5.23.0 -Dmaven.repo.local=/tmp/m2_repo

# Above here is only affected by the pom.xml files, so the cache is stable.
# Above here is affected only by the POMs, checked-in jars, and the Maven wrapper, so the layer is usually stable.

# Now, copy in all the source, and actually build it, skipping the tests.
# The offline build reads the /tmp/m2_repo that the layers above populated.
COPY . .
RUN --mount=type=cache,target=/tmp/m2_repo,id=openfire_build ./mvnw -o -e -B install -Dmaven.test.skip -Dmaven.repo.local=/tmp/m2_repo
RUN ./mvnw -o -e -B install -Dmaven.test.skip -Dmaven.repo.local=/tmp/m2_repo
# In case of Windows, break glass.
RUN sed -i 's/\r//g' /usr/src/distribution/target/distribution-base/bin/openfire.sh

Expand Down
4 changes: 2 additions & 2 deletions xmppserver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,14 @@
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>6.1.0</version>
<version>6.1.0</version> <!-- when updating, also change the pre-fetch in the Dockerfile -->
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-bom</artifactId>
<version>5.23.0</version>
<version>5.23.0</version> <!-- when updating, also change the pre-fetch in the Dockerfile -->
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
Loading