diff --git a/Documentation/CACHE-HOWTO.md b/Documentation/CACHE-HOWTO.md index aa15f626af65..77d03ba07f19 100644 --- a/Documentation/CACHE-HOWTO.md +++ b/Documentation/CACHE-HOWTO.md @@ -17,18 +17,17 @@ ### Overview -Cache configuration provides you additional control over incremental maven behavior. Follow it step by step to +Cache configuration provides you additional control over incremental Maven behavior. Follow it step by step to understand how it works and figure out your optimal config ### Minimal config -Absolutely minimal config which enables incremental maven with local cache +Absolutely minimal config which enables incremental Maven with local cache ```xml - + true @@ -73,7 +72,7 @@ Add all the project specific source code files in ``. Scala in this case: ### Adding source directory for bespoke project layouts -In most of the cases incremental maven will recognize directories automatically by build introspection. If not, you can +In most of the cases incremental Maven will recognize directories automatically by build introspection. If not, you can add additional directories with ``. Also you can filter out undesirable dirs and files by using exclude tag ```xml @@ -134,7 +133,7 @@ Add `executionControl/runAlways` section ```xml + xsi:schemaLocation="org:apache:maven:cache:config:v1 http://maven.apache.org/xsd/cache-config-1.0.0.xsd"> ... @@ -157,7 +156,7 @@ Add `executionControl/runAlways` section ### I occasionally cached build with `-DskipTests=true` and tests do not run now -If you add command line flags to your build, they do not participate in effective pom - maven defers final value +If you add command line flags to your build, they do not participate in effective pom - Maven defers final value resolution to plugin runtime. To invalidate build if filed value is different in runtime, add reconciliation section to `executionControl`: @@ -180,7 +179,7 @@ to `executionControl`: Please notice `skipValue` attribute. It denotes value which forces skipped execution. Read `propertyName="skipTests" skipValue="true"` as if property skipTests has value true, plugin will skip execution If -you declare such value incremental maven will reuse appropriate full-build though technically they are different, but +you declare such value incremental Maven will reuse appropriate full-build though technically they are different, but because full-build is better it is safe to reuse ### How to renormalize line endings in working copy after committing .gitattributes (git 2.16+) @@ -201,4 +200,4 @@ git reset --hard ### I want to cache interim build and override it later with final version Solution: set `-Dremote.cache.save.final=true` to nodes which produce final builds. Such builds will not be overridden -and eventually will replace all interim builds \ No newline at end of file +and eventually will replace all interim builds diff --git a/Documentation/CACHE-PARAMETERS.md b/Documentation/CACHE-PARAMETERS.md index 7633ddbea158..12042c634076 100644 --- a/Documentation/CACHE-PARAMETERS.md +++ b/Documentation/CACHE-PARAMETERS.md @@ -26,8 +26,8 @@ This documents contains various configuration parameters supported by cache engi | `-Dremote.cache.configPath=true/false` | Location of cache configuration file | Cache config is not in default location | | `-Dremote.cache.enabled=true/false` | Remote cache and associated features disabled/enabled | To remove noise from logs then remote cache is not available | | `-Dremote.cache.save.enabled=true/false` | Remote cache save allowed or not | To designate nodes which allowed to push in remote shared cache | -| `-Dremote.cache.save.final=true/false` | Is it allowed or not to override produced cache | To ensure that reference build is not overriden by interim build | -| `-Dremote.cache.failFast=true/false` | Fail on the first module whcih cannot be restored from cache | Remote cache setup/tuning/troubleshooting | +| `-Dremote.cache.save.final=true/false` | Is it allowed or not to override produced cache | To ensure that reference build is not overridden by interim build | +| `-Dremote.cache.failFast=true/false` | Fail on the first module which cannot be restored from cache | Remote cache setup/tuning/troubleshooting | | `-Dremote.cache.baselineUrl=` | Location of baseline build for comparison | Remote cache setup/tuning/troubleshooting | ## Project level properties diff --git a/Documentation/CACHE-REMOTE.md b/Documentation/CACHE-REMOTE.md index f5fe38721d70..c89e5de19818 100644 --- a/Documentation/CACHE-REMOTE.md +++ b/Documentation/CACHE-REMOTE.md @@ -17,7 +17,7 @@ # Overview -This document describes generic approach to cache setup. The process require expertise in maven equivalent to expertise +This document describes generic approach to cache setup. The process require expertise in Maven equivalent to expertise required to author and Maven your project build, it implies good knowledge of both Maven and the project. Due to Maven model limitation the process is manual, but allows you to achieve sufficient control and transparency over caching logic. @@ -113,8 +113,8 @@ Once discrepancy between remote and local builds detected cache will fail with d in `target/incremental-maven` directory: ``` -* buildinfo-baseline-3c64673e23259e6f.xml - build specficiation from baseline build -* buildinfo-db43936e0666ce7.xml - build specification of locall build +* buildinfo-baseline-3c64673e23259e6f.xml - build specification from baseline build +* buildinfo-db43936e0666ce7.xml - build specification of local build * buildsdiff.xml - comparison report with list of discrepancies ``` @@ -242,7 +242,7 @@ relax consistency rules in favor of compatibility, remove property from tracked Current implementation doesn't support version changes between cache entries. It will result in cache invalidation for each new version. -To mitigate the issue please consider migrating off traditional maven release approach - try to use single version id in +To mitigate the issue please consider migrating off traditional Maven release approach - try to use single version id in project (eg `MY-PROJECT-LOCAL`). Such approach simplifies git branching workflow significantly. Deployment of artifacts with specific version from builds with cache is not supported yet. diff --git a/Documentation/CACHE.md b/Documentation/CACHE.md index 391becc7b5f7..7449ef5cc7ec 100644 --- a/Documentation/CACHE.md +++ b/Documentation/CACHE.md @@ -17,19 +17,19 @@ ## Overview -Idea of Incremental Maven is to specify module inputs and outputs and make them known to standard maven core. This +Idea of Incremental Maven is to specify module inputs and outputs and make them known to standard Maven core. This allows accurate analysis and determination of out-of-date build artifacts in the build dependencies graph. Making the dependency graph analysis deterministic leads to improvements in build times by avoiding re-building unnecessary modules. -Cache does not make any low-level interventions to build process and delegates actual build work to maven core. This -guarantees that build results are identical to results produced by standard maven and are fully reproducible. -To achieve accurate input and outputs calculation incremental maven combines automatic introspection +Cache does not make any low-level interventions to build process and delegates actual build work to Maven core. This +guarantees that build results are identical to results produced by standard Maven and are fully reproducible. +To achieve accurate input and outputs calculation incremental Maven combines automatic introspection of [project object model](https://maven.apache.org/pom.html#What_is_the_POM) in conjunction with configuration-driven rules for fine-grained content and execution control. For content analysis it digests based approach which is more reliable over widely used file timestamps in tools like Make or Apache Ant. Deterministic build state allows reliably cache even intermediate outputs of build and share them between teams using remote cache. Deterministic inputs calculation allows distributed and parallel builds running in heterogeneous environments (like cloud of build agents) -could efficiently reuse cached build artifacts. Therefore incremental maven is particularly well-suited for large maven +could efficiently reuse cached build artifacts. Therefore incremental Maven is particularly well-suited for large Maven projects that have significant number of small modules. Remote cache in conjunction with precise input identification effectively enables "change once - build once" approach. @@ -51,7 +51,7 @@ of today build with some tolerance (implementation, configuration and environmen ### Implementation insights -At very simple form, the incremental maven is essentially a hash function which takes maven project and produces hash +At very simple form, the incremental Maven is essentially a hash function which takes Maven project and produces hash code (checksum). Then hash value is used to fetch and restore build result. As with any hash, there could be collisions and instabilities. Collision could happen if the same hash produced from the different build states and will result in unintended reuse. Instability means that same input yields different hash sums @@ -79,7 +79,7 @@ verification it's still consumer's responsibility to verify final product qualit Given all the information above, the Incremental Maven is recommended to use in scenarios when productivity and performance are in priority. Typical cases are: -* Speedup CI. In conjunction with remote cache incremental maven could drastically reduce build times, validate pull +* Speedup CI. In conjunction with remote cache incremental Maven could drastically reduce build times, validate pull requests faster and reduce load on CI nodes * Speedup developer builds. By reusing cached builds developers could verify changes much faster and be more productive. No more `-DskipTests` and similar. @@ -92,35 +92,35 @@ This also allows you to validate cache correctness and reconcile cache outcomes ## Getting Started -To on-board incremental maven you need to complete several steps: +To on-board incremental Maven you need to complete several steps: -* Get incremental maven distribution -* Add cache config in .mvn +* Get incremental Maven distribution +* Add cache config in `.mvn` * Validate build results and iteratively adjust config to project specifics -* Migrate CI to incremental maven with remote cache (to get full benefit) - optional +* Migrate CI to incremental Maven with remote cache (to get full benefit) - optional -### Get incremental maven distribution +### Get incremental Maven distribution The recommended way is to add [Takari Maven Wrapper](https://github.com/takari/maven-wrapper) to your project. In that -case `maven-wrapper.properties` should reference the latest incremental maven distribution: +case `maven-wrapper.properties` should reference the latest incremental Maven distribution: ```properties distributionUrl=https://your-server/maven-incremental.zip wrapperUrl=https://your-server/maven-wrapper-0.5.5.jar ``` -Benefits of using maven wrapper are following: +Benefits of using Maven wrapper are following: * simple distribution across workstations and CI envs -* maven stays compatible to your branch +* Maven stays compatible to your branch * further upgrades are simplified significantly - If you refuse wrapper - then download, unzip and install it just as usual maven. Further it will be assumed you use - maven wrapper (`mvnw`) + If you refuse wrapper - then download, unzip and install it just as usual Maven. Further it will be assumed you use + Maven wrapper (`mvnw`) ### Adding cache config -Copy [default config](maven-cache-config.xml) and [xml schema](../maven-core/src/main/resources/cache-config.xsd) -to [.mvn](https://maven.apache.org/configure.html) dir of yor project. +Copy [default config `maven-cache-config.xml`](maven-cache-config.xml) +to [`.mvn/`](https://maven.apache.org/configure.html) dir of your project. To get overall understanding of cache machinery it is recommended to review the config and read comments. In typical scenario you need to adjust: @@ -135,15 +135,15 @@ See also: * [Remote cache setup](CACHE-REMOTE.md) - instruction how to setup shared cache * [Cache How-To](CACHE-HOWTO.md) - cookbook for frequently encountered questions * [Cache Parameters](CACHE-PARAMETERS.md) - description of supported parameters -* Attached [sample config file](maven-cache-config.xml) and elements annotations in xsd schema. (Ctrl+Q in idea should +* Attached [sample `maven-cache-config.xml` config file](maven-cache-config.xml) and elements annotations in xsd schema. (Ctrl+Q in idea should show annotations in popup) ### Adjusting cache config -Having incremental maven and the config in place you're all set. To run first cacheable build just +Having incremental Maven and the config in place you're all set. To run first cacheable build just execute: `mvnw clean install` -* Ensure that the config is picked up and incremental maven is picked up. Just check log output - you will notice cache +* Ensure that the config is picked up and incremental Maven is picked up. Just check log output - you will notice cache related output or initialization error message. * Navigate to your local repo directory - there should be sibling next to your local repo named `cache` * Find `buildinfo.xml` for typical module and review it. Ensure that diff --git a/Documentation/maven-cache-config.xml b/Documentation/maven-cache-config.xml index a2a7ad8ee1c3..12425fdf8939 100644 --- a/Documentation/maven-cache-config.xml +++ b/Documentation/maven-cache-config.xml @@ -15,9 +15,8 @@ See the License for the specific language governing permissions and limitations under the License. --> - + true diff --git a/apache-maven/src/main/appended-resources/META-INF/LICENSE.vm b/apache-maven/src/main/appended-resources/META-INF/LICENSE.vm index 6ac9f31124b7..d5cba211a660 100644 --- a/apache-maven/src/main/appended-resources/META-INF/LICENSE.vm +++ b/apache-maven/src/main/appended-resources/META-INF/LICENSE.vm @@ -42,8 +42,6 @@ subject to the terms and conditions of the following licenses: #* *##set ( $spdx = 'EPL-1.0' ) #* *##elseif ( $license.url.contains( "www.apache.org/licenses/LICENSE-2.0" ) ) #* *##set ( $spdx = 'ASL-2.0' ) -#* *##elseif ( $license.url.contains( "www.eclipse.org/org/documents/edl-v10.php" ) ) -#* *##set ( $spdx = 'EDL-1.0' ) #* *##elseif ( $license.url.contains( "www.mozilla.org/en-US/MPL/1.1" ) ) #* *##set ( $spdx = 'MPL-1.1' ) #* *##elseif ( $license.url.contains( "www.gnu.org/licenses/gpl" ) ) diff --git a/apache-maven/src/main/appended-resources/licenses/EDL-1.0.txt b/apache-maven/src/main/appended-resources/licenses/EDL-1.0.txt deleted file mode 100644 index 259e0377f30f..000000000000 --- a/apache-maven/src/main/appended-resources/licenses/EDL-1.0.txt +++ /dev/null @@ -1,23 +0,0 @@ -Eclipse Distribution License - v 1.0 -Copyright (c) 2007, Eclipse Foundation, Inc. and its licensors. - -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided -that the following conditions are met: - -- Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. -- Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation and/or other materials provided -with the distribution. -- Neither the name of the Eclipse Foundation, Inc. nor the names of its contributors may be used to endorse -or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/maven-core/pom.xml b/maven-core/pom.xml index 9dd0250754e4..93aede9be0d1 100644 --- a/maven-core/pom.xml +++ b/maven-core/pom.xml @@ -156,17 +156,6 @@ under the License. zero-allocation-hashing 0.9 - - jakarta.xml.bind - jakarta.xml.bind-api - 2.3.3 - - - com.sun.xml.bind - jaxb-impl - 2.3.3 - runtime - com.github.albfernandez juniversalchardet @@ -217,7 +206,43 @@ under the License. - modello-site-doc + modello-site-docs-cache + pre-site + + xdoc + xsd + + + 1.0.0 + + src/main/mdo/cache-buildinfo.mdo + src/main/mdo/cache-buildsdiff.mdo + src/main/mdo/cache-config.mdo + src/main/mdo/cache-report.mdo + + + + + modello-cache + + java + xpp3-reader + xpp3-writer + xsd + + + 1.0.0 + + src/main/mdo/cache-buildinfo.mdo + src/main/mdo/cache-buildsdiff.mdo + src/main/mdo/cache-config.mdo + src/main/mdo/cache-report.mdo + + ${basedir}/target/generated-sources/modello + + + + modello-site-docs-extension pre-site xdoc @@ -248,26 +273,6 @@ under the License. - - org.codehaus.mojo - jaxb2-maven-plugin - 2.5.0 - - - xjc - - xjc - - - - - org.apache.maven.caching.jaxb - - src/main/resources/cache-config.xsd - src/main/resources/cache-domain.xsd - - - diff --git a/maven-core/src/main/java/org/apache/maven/caching/ArtifactsRepository.java b/maven-core/src/main/java/org/apache/maven/caching/ArtifactsRepository.java index 65315498c7ff..c72781d35407 100644 --- a/maven-core/src/main/java/org/apache/maven/caching/ArtifactsRepository.java +++ b/maven-core/src/main/java/org/apache/maven/caching/ArtifactsRepository.java @@ -20,7 +20,7 @@ */ import org.apache.maven.artifact.Artifact; -import org.apache.maven.caching.jaxb.CacheReportType; +import org.apache.maven.caching.xml.report.CacheReportType; import org.apache.maven.caching.xml.BuildInfo; import org.apache.maven.execution.MavenSession; diff --git a/maven-core/src/main/java/org/apache/maven/caching/CacheContext.java b/maven-core/src/main/java/org/apache/maven/caching/CacheContext.java index 569286d8b841..d485687178d0 100644 --- a/maven-core/src/main/java/org/apache/maven/caching/CacheContext.java +++ b/maven-core/src/main/java/org/apache/maven/caching/CacheContext.java @@ -19,7 +19,7 @@ * under the License. */ -import org.apache.maven.caching.jaxb.ProjectsInputInfoType; +import org.apache.maven.caching.xml.buildinfo.ProjectsInputInfoType; import org.apache.maven.execution.MavenSession; import org.apache.maven.project.MavenProject; diff --git a/maven-core/src/main/java/org/apache/maven/caching/CacheControllerImpl.java b/maven-core/src/main/java/org/apache/maven/caching/CacheControllerImpl.java index ad9d490c6ebb..eac5feb2662a 100644 --- a/maven-core/src/main/java/org/apache/maven/caching/CacheControllerImpl.java +++ b/maven-core/src/main/java/org/apache/maven/caching/CacheControllerImpl.java @@ -31,18 +31,18 @@ import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.caching.checksum.KeyUtils; import org.apache.maven.caching.checksum.MavenProjectInput; +import org.apache.maven.caching.xml.buildinfo.ArtifactType; +import org.apache.maven.caching.xml.buildinfo.CompletedExecutionType; +import org.apache.maven.caching.xml.buildinfo.DigestItemType; +import org.apache.maven.caching.xml.buildinfo.ProjectsInputInfoType; +import org.apache.maven.caching.xml.buildinfo.Scm; +import org.apache.maven.caching.xml.buildsdiff.BuildDiffType; +import org.apache.maven.caching.xml.config.PropertyNameType; +import org.apache.maven.caching.xml.config.TrackedPropertyType; +import org.apache.maven.caching.xml.report.CacheReportType; +import org.apache.maven.caching.xml.report.ProjectReportType; import org.apache.maven.caching.hash.HashAlgorithm; import org.apache.maven.caching.hash.HashFactory; -import org.apache.maven.caching.jaxb.ArtifactType; -import org.apache.maven.caching.jaxb.BuildDiffType; -import org.apache.maven.caching.jaxb.BuildInfoType; -import org.apache.maven.caching.jaxb.CacheReportType; -import org.apache.maven.caching.jaxb.CompletedExecutionType; -import org.apache.maven.caching.jaxb.DigestItemType; -import org.apache.maven.caching.jaxb.ProjectReportType; -import org.apache.maven.caching.jaxb.ProjectsInputInfoType; -import org.apache.maven.caching.jaxb.PropertyNameType; -import org.apache.maven.caching.jaxb.TrackedPropertyType; import org.apache.maven.caching.xml.BuildInfo; import org.apache.maven.caching.xml.CacheConfig; import org.apache.maven.caching.xml.CacheSource; @@ -67,7 +67,6 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; -import java.math.BigInteger; import java.nio.charset.StandardCharsets; import java.nio.file.FileVisitResult; import java.nio.file.Files; @@ -143,7 +142,7 @@ public class CacheControllerImpl implements CacheController private final ConcurrentMap cacheResults = new ConcurrentHashMap<>(); - private volatile BuildInfoType.Scm scm; + private volatile Scm scm; @Override @Nonnull @@ -434,7 +433,7 @@ public void save( CacheResult cacheResult, List mojoExecutions, final BuildInfo buildInfo = new BuildInfo( session.getGoals(), projectArtifactDto, attachedArtifactDtos, context.getInputInfo(), completedExecution, hashFactory.getAlgorithm() ); populateGitInfo( buildInfo, session ); - buildInfo.getDto().setFinal( cacheConfig.isSaveFinal() ); + buildInfo.getDto().set_final( cacheConfig.isSaveFinal() ); cacheResults.put( getVersionlessProjectKey( project ), rebuilded( cacheResult, buildInfo ) ); // if package phase presence means new artifacts were packaged @@ -554,7 +553,7 @@ private ArtifactType artifactDto( Artifact projectArtifact, HashAlgorithm algori { final Path file = projectArtifact.getFile().toPath(); dto.setFileHash( algorithm.hash( file ) ); - dto.setFileSize( BigInteger.valueOf( Files.size( file ) ) ); + dto.setFileSize( Files.size( file ) ); } return dto; } @@ -798,7 +797,7 @@ private void populateGitInfo( BuildInfo buildInfo, MavenSession session ) throws } catch ( IOException e ) { - scm = new BuildInfoType.Scm(); + scm = new Scm(); logger.error( "Cannot populate git info", e ); } } diff --git a/maven-core/src/main/java/org/apache/maven/caching/CacheDiff.java b/maven-core/src/main/java/org/apache/maven/caching/CacheDiff.java index 9e066a598eff..29e18d2fea4a 100644 --- a/maven-core/src/main/java/org/apache/maven/caching/CacheDiff.java +++ b/maven-core/src/main/java/org/apache/maven/caching/CacheDiff.java @@ -22,13 +22,13 @@ import com.google.common.base.Optional; import com.google.common.collect.Sets; import org.apache.commons.lang3.StringUtils; -import org.apache.maven.caching.jaxb.BuildDiffType; -import org.apache.maven.caching.jaxb.BuildInfoType; -import org.apache.maven.caching.jaxb.CompletedExecutionType; -import org.apache.maven.caching.jaxb.DigestItemType; -import org.apache.maven.caching.jaxb.MismatchType; -import org.apache.maven.caching.jaxb.ProjectsInputInfoType; -import org.apache.maven.caching.jaxb.PropertyValueType; +import org.apache.maven.caching.xml.buildinfo.BuildInfoType; +import org.apache.maven.caching.xml.buildinfo.CompletedExecutionType; +import org.apache.maven.caching.xml.buildinfo.DigestItemType; +import org.apache.maven.caching.xml.buildinfo.ProjectsInputInfoType; +import org.apache.maven.caching.xml.buildinfo.PropertyValueType; +import org.apache.maven.caching.xml.buildsdiff.BuildDiffType; +import org.apache.maven.caching.xml.buildsdiff.MismatchType; import org.apache.maven.caching.xml.CacheConfig; import java.util.ArrayList; @@ -232,23 +232,23 @@ private void compareDependencies( ProjectsInputInfoType current, ProjectsInputIn } - private void compareExecutions( BuildInfoType.Executions current, BuildInfoType.Executions baseline ) + private void compareExecutions( List current, List baseline ) { Map baselineExecutionsByKey = new HashMap<>(); - for ( CompletedExecutionType completedExecutionType : baseline.getExecution() ) + for ( CompletedExecutionType completedExecutionType : baseline ) { baselineExecutionsByKey.put( completedExecutionType.getExecutionKey(), completedExecutionType ); } Map currentExecutionsByKey = new HashMap<>(); - for ( CompletedExecutionType e1 : current.getExecution() ) + for ( CompletedExecutionType e1 : current ) { currentExecutionsByKey.put( e1.getExecutionKey(), e1 ); } // such situation normally means different poms and mismatch in effective poms, // but in any case it is helpful to report - for ( CompletedExecutionType baselineExecution : baseline.getExecution() ) + for ( CompletedExecutionType baselineExecution : baseline ) { if ( !currentExecutionsByKey.containsKey( baselineExecution.getExecutionKey() ) ) { @@ -261,7 +261,7 @@ private void compareExecutions( BuildInfoType.Executions current, BuildInfoType. } } - for ( CompletedExecutionType currentExecution : current.getExecution() ) + for ( CompletedExecutionType currentExecution : current ) { if ( !baselineExecutionsByKey.containsKey( currentExecution.getExecutionKey() ) ) { @@ -285,7 +285,7 @@ private void comparePlugins( CompletedExecutionType current, CompletedExecutionT { // TODO add support for skip values final List trackedProperties = new ArrayList<>(); - for ( PropertyValueType propertyValueType : current.getConfiguration().getProperty() ) + for ( PropertyValueType propertyValueType : current.getConfiguration() ) { if ( propertyValueType.isTracked() ) { @@ -298,7 +298,7 @@ private void comparePlugins( CompletedExecutionType current, CompletedExecutionT } final Map baselinePropertiesByName = new HashMap<>(); - for ( PropertyValueType propertyValueType : baseline.getConfiguration().getProperty() ) + for ( PropertyValueType propertyValueType : baseline.getConfiguration() ) { baselinePropertiesByName.put( propertyValueType.getName(), propertyValueType ); } diff --git a/maven-core/src/main/java/org/apache/maven/caching/CacheResult.java b/maven-core/src/main/java/org/apache/maven/caching/CacheResult.java index 8d886764f8b8..84038a3311d8 100644 --- a/maven-core/src/main/java/org/apache/maven/caching/CacheResult.java +++ b/maven-core/src/main/java/org/apache/maven/caching/CacheResult.java @@ -117,6 +117,6 @@ public RestoreStatus getStatus() public boolean isFinal() { - return buildInfo != null && buildInfo.getDto().isFinal(); + return buildInfo != null && buildInfo.getDto().is_final(); } } diff --git a/maven-core/src/main/java/org/apache/maven/caching/DefaultPluginScanConfig.java b/maven-core/src/main/java/org/apache/maven/caching/DefaultPluginScanConfig.java index 408d097cf10e..cff0375d3d1a 100644 --- a/maven-core/src/main/java/org/apache/maven/caching/DefaultPluginScanConfig.java +++ b/maven-core/src/main/java/org/apache/maven/caching/DefaultPluginScanConfig.java @@ -19,7 +19,7 @@ * under the License. */ -import org.apache.maven.caching.jaxb.DirScanConfigType; +import org.apache.maven.caching.xml.config.DirScanConfigType; import javax.annotation.Nonnull; diff --git a/maven-core/src/main/java/org/apache/maven/caching/HttpRepositoryImpl.java b/maven-core/src/main/java/org/apache/maven/caching/HttpRepositoryImpl.java index fbbe509bb28d..d32460da07fd 100644 --- a/maven-core/src/main/java/org/apache/maven/caching/HttpRepositoryImpl.java +++ b/maven-core/src/main/java/org/apache/maven/caching/HttpRepositoryImpl.java @@ -33,10 +33,10 @@ import org.apache.http.impl.client.HttpClientBuilder; import org.apache.maven.artifact.Artifact; import org.apache.maven.caching.checksum.MavenProjectInput; -import org.apache.maven.caching.jaxb.ArtifactType; -import org.apache.maven.caching.jaxb.BuildInfoType; -import org.apache.maven.caching.jaxb.CacheReportType; -import org.apache.maven.caching.jaxb.ProjectReportType; +import org.apache.maven.caching.xml.buildinfo.ArtifactType; +import org.apache.maven.caching.xml.buildinfo.BuildInfoType; +import org.apache.maven.caching.xml.report.CacheReportType; +import org.apache.maven.caching.xml.report.ProjectReportType; import org.apache.maven.caching.xml.BuildInfo; import org.apache.maven.caching.xml.CacheConfig; import org.apache.maven.caching.xml.CacheSource; @@ -268,7 +268,7 @@ public Optional findBaselineBuild( MavenProject project ) { String url; final ProjectReportType projectReport = cachedProjectHolder.get(); - if ( projectReport.isSetUrl() ) + if ( projectReport.getUrl() != null ) { url = cachedProjectHolder.get().getUrl(); logInfo( "Retrieving baseline buildinfo: " + projectReport.getUrl(), project.getArtifactId() ); diff --git a/maven-core/src/main/java/org/apache/maven/caching/LocalArtifactsRepository.java b/maven-core/src/main/java/org/apache/maven/caching/LocalArtifactsRepository.java index c5916b2c64ba..c646aa76c0f7 100644 --- a/maven-core/src/main/java/org/apache/maven/caching/LocalArtifactsRepository.java +++ b/maven-core/src/main/java/org/apache/maven/caching/LocalArtifactsRepository.java @@ -20,9 +20,9 @@ */ import com.google.common.base.Optional; -import org.apache.maven.caching.jaxb.ArtifactType; import org.apache.maven.caching.xml.BuildInfo; import org.apache.maven.caching.xml.CacheSource; +import org.apache.maven.caching.xml.buildinfo.ArtifactType; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Dependency; diff --git a/maven-core/src/main/java/org/apache/maven/caching/LocalRepositoryImpl.java b/maven-core/src/main/java/org/apache/maven/caching/LocalRepositoryImpl.java index ec75b476e4b4..a0fbcbe1e528 100644 --- a/maven-core/src/main/java/org/apache/maven/caching/LocalRepositoryImpl.java +++ b/maven-core/src/main/java/org/apache/maven/caching/LocalRepositoryImpl.java @@ -31,13 +31,14 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.tuple.Pair; import org.apache.maven.artifact.Artifact; -import org.apache.maven.caching.jaxb.ArtifactType; -import org.apache.maven.caching.jaxb.BuildInfoType; -import org.apache.maven.caching.jaxb.CacheReportType; import org.apache.maven.caching.xml.BuildInfo; import org.apache.maven.caching.xml.CacheConfig; import org.apache.maven.caching.xml.CacheSource; import org.apache.maven.caching.xml.XmlService; +import org.apache.maven.caching.xml.buildinfo.ArtifactType; +import org.apache.maven.caching.xml.buildinfo.BuildInfoType; +import org.apache.maven.caching.xml.buildinfo.Scm; +import org.apache.maven.caching.xml.report.CacheReportType; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.LegacySupport; @@ -350,11 +351,11 @@ public FileVisitResult visitFile( Path o, BasicFileAttributes basicFileAttribute return Optional.of( orderedFiles.get( 0 ).getLeft() ); } - private String getScmRef( BuildInfoType.Scm scm ) + private String getScmRef( Scm scm ) { if ( scm != null ) { - return scm.isSetSourceBranch() ? scm.getSourceBranch() : scm.getRevision(); + return scm.getSourceBranch() != null ? scm.getSourceBranch() : scm.getRevision(); } else { diff --git a/maven-core/src/main/java/org/apache/maven/caching/MojoExecutionManager.java b/maven-core/src/main/java/org/apache/maven/caching/MojoExecutionManager.java index 9c07e5815e69..84efff4c5945 100644 --- a/maven-core/src/main/java/org/apache/maven/caching/MojoExecutionManager.java +++ b/maven-core/src/main/java/org/apache/maven/caching/MojoExecutionManager.java @@ -20,11 +20,11 @@ */ import org.apache.commons.lang3.StringUtils; -import org.apache.maven.caching.jaxb.CompletedExecutionType; -import org.apache.maven.caching.jaxb.TrackedPropertyType; import org.apache.maven.caching.xml.BuildInfo; import org.apache.maven.caching.xml.CacheConfig; import org.apache.maven.caching.xml.DtoUtils; +import org.apache.maven.caching.xml.config.TrackedPropertyType; +import org.apache.maven.caching.xml.buildinfo.CompletedExecutionType; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.Mojo; import org.apache.maven.plugin.MojoCheker; @@ -124,7 +124,7 @@ private boolean isParamsMatched( MavenProject project, final String propertyName = trackedProperty.getPropertyName(); String expectedValue = DtoUtils.findPropertyValue( propertyName, completedExecution ); - if ( expectedValue == null && trackedProperty.isSetDefaultValue() ) + if ( expectedValue == null && trackedProperty.getDefaultValue() != null ) { expectedValue = trackedProperty.getDefaultValue(); } diff --git a/maven-core/src/main/java/org/apache/maven/caching/PluginScanConfig.java b/maven-core/src/main/java/org/apache/maven/caching/PluginScanConfig.java index 93bcccba0b1c..08ea117a4cb7 100644 --- a/maven-core/src/main/java/org/apache/maven/caching/PluginScanConfig.java +++ b/maven-core/src/main/java/org/apache/maven/caching/PluginScanConfig.java @@ -19,7 +19,7 @@ * under the License. */ -import org.apache.maven.caching.jaxb.DirScanConfigType; +import org.apache.maven.caching.xml.config.DirScanConfigType; import javax.annotation.Nonnull; diff --git a/maven-core/src/main/java/org/apache/maven/caching/PluginScanConfigImpl.java b/maven-core/src/main/java/org/apache/maven/caching/PluginScanConfigImpl.java index 87791905100d..c7031fa3f866 100644 --- a/maven-core/src/main/java/org/apache/maven/caching/PluginScanConfigImpl.java +++ b/maven-core/src/main/java/org/apache/maven/caching/PluginScanConfigImpl.java @@ -20,9 +20,9 @@ */ import org.apache.commons.lang3.StringUtils; -import org.apache.maven.caching.jaxb.DirScanConfigType; -import org.apache.maven.caching.jaxb.TagNameType; -import org.apache.maven.caching.jaxb.TagScanConfigType; +import org.apache.maven.caching.xml.config.DirScanConfigType; +import org.apache.maven.caching.xml.config.TagNameType; +import org.apache.maven.caching.xml.config.TagScanConfigType; import javax.annotation.Nonnull; import java.util.List; @@ -52,13 +52,13 @@ public boolean accept( String tagName ) // include or exclude is a choice element, could be only obe property set //noinspection ConstantConditions - final List includes = dto.getInclude(); + final List includes = dto.getIncludes(); if ( !includes.isEmpty() ) { return findTagScanProperties( tagName ) != null; } - return !contains( dto.getExclude(), tagName ); + return !contains( dto.getExcludes(), tagName ); } private boolean contains( List excludes, String tagName ) @@ -95,7 +95,7 @@ public PluginScanConfig mergeWith( final PluginScanConfig overrideConfig ) } DirScanConfigType merged = new DirScanConfigType(); - if ( override.isSetMode() ) + if ( override.getMode() != null ) { merged.setMode( override.getMode() ); } @@ -104,11 +104,11 @@ public PluginScanConfig mergeWith( final PluginScanConfig overrideConfig ) merged.setMode( dto.getMode() ); } - merged.getExclude().addAll( dto.getExclude() ); - merged.getExclude().addAll( override.getExclude() ); + merged.getExcludes().addAll( dto.getExcludes() ); + merged.getExcludes().addAll( override.getExcludes() ); - merged.getInclude().addAll( dto.getInclude() ); - merged.getInclude().addAll( override.getInclude() ); + merged.getIncludes().addAll( dto.getIncludes() ); + merged.getIncludes().addAll( override.getIncludes() ); return new PluginScanConfigImpl( merged ); } @@ -128,10 +128,10 @@ public DirScanConfigType dto() private ScanConfigProperties findTagScanProperties( String tagName ) { - ScanConfigProperties scanConfigProperties = findConfigByName( tagName, dto.getInclude() ); + ScanConfigProperties scanConfigProperties = findConfigByName( tagName, dto.getIncludes() ); if ( scanConfigProperties == null ) { - scanConfigProperties = findConfigByName( tagName, dto.getTagScanConfig() ); + scanConfigProperties = findConfigByName( tagName, dto.getTagScanConfigs() ); } return scanConfigProperties; } diff --git a/maven-core/src/main/java/org/apache/maven/caching/ProjectUtils.java b/maven-core/src/main/java/org/apache/maven/caching/ProjectUtils.java index 176556850377..a6bdd7a6b958 100644 --- a/maven-core/src/main/java/org/apache/maven/caching/ProjectUtils.java +++ b/maven-core/src/main/java/org/apache/maven/caching/ProjectUtils.java @@ -25,7 +25,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.ArtifactHandler; -import org.apache.maven.caching.jaxb.BuildInfoType; +import org.apache.maven.caching.xml.buildinfo.Scm; import org.apache.maven.execution.MavenSession; import org.apache.maven.lifecycle.internal.ProjectIndex; import org.apache.maven.lifecycle.internal.builder.BuilderCommon; @@ -155,9 +155,9 @@ public static String getMultimoduleRoot( MavenSession session ) return System.getProperty( "maven.multiModuleProjectDirectory", session.getExecutionRootDirectory() ); } - public static BuildInfoType.Scm readGitInfo( MavenSession session ) throws IOException + public static Scm readGitInfo( MavenSession session ) throws IOException { - final BuildInfoType.Scm scmCandidate = new BuildInfoType.Scm(); + final Scm scmCandidate = new Scm(); final Path gitDir = Paths.get( getMultimoduleRoot( session ), ".git" ); if ( Files.isDirectory( gitDir ) ) { diff --git a/maven-core/src/main/java/org/apache/maven/caching/RemoteArtifactsRepository.java b/maven-core/src/main/java/org/apache/maven/caching/RemoteArtifactsRepository.java index 7c118c405739..551c27d0b557 100644 --- a/maven-core/src/main/java/org/apache/maven/caching/RemoteArtifactsRepository.java +++ b/maven-core/src/main/java/org/apache/maven/caching/RemoteArtifactsRepository.java @@ -20,8 +20,8 @@ */ import com.google.common.base.Optional; -import org.apache.maven.caching.jaxb.ArtifactType; import org.apache.maven.caching.xml.BuildInfo; +import org.apache.maven.caching.xml.buildinfo.ArtifactType; import org.apache.maven.project.MavenProject; import java.io.IOException; diff --git a/maven-core/src/main/java/org/apache/maven/caching/checksum/DigestUtils.java b/maven-core/src/main/java/org/apache/maven/caching/checksum/DigestUtils.java index e837da1f8587..6973f82e9542 100644 --- a/maven-core/src/main/java/org/apache/maven/caching/checksum/DigestUtils.java +++ b/maven-core/src/main/java/org/apache/maven/caching/checksum/DigestUtils.java @@ -22,7 +22,7 @@ import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang3.StringUtils; import org.apache.maven.caching.hash.HashChecksum; -import org.apache.maven.caching.jaxb.DigestItemType; +import org.apache.maven.caching.xml.buildinfo.DigestItemType; import org.mozilla.universalchardet.UniversalDetector; import java.io.IOException; diff --git a/maven-core/src/main/java/org/apache/maven/caching/checksum/KeyUtils.java b/maven-core/src/main/java/org/apache/maven/caching/checksum/KeyUtils.java index 04d9207cb0dc..a0075e071589 100644 --- a/maven-core/src/main/java/org/apache/maven/caching/checksum/KeyUtils.java +++ b/maven-core/src/main/java/org/apache/maven/caching/checksum/KeyUtils.java @@ -21,7 +21,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; -import org.apache.maven.caching.jaxb.ArtifactType; +import org.apache.maven.caching.xml.buildinfo.ArtifactType; import org.apache.maven.model.Dependency; import org.apache.maven.project.MavenProject; diff --git a/maven-core/src/main/java/org/apache/maven/caching/checksum/MavenProjectInput.java b/maven-core/src/main/java/org/apache/maven/caching/checksum/MavenProjectInput.java index 8e5873ce7dcd..089e02de9988 100644 --- a/maven-core/src/main/java/org/apache/maven/caching/checksum/MavenProjectInput.java +++ b/maven-core/src/main/java/org/apache/maven/caching/checksum/MavenProjectInput.java @@ -19,7 +19,6 @@ * under the License. */ - import com.google.common.base.Optional; import com.google.common.collect.Iterables; import org.apache.commons.lang3.StringUtils; @@ -33,14 +32,16 @@ import org.apache.maven.caching.ProjectUtils; import org.apache.maven.caching.RemoteArtifactsRepository; import org.apache.maven.caching.ScanConfigProperties; +import org.apache.maven.caching.hash.HashFactory; import org.apache.maven.caching.hash.HashAlgorithm; import org.apache.maven.caching.hash.HashChecksum; -import org.apache.maven.caching.hash.HashFactory; -import org.apache.maven.caching.jaxb.DigestItemType; -import org.apache.maven.caching.jaxb.ProjectsInputInfoType; import org.apache.maven.caching.xml.BuildInfo; import org.apache.maven.caching.xml.CacheConfig; import org.apache.maven.caching.xml.DtoUtils; +import org.apache.maven.caching.xml.buildinfo.DigestItemType; +import org.apache.maven.caching.xml.buildinfo.ProjectsInputInfoType; +import org.apache.maven.caching.xml.config.Exclude; +import org.apache.maven.caching.xml.config.Include; import org.apache.maven.execution.MavenSession; import org.apache.maven.lifecycle.internal.ProjectIndex; import org.apache.maven.model.Build; @@ -94,7 +95,6 @@ import static org.apache.commons.lang3.StringUtils.stripToEmpty; import static org.apache.maven.caching.ProjectUtils.isBuilding; import static org.apache.maven.caching.ProjectUtils.isSnapshot; -import static org.apache.maven.caching.jaxb.PathSetType.Include; /** * MavenProjectInput @@ -179,9 +179,10 @@ public MavenProjectInput( MavenProject project, filteredOutPaths = new ArrayList<>( Arrays.asList( normalizedPath( build.getDirectory() ), // target by default normalizedPath( build.getOutputDirectory() ), normalizedPath( build.getTestOutputDirectory() ) ) ); - for ( String excludePath : config.getGlobalExcludePaths() ) + List excludes = config.getGlobalExcludePaths(); + for ( Exclude excludePath : excludes ) { - filteredOutPaths.add( Paths.get( excludePath ) ); + filteredOutPaths.add( Paths.get( excludePath.getValue() ) ); } for ( String propertyName : properties.stringPropertyNames() ) diff --git a/maven-core/src/main/java/org/apache/maven/caching/hash/CloseableBuffer.java b/maven-core/src/main/java/org/apache/maven/caching/hash/CloseableBuffer.java index 0fec3646ffa4..91acdf27b6d3 100644 --- a/maven-core/src/main/java/org/apache/maven/caching/hash/CloseableBuffer.java +++ b/maven-core/src/main/java/org/apache/maven/caching/hash/CloseableBuffer.java @@ -35,22 +35,21 @@ */ public class CloseableBuffer implements AutoCloseable { - /* Java 8 - private static final Cleaner CLEANER = doPrivileged((PrivilegedAction) () -> { - final boolean isOldJava = System.getProperty("java.specification.version", "9").startsWith("1."); - if (isOldJava) { - return DirectCleaner.isSupported() ? new DirectCleaner() : new NoopCleaner(); - } else { - return UnsafeCleaner.isSupported() ? new UnsafeCleaner() : new NoopCleaner(); - } - }); - */ + private static final Cleaner CLEANER = doPrivileged( new PrivilegedAction() { @Override public Cleaner run() { - return DirectCleaner.isSupported() ? new DirectCleaner() : new NoopCleaner(); + final String jsv = System.getProperty( "java.specification.version", "9" ); + if ( jsv.startsWith( "1." ) ) + { + return DirectCleaner.isSupported() ? new DirectCleaner() : new NoopCleaner(); + } + else + { + return UnsafeCleaner.isSupported() ? new UnsafeCleaner() : new NoopCleaner(); + } } } ); diff --git a/maven-core/src/main/java/org/apache/maven/caching/hash/XXMM.java b/maven-core/src/main/java/org/apache/maven/caching/hash/XXMM.java index 8e09299c247e..7afe2403ffbe 100644 --- a/maven-core/src/main/java/org/apache/maven/caching/hash/XXMM.java +++ b/maven-core/src/main/java/org/apache/maven/caching/hash/XXMM.java @@ -57,8 +57,8 @@ private static class Algorithm extends XX.Algorithm @Override public byte[] hash( Path path ) throws IOException { - try ( FileChannel channel = FileChannel.open( path, - READ ); CloseableBuffer buffer = CloseableBuffer.mappedBuffer( channel, READ_ONLY ) ) + try ( FileChannel channel = FileChannel.open( path, READ ); + CloseableBuffer buffer = CloseableBuffer.mappedBuffer( channel, READ_ONLY ) ) { return toByteArray( XX.INSTANCE.hashBytes( buffer.getBuffer() ) ); } diff --git a/maven-core/src/main/java/org/apache/maven/caching/xml/BuildInfo.java b/maven-core/src/main/java/org/apache/maven/caching/xml/BuildInfo.java index 0b61bfd89d74..f0cf3c7c7b6d 100644 --- a/maven-core/src/main/java/org/apache/maven/caching/xml/BuildInfo.java +++ b/maven-core/src/main/java/org/apache/maven/caching/xml/BuildInfo.java @@ -24,24 +24,22 @@ import org.apache.maven.caching.ProjectUtils; import org.apache.maven.caching.checksum.MavenProjectInput; import org.apache.maven.caching.hash.HashAlgorithm; -import org.apache.maven.caching.jaxb.ArtifactType; -import org.apache.maven.caching.jaxb.BuildInfoType; -import org.apache.maven.caching.jaxb.CompletedExecutionType; -import org.apache.maven.caching.jaxb.DigestItemType; -import org.apache.maven.caching.jaxb.ProjectsInputInfoType; +import org.apache.maven.caching.xml.buildinfo.ArtifactType; +import org.apache.maven.caching.xml.buildinfo.BuildInfoType; +import org.apache.maven.caching.xml.buildinfo.CompletedExecutionType; +import org.apache.maven.caching.xml.buildinfo.DigestItemType; +import org.apache.maven.caching.xml.buildinfo.ProjectsInputInfoType; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecution; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.StringUtils; -import javax.xml.datatype.DatatypeConfigurationException; -import javax.xml.datatype.DatatypeFactory; import java.io.IOException; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Collections; -import java.util.GregorianCalendar; +import java.util.Date; import java.util.List; import java.util.Objects; @@ -66,13 +64,7 @@ public BuildInfo( List goals, { this.dto = new BuildInfoType(); this.dto.setCacheImplementationVersion( MavenProjectInput.CACHE_IMPLMENTATION_VERSION ); - try - { - this.dto.setBuildTime( DatatypeFactory.newInstance().newXMLGregorianCalendar( new GregorianCalendar() ) ); - } - catch ( DatatypeConfigurationException ignore ) - { - } + this.dto.setBuildTime( new Date() ); try { this.dto.setBuildServer( InetAddress.getLocalHost().getCanonicalHostName() ); @@ -83,10 +75,9 @@ public BuildInfo( List goals, } this.dto.setHashFunction( hashAlgorithm ); this.dto.setArtifact( artifact ); - this.dto.setGoals( createGoals( goals ) ); - this.dto.setAttachedArtifacts( new BuildInfoType.AttachedArtifacts() ); - this.dto.getAttachedArtifacts().getArtifact().addAll( attachedArtifacts ); - this.dto.setExecutions( createExecutions( completedExecutions ) ); + this.dto.setGoals( goals ); + this.dto.setAttachedArtifacts( attachedArtifacts ); + this.dto.setExecutions( completedExecutions ); this.dto.setProjectsInputInfo( projectsInputInfo ); this.source = CacheSource.BUILD; } @@ -96,30 +87,16 @@ public CacheSource getSource() return source; } - private BuildInfoType.Executions createExecutions( List completedExecutions ) - { - BuildInfoType.Executions executions = new BuildInfoType.Executions(); - executions.getExecution().addAll( completedExecutions ); - return executions; - } - public BuildInfo( BuildInfoType buildInfo, CacheSource source ) { this.dto = buildInfo; this.source = source; } - public static BuildInfoType.Goals createGoals( List list ) - { - BuildInfoType.Goals goals = new BuildInfoType.Goals(); - goals.getGoal().addAll( list ); - return goals; - } - - public static BuildInfoType.AttachedArtifacts createAttachedArtifacts( List artifacts, - HashAlgorithm algorithm ) throws IOException + public static List createAttachedArtifacts( List artifacts, + HashAlgorithm algorithm ) throws IOException { - BuildInfoType.AttachedArtifacts attachedArtifacts = new BuildInfoType.AttachedArtifacts(); + List attachedArtifacts = new ArrayList<>(); for ( Artifact artifact : artifacts ) { final ArtifactType dto = DtoUtils.createDto( artifact ); @@ -127,7 +104,7 @@ public static BuildInfoType.AttachedArtifacts createAttachedArtifacts( List mojos, Logger logger private boolean hasCompletedExecution( String mojoExecutionKey ) { - final List completedExecutions = dto.getExecutions().getExecution(); - for ( CompletedExecutionType completedExecution : completedExecutions ) + final List completedExecutions = dto.getExecutions(); + if ( dto.getExecutions() != null ) { - if ( StringUtils.equals( completedExecution.getExecutionKey(), mojoExecutionKey ) ) + for ( CompletedExecutionType completedExecution : completedExecutions ) { - return true; + if ( StringUtils.equals( completedExecution.getExecutionKey(), mojoExecutionKey ) ) + { + return true; + } } } return false; @@ -168,12 +148,12 @@ public String toString() public CompletedExecutionType findMojoExecutionInfo( MojoExecution mojoExecution ) { - if ( !dto.isSetExecutions() ) + if ( dto.getExecutions() == null ) { return null; } - final List executions = dto.getExecutions().getExecution(); + final List executions = dto.getExecutions(); for ( CompletedExecutionType execution : executions ) { if ( StringUtils.equals( execution.getExecutionKey(), mojoExecutionKey( mojoExecution ) ) ) @@ -196,9 +176,9 @@ public ArtifactType getArtifact() public List getAttachedArtifacts() { - if ( dto.isSetAttachedArtifacts() ) + if ( dto.getAttachedArtifacts() != null ) { - return dto.getAttachedArtifacts().getArtifact(); + return dto.getAttachedArtifacts(); } return Collections.emptyList(); } @@ -210,7 +190,7 @@ public BuildInfoType getDto() public String getHighestCompletedGoal() { - return Iterables.getLast( dto.getGoals().getGoal() ); + return Iterables.getLast( dto.getGoals() ); } public List getCachedSegment( List mojoExecutions ) diff --git a/maven-core/src/main/java/org/apache/maven/caching/xml/CacheConfig.java b/maven-core/src/main/java/org/apache/maven/caching/xml/CacheConfig.java index 2f5137d9a3ea..7d90cc1fea73 100644 --- a/maven-core/src/main/java/org/apache/maven/caching/xml/CacheConfig.java +++ b/maven-core/src/main/java/org/apache/maven/caching/xml/CacheConfig.java @@ -22,9 +22,10 @@ import org.apache.maven.caching.PluginScanConfig; import org.apache.maven.caching.checksum.MultimoduleDiscoveryStrategy; import org.apache.maven.caching.hash.HashFactory; -import org.apache.maven.caching.jaxb.PathSetType; -import org.apache.maven.caching.jaxb.PropertyNameType; -import org.apache.maven.caching.jaxb.TrackedPropertyType; +import org.apache.maven.caching.xml.config.Exclude; +import org.apache.maven.caching.xml.config.Include; +import org.apache.maven.caching.xml.config.PropertyNameType; +import org.apache.maven.caching.xml.config.TrackedPropertyType; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginExecution; @@ -62,10 +63,10 @@ public interface CacheConfig String getDefaultGlob(); @Nonnull - List getGlobalIncludePaths(); + List getGlobalIncludePaths(); @Nonnull - List getGlobalExcludePaths(); + List getGlobalExcludePaths(); @Nonnull PluginScanConfig getPluginDirScanConfig( Plugin plugin ); diff --git a/maven-core/src/main/java/org/apache/maven/caching/xml/CacheConfigImpl.java b/maven-core/src/main/java/org/apache/maven/caching/xml/CacheConfigImpl.java index 9dd0e85f578f..398ef511dd0a 100644 --- a/maven-core/src/main/java/org/apache/maven/caching/xml/CacheConfigImpl.java +++ b/maven-core/src/main/java/org/apache/maven/caching/xml/CacheConfigImpl.java @@ -27,20 +27,25 @@ import org.apache.maven.caching.PluginScanConfigImpl; import org.apache.maven.caching.checksum.MultimoduleDiscoveryStrategy; import org.apache.maven.caching.hash.HashFactory; -import org.apache.maven.caching.jaxb.CacheType; -import org.apache.maven.caching.jaxb.ConfigurationType; -import org.apache.maven.caching.jaxb.CoordinatesBaseType; -import org.apache.maven.caching.jaxb.ExecutablesType; -import org.apache.maven.caching.jaxb.ExecutionConfigurationScanType; -import org.apache.maven.caching.jaxb.ExecutionControlType; -import org.apache.maven.caching.jaxb.ExecutionIdsListType; -import org.apache.maven.caching.jaxb.GoalReconciliationType; -import org.apache.maven.caching.jaxb.GoalsListType; -import org.apache.maven.caching.jaxb.PathSetType; -import org.apache.maven.caching.jaxb.PluginConfigurationScanType; -import org.apache.maven.caching.jaxb.PluginSetType; -import org.apache.maven.caching.jaxb.PropertyNameType; -import org.apache.maven.caching.jaxb.TrackedPropertyType; +import org.apache.maven.caching.xml.config.AttachedOutputs; +import org.apache.maven.caching.xml.config.Exclude; +import org.apache.maven.caching.xml.config.Include; +import org.apache.maven.caching.xml.config.Local; +import org.apache.maven.caching.xml.config.ProjectDiscoveryStrategy; +import org.apache.maven.caching.xml.config.Remote; +import org.apache.maven.caching.xml.config.CacheType; +import org.apache.maven.caching.xml.config.ConfigurationType; +import org.apache.maven.caching.xml.config.CoordinatesBaseType; +import org.apache.maven.caching.xml.config.ExecutablesType; +import org.apache.maven.caching.xml.config.ExecutionConfigurationScanType; +import org.apache.maven.caching.xml.config.ExecutionControlType; +import org.apache.maven.caching.xml.config.ExecutionIdsListType; +import org.apache.maven.caching.xml.config.GoalReconciliationType; +import org.apache.maven.caching.xml.config.GoalsListType; +import org.apache.maven.caching.xml.config.PluginConfigurationScanType; +import org.apache.maven.caching.xml.config.PluginSetType; +import org.apache.maven.caching.xml.config.PropertyNameType; +import org.apache.maven.caching.xml.config.TrackedPropertyType; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginExecution; @@ -186,7 +191,7 @@ public List getTrackedProperties( MojoExecution mojoExecuti final GoalReconciliationType reconciliationConfig = findReconciliationConfig( mojoExecution ); if ( reconciliationConfig != null ) { - return reconciliationConfig.getReconcile(); + return reconciliationConfig.getReconciles(); } else { @@ -202,25 +207,25 @@ public boolean isLogAllProperties( MojoExecution mojoExecution ) { return true; } - return cacheConfig.isSetExecutionControl() && cacheConfig.getExecutionControl().isSetReconcile() + return cacheConfig.getExecutionControl() != null && cacheConfig.getExecutionControl().getReconcile() != null && cacheConfig.getExecutionControl().getReconcile().isLogAllProperties(); } private GoalReconciliationType findReconciliationConfig( MojoExecution mojoExecution ) { - if ( !cacheConfig.isSetExecutionControl() ) + if ( cacheConfig.getExecutionControl() == null ) { return null; } final ExecutionControlType executionControl = cacheConfig.getExecutionControl(); - if ( !executionControl.isSetReconcile() ) + if ( executionControl.getReconcile() == null ) { return null; } - final List reconciliation = executionControl.getReconcile().getPlugin(); + final List reconciliation = executionControl.getReconcile().getPlugins(); for ( GoalReconciliationType goalReconciliationConfig : reconciliation ) { @@ -245,7 +250,7 @@ public List getLoggedProperties( MojoExecution mojoExecution ) final GoalReconciliationType reconciliationConfig = findReconciliationConfig( mojoExecution ); if ( reconciliationConfig != null ) { - return reconciliationConfig.getLog(); + return reconciliationConfig.getLogs(); } else { @@ -261,7 +266,7 @@ public List getNologProperties( MojoExecution mojoExecution ) final GoalReconciliationType reconciliationConfig = findReconciliationConfig( mojoExecution ); if ( reconciliationConfig != null ) { - return reconciliationConfig.getNolog(); + return reconciliationConfig.getNologs(); } else { @@ -276,9 +281,9 @@ public List getEffectivePomExcludeProperties( Plugin plugin ) checkInitializedState(); final PluginConfigurationScanType pluginConfig = findPluginScanConfig( plugin ); - if ( pluginConfig != null && pluginConfig.isSetEffectivePom() ) + if ( pluginConfig != null && pluginConfig.getEffectivePom() != null ) { - return pluginConfig.getEffectivePom().getExcludeProperty(); + return pluginConfig.getEffectivePom().getExcludeProperties(); } return Collections.emptyList(); } @@ -286,12 +291,12 @@ public List getEffectivePomExcludeProperties( Plugin plugin ) private PluginConfigurationScanType findPluginScanConfig( Plugin plugin ) { - if ( !cacheConfig.isSetInput() ) + if ( cacheConfig.getInput() == null ) { return null; } - final List pluginConfigs = cacheConfig.getInput().getPlugin(); + final List pluginConfigs = cacheConfig.getInput().getPlugins(); for ( PluginConfigurationScanType pluginConfig : pluginConfigs ) { if ( isPluginMatch( plugin, pluginConfig ) ) @@ -305,7 +310,7 @@ private PluginConfigurationScanType findPluginScanConfig( Plugin plugin ) private boolean isPluginMatch( Plugin plugin, CoordinatesBaseType pluginConfig ) { return StringUtils.equals( pluginConfig.getArtifactId(), - plugin.getArtifactId() ) && ( !pluginConfig.isSetGroupId() || StringUtils.equals( + plugin.getArtifactId() ) && ( pluginConfig.getGroupId() == null || StringUtils.equals( pluginConfig.getGroupId(), plugin.getGroupId() ) ); } @@ -316,7 +321,7 @@ public PluginScanConfig getPluginDirScanConfig( Plugin plugin ) { checkInitializedState(); final PluginConfigurationScanType pluginConfig = findPluginScanConfig( plugin ); - if ( pluginConfig == null || !pluginConfig.isSetDirScan() ) + if ( pluginConfig == null || pluginConfig.getDirScan() == null ) { return new DefaultPluginScanConfig(); } @@ -334,8 +339,8 @@ public PluginScanConfig getExecutionDirScanConfig( Plugin plugin, PluginExecutio if ( pluginScanConfig != null ) { final ExecutionConfigurationScanType executionScanConfig = findExecutionScanConfig( exec, - pluginScanConfig.getExecution() ); - if ( executionScanConfig != null && executionScanConfig.isSetDirScan() ) + pluginScanConfig.getExecutions() ); + if ( executionScanConfig != null && executionScanConfig.getDirScan() != null ) { return new PluginScanConfigImpl( executionScanConfig.getDirScan() ); } @@ -349,7 +354,7 @@ private ExecutionConfigurationScanType findExecutionScanConfig( PluginExecution { for ( ExecutionConfigurationScanType executionScanConfig : scanConfigs ) { - if ( executionScanConfig.getExecId().contains( execution.getId() ) ) + if ( executionScanConfig.getExecIds().contains( execution.getId() ) ) { return executionScanConfig; } @@ -373,18 +378,18 @@ public String getDefaultGlob() @Nonnull @Override - public List getGlobalIncludePaths() + public List getGlobalIncludePaths() { checkInitializedState(); - return cacheConfig.getInput().getGlobal().getInclude(); + return cacheConfig.getInput().getGlobal().getIncludes(); } @Nonnull @Override - public List getGlobalExcludePaths() + public List getGlobalExcludePaths() { checkInitializedState(); - return cacheConfig.getInput().getGlobal().getExclude(); + return cacheConfig.getInput().getGlobal().getExcludes(); } @Nonnull @@ -392,9 +397,9 @@ public List getGlobalExcludePaths() public MultimoduleDiscoveryStrategy getMultimoduleDiscoveryStrategy() { checkInitializedState(); - final ConfigurationType.ProjectDiscoveryStrategy projectDiscoveryStrategy = + final ProjectDiscoveryStrategy projectDiscoveryStrategy = cacheConfig.getConfiguration().getProjectDiscoveryStrategy(); - if ( projectDiscoveryStrategy.isSetSpecificVersion() ) + if ( projectDiscoveryStrategy != null && projectDiscoveryStrategy.getSpecificVersion() != null ) { return new SentinelVersionStartegy( projectDiscoveryStrategy.getSpecificVersion() ); } @@ -413,7 +418,7 @@ public HashFactory getHashFactory() public boolean canIgnore( MojoExecution mojoExecution ) { checkInitializedState(); - if ( !cacheConfig.isSetExecutionControl() || !cacheConfig.getExecutionControl().isSetIgnoreMissing() ) + if ( cacheConfig.getExecutionControl() == null || cacheConfig.getExecutionControl().getIgnoreMissing() == null ) { return false; } @@ -425,7 +430,7 @@ public boolean canIgnore( MojoExecution mojoExecution ) public boolean isForcedExecution( MojoExecution execution ) { checkInitializedState(); - if ( !cacheConfig.isSetExecutionControl() || !cacheConfig.getExecutionControl().isSetRunAlways() ) + if ( cacheConfig.getExecutionControl() == null || cacheConfig.getExecutionControl().getRunAlways() == null ) { return false; } @@ -435,7 +440,7 @@ public boolean isForcedExecution( MojoExecution execution ) private boolean executionMatches( MojoExecution execution, ExecutablesType executablesType ) { - final List pluginConfigs = executablesType.getPlugin(); + final List pluginConfigs = executablesType.getPlugins(); for ( PluginSetType pluginConfig : pluginConfigs ) { if ( isPluginMatch( execution.getPlugin(), pluginConfig ) ) @@ -444,20 +449,20 @@ private boolean executionMatches( MojoExecution execution, ExecutablesType execu } } - final List executionIds = executablesType.getExecution(); + final List executionIds = executablesType.getExecutions(); for ( ExecutionIdsListType executionConfig : executionIds ) { - if ( isPluginMatch( execution.getPlugin(), executionConfig ) && executionConfig.getExecId().contains( + if ( isPluginMatch( execution.getPlugin(), executionConfig ) && executionConfig.getExecIds().contains( execution.getExecutionId() ) ) { return true; } } - final List pluginsGoalsList = executablesType.getGoals(); + final List pluginsGoalsList = executablesType.getGoalsLists(); for ( GoalsListType pluginGoals : pluginsGoalsList ) { - if ( isPluginMatch( execution.getPlugin(), pluginGoals ) && pluginGoals.getGoal().contains( + if ( isPluginMatch( execution.getPlugin(), pluginGoals ) && pluginGoals.getGoals().contains( execution.getGoal() ) ) { return true; @@ -524,15 +529,15 @@ public String getUrl() public int getMaxLocalBuildsCached() { checkInitializedState(); - return getLocal().getMaxBuildsCached().intValue(); + return getLocal().getMaxBuildsCached(); } @Override public List getAttachedOutputs() { checkInitializedState(); - final ConfigurationType.AttachedOutputs attachedOutputs = getConfiguration().getAttachedOutputs(); - return attachedOutputs == null ? Collections.emptyList() : attachedOutputs.getDirName(); + final AttachedOutputs attachedOutputs = getConfiguration().getAttachedOutputs(); + return attachedOutputs == null ? Collections.emptyList() : attachedOutputs.getDirNames(); } @Nonnull @@ -545,10 +550,10 @@ public List getExcludePatterns() private List compileExcludePatterns() { - if ( cacheConfig.isSetOutput() && cacheConfig.getOutput().isSetExclude() ) + if ( cacheConfig.getOutput() != null && cacheConfig.getOutput().getExclude() != null ) { List patterns = new ArrayList<>(); - for ( String pattern : cacheConfig.getOutput().getExclude().getPattern() ) + for ( String pattern : cacheConfig.getOutput().getExclude().getPatterns() ) { patterns.add( Pattern.compile( pattern ) ); } @@ -557,12 +562,12 @@ private List compileExcludePatterns() return Collections.emptyList(); } - private ConfigurationType.Remote getRemote() + private Remote getRemote() { return getConfiguration().getRemote(); } - private ConfigurationType.Local getLocal() + private Local getLocal() { return getConfiguration().getLocal(); } diff --git a/maven-core/src/main/java/org/apache/maven/caching/xml/DtoUtils.java b/maven-core/src/main/java/org/apache/maven/caching/xml/DtoUtils.java index a2810ab86824..d44ab3753584 100644 --- a/maven-core/src/main/java/org/apache/maven/caching/xml/DtoUtils.java +++ b/maven-core/src/main/java/org/apache/maven/caching/xml/DtoUtils.java @@ -23,14 +23,16 @@ import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.caching.ProjectUtils; -import org.apache.maven.caching.jaxb.ArtifactType; -import org.apache.maven.caching.jaxb.CompletedExecutionType; -import org.apache.maven.caching.jaxb.DigestItemType; -import org.apache.maven.caching.jaxb.PropertyValueType; -import org.apache.maven.caching.jaxb.TrackedPropertyType; +import org.apache.maven.caching.xml.buildinfo.ArtifactType; +import org.apache.maven.caching.xml.buildinfo.CompletedExecutionType; +import org.apache.maven.caching.xml.buildinfo.DigestItemType; +import org.apache.maven.caching.xml.buildinfo.PropertyValueType; +import org.apache.maven.caching.xml.config.TrackedPropertyType; import org.apache.maven.model.Dependency; import javax.annotation.Nonnull; + +import java.util.ArrayList; import java.util.List; import static org.apache.maven.caching.checksum.KeyUtils.getArtifactKey; @@ -43,12 +45,12 @@ public class DtoUtils public static String findPropertyValue( String propertyName, CompletedExecutionType completedExecution ) { - final CompletedExecutionType.Configuration configuration = completedExecution.getConfiguration(); + final List configuration = completedExecution.getConfiguration(); if ( configuration == null ) { return null; } - final List properties = configuration.getProperty(); + final List properties = configuration; for ( PropertyValueType property : properties ) { if ( StringUtils.equals( propertyName, property.getName() ) ) @@ -124,7 +126,7 @@ public static void addProperty( CompletedExecutionType execution, { if ( execution.getConfiguration() == null ) { - execution.setConfiguration( new CompletedExecutionType.Configuration() ); + execution.setConfiguration( new ArrayList<>() ); } final PropertyValueType valueType = new PropertyValueType(); valueType.setName( propertyName ); @@ -135,7 +137,7 @@ public static void addProperty( CompletedExecutionType execution, final String valueText = String.valueOf( value ); valueType.setValue( StringUtils.remove( valueText, baseDirPath ) ); valueType.setTracked( tracked ); - execution.getConfiguration().getProperty().add( valueType ); + execution.getConfiguration().add( valueType ); } public static boolean containsAllProperties( @@ -147,12 +149,12 @@ public static boolean containsAllProperties( return true; } - if ( !cachedExecution.isSetConfiguration() ) + if ( cachedExecution.getConfiguration() == null ) { return false; } - final List executionProperties = cachedExecution.getConfiguration().getProperty(); + final List executionProperties = cachedExecution.getConfiguration(); for ( TrackedPropertyType trackedProperty : trackedProperties ) { if ( !contains( executionProperties, trackedProperty.getPropertyName() ) ) @@ -178,42 +180,15 @@ public static boolean contains( List executionProperties, Str public static ArtifactType copy( ArtifactType artifact ) { ArtifactType copy = new ArtifactType(); - if ( artifact.isSetArtifactId() ) - { - copy.setArtifactId( artifact.getArtifactId() ); - } - if ( artifact.isSetGroupId() ) - { - copy.setGroupId( artifact.getGroupId() ); - } - if ( artifact.isSetVersion() ) - { - copy.setVersion( artifact.getVersion() ); - } - if ( artifact.isSetType() ) - { - copy.setType( artifact.getType() ); - } - if ( artifact.isSetClassifier() ) - { - copy.setClassifier( artifact.getClassifier() ); - } - if ( artifact.isSetScope() ) - { - copy.setScope( artifact.getScope() ); - } - if ( artifact.isSetFileName() ) - { - copy.setFileName( artifact.getFileName() ); - } - if ( artifact.isSetFileHash() ) - { - copy.setFileHash( artifact.getFileHash() ); - } - if ( artifact.isSetFileSize() ) - { - copy.setFileSize( artifact.getFileSize() ); - } + copy.setArtifactId( artifact.getArtifactId() ); + copy.setGroupId( artifact.getGroupId() ); + copy.setVersion( artifact.getVersion() ); + copy.setType( artifact.getType() ); + copy.setClassifier( artifact.getClassifier() ); + copy.setScope( artifact.getScope() ); + copy.setFileName( artifact.getFileName() ); + copy.setFileHash( artifact.getFileHash() ); + copy.setFileSize( artifact.getFileSize() ); return copy; } } diff --git a/maven-core/src/main/java/org/apache/maven/caching/xml/XmlService.java b/maven-core/src/main/java/org/apache/maven/caching/xml/XmlService.java index 658c9d0dd3b1..44bd917cc7da 100644 --- a/maven-core/src/main/java/org/apache/maven/caching/xml/XmlService.java +++ b/maven-core/src/main/java/org/apache/maven/caching/xml/XmlService.java @@ -19,27 +19,27 @@ * under the License. */ -import org.apache.maven.caching.jaxb.BuildDiffType; -import org.apache.maven.caching.jaxb.BuildInfoType; -import org.apache.maven.caching.jaxb.CacheReportType; -import org.apache.maven.caching.jaxb.ObjectFactory; +import org.apache.maven.caching.xml.config.CacheType; +import org.apache.maven.caching.xml.config.io.xpp3.CacheConfigXpp3Reader; +import org.apache.maven.caching.xml.config.io.xpp3.CacheConfigXpp3Writer; +import org.apache.maven.caching.xml.buildinfo.BuildInfoType; +import org.apache.maven.caching.xml.buildinfo.io.xpp3.CacheBuildInfoXpp3Reader; +import org.apache.maven.caching.xml.buildinfo.io.xpp3.CacheBuildInfoXpp3Writer; +import org.apache.maven.caching.xml.buildsdiff.BuildDiffType; +import org.apache.maven.caching.xml.buildsdiff.io.xpp3.CacheBuildsDiffXpp3Reader; +import org.apache.maven.caching.xml.buildsdiff.io.xpp3.CacheBuildsDiffXpp3Writer; +import org.apache.maven.caching.xml.report.CacheReportType; +import org.apache.maven.caching.xml.report.io.xpp3.CacheReportXpp3Reader; +import org.apache.maven.caching.xml.report.io.xpp3.CacheReportXpp3Writer; import org.codehaus.plexus.component.annotations.Component; -import org.xml.sax.SAXException; +import org.codehaus.plexus.util.xml.pull.XmlPullParserException; -import javax.xml.XMLConstants; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; -import javax.xml.bind.Unmarshaller; -import javax.xml.transform.Source; -import javax.xml.transform.stream.StreamSource; -import javax.xml.validation.Schema; -import javax.xml.validation.SchemaFactory; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; +import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; /** * XmlService @@ -48,98 +48,80 @@ public class XmlService { - private final ObjectFactory objectFactory; - private final JAXBContext jaxbContext; - private final Schema schema; - - public XmlService() throws JAXBException, SAXException - { - objectFactory = new ObjectFactory(); - jaxbContext = JAXBContext.newInstance( "org.apache.maven.caching.jaxb", XmlService.class.getClassLoader() ); - - SchemaFactory sf = SchemaFactory.newInstance( XMLConstants.W3C_XML_SCHEMA_NS_URI ); - final InputStream domainSchemaStream = getResourceAsStream( "cache-domain.xsd" ); - final Source domainSchema = new StreamSource( domainSchemaStream ); - final InputStream configSchemaStream = getResourceAsStream( "cache-config.xsd" ); - final Source configSchema = new StreamSource( configSchemaStream ); - schema = sf.newSchema( new Source[] {domainSchema, configSchema} ); - } - - public byte[] toBytes( BuildInfoType buildInfo ) - { - return serializeXml( objectFactory.createBuild( buildInfo ) ); - } - - public byte[] toBytes( BuildDiffType diff ) + public byte[] toBytes( CacheType cache ) throws IOException { - return serializeXml( objectFactory.createDiff( diff ) ); + try ( ByteArrayOutputStream baos = new ByteArrayOutputStream() ) + { + new CacheConfigXpp3Writer().write( baos, cache ); + return baos.toByteArray(); + } } - public byte[] toBytes( CacheReportType cacheReportType ) + public byte[] toBytes( BuildInfoType buildInfo ) throws IOException { - - return serializeXml( objectFactory.createReport( cacheReportType ) ); + try ( ByteArrayOutputStream baos = new ByteArrayOutputStream() ) + { + new CacheBuildInfoXpp3Writer().write( baos, buildInfo ); + return baos.toByteArray(); + } } - private byte[] serializeXml( JAXBElement element ) + public byte[] toBytes( BuildDiffType diff ) throws IOException { - try + try ( ByteArrayOutputStream baos = new ByteArrayOutputStream() ) { - Marshaller jaxbMarshaller = jaxbContext.createMarshaller(); - jaxbMarshaller.setSchema( schema ); - // output pretty printed - jaxbMarshaller.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, true ); - jaxbMarshaller.setProperty( Marshaller.JAXB_ENCODING, "UTF-8" ); - final ByteArrayOutputStream baos = new ByteArrayOutputStream(); - jaxbMarshaller.marshal( element, baos ); + new CacheBuildsDiffXpp3Writer().write( baos, diff ); return baos.toByteArray(); } - catch ( Exception e ) - { - throw new RuntimeException( "Errors in jaxb serialization: " + e.toString(), e ); - } } - public T fromFile( Class clazz, File file ) + public byte[] toBytes( CacheReportType cacheReportType ) throws IOException { - - try - { - Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); - unmarshaller.setSchema( schema ); - JAXBElement result = (JAXBElement) unmarshaller.unmarshal( file ); - return result.getValue(); - } - catch ( Exception e ) + try ( ByteArrayOutputStream baos = new ByteArrayOutputStream() ) { - throw new RuntimeException( "Errors in jaxb serialization: " + e.toString(), e ); + new CacheReportXpp3Writer().write( baos, cacheReportType ); + return baos.toByteArray(); } } - public static InputStream getResourceAsStream( String name ) + public T fromFile( Class clazz, File file ) throws IOException, XmlPullParserException { - ClassLoader cl = XmlService.class.getClassLoader(); - if ( cl == null ) - { - // A system class. - return ClassLoader.getSystemResourceAsStream( name ); - } - return cl.getResourceAsStream( name ); + return fromInputStream( clazz, Files.newInputStream( file.toPath() ) ); } public T fromBytes( Class clazz, byte[] bytes ) + { + return fromInputStream( clazz, new ByteArrayInputStream( bytes ) ); + } + + public T fromInputStream( Class clazz, InputStream inputStream ) { try { - Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); - unmarshaller.setSchema( schema ); - JAXBElement result = (JAXBElement) unmarshaller.unmarshal( new ByteArrayInputStream( bytes ) ); - return result.getValue(); - + if ( clazz == BuildInfoType.class ) + { + return clazz.cast( new CacheBuildInfoXpp3Reader().read( inputStream ) ); + } + else if ( clazz == CacheType.class ) + { + return clazz.cast( new CacheConfigXpp3Reader().read( inputStream ) ); + } + else if ( clazz == BuildDiffType.class ) + { + return clazz.cast( new CacheBuildsDiffXpp3Reader().read( inputStream ) ); + } + else if ( clazz == CacheReportType.class ) + { + return clazz.cast( new CacheReportXpp3Reader().read( inputStream ) ); + } + else + { + throw new IllegalArgumentException( "Unsupported type " + clazz ); + } } - catch ( Exception e ) + catch ( IOException | XmlPullParserException e ) { - throw new RuntimeException( "Errors in jaxb serialization: " + e.toString(), e ); + throw new RuntimeException( "Unable to parse cache xml element", e ); } } } diff --git a/maven-core/src/main/mdo/cache-buildinfo.mdo b/maven-core/src/main/mdo/cache-buildinfo.mdo new file mode 100644 index 000000000000..0659d76256d1 --- /dev/null +++ b/maven-core/src/main/mdo/cache-buildinfo.mdo @@ -0,0 +1,385 @@ + + + + cache-buildinfo + CacheBuildInfo + lookupinfo.xml or remote buildinfo.xml + ]]> + + + package + org.apache.maven.caching.xml.buildinfo + + + + + + BuildInfoType + 1.0.0+ + + + + + + cacheImplementationVersion + 1.0.0+ + String + + + + _final + 1.0.0+ + Boolean + final + + + + hashFunction + 1.0.0+ + String + + + + buildTime + 1.0.0+ + Date + + + + buildServer + 1.0.0+ + String + + + + scm + 1.0.0+ + + Scm + + + + + goals + 1.0.0+ + + String + * + + + + + + artifact + 1.0.0+ + + ArtifactType + + + + + + attachedArtifacts + + ArtifactType + * + + + + + + executions + + CompletedExecutionType + * + + + + + projectsInputInfo + + ProjectsInputInfoType + + + + + + + + Scm + + + sourceBranch + String + + + revision + String + + + + + + + ArtifactType + + + + + groupId + String + + + + artifactId + String + + + + version + String + + + + classifier + String + + + + type + String + + + + scope + String + + + + fileName + String + + + + fileHash + String + + + + + fileSize + long + + + + + + + + + CompletedExecutionType + + + executionKey + String + + + mojoClassName + String + + + configuration + + PropertyValueType + * + + + + + + + + + PropertyValueType + + + value + String + + + name + String + + + tracked + Boolean + + + + + + + + ProjectsInputInfoType + + + checksum + String + + + item + + DigestItemType + * + + + + + + + + + DigestItemType + + + value + String + + + type + String + + + hash + String + + + fileChecksum + String + + + content + String + + + isText + String + + + charset + String + + + eol + String + + + + + + diff --git a/maven-core/src/main/mdo/cache-buildsdiff.mdo b/maven-core/src/main/mdo/cache-buildsdiff.mdo new file mode 100644 index 000000000000..45bdfe1d0a8d --- /dev/null +++ b/maven-core/src/main/mdo/cache-buildsdiff.mdo @@ -0,0 +1,109 @@ + + + + cache-buildsdiff + CacheBuildsDiff + buildsdiff-${checksum}.xml + ]]> + + + package + org.apache.maven.caching.xml.buildsdiff + + + + + + + + BuildDiffType + + + mismatch + + MismatchType + * + + + + + + + + + MismatchType + + + detail + + MismatchDetailType + * + + + + item + String + + + current + String + + + baseline + String + + + reason + String + + + resolution + String + + + context + String + + + + + + + MismatchDetailType + + + + diff --git a/maven-core/src/main/mdo/cache-config.mdo b/maven-core/src/main/mdo/cache-config.mdo new file mode 100644 index 000000000000..a9e9f92bf208 --- /dev/null +++ b/maven-core/src/main/mdo/cache-config.mdo @@ -0,0 +1,1401 @@ + + + + cache-config + CacheConfig + .mvn/maven-cache-config.xml + ]]> + + + + package + org.apache.maven.caching.xml.config + + + + + + + + CacheType + + + configuration + + ConfigurationType + + + + input + + InputType + + + + output + + OutputType + + + + executionControl + + ExecutionControlType + + + + + + + + Remote + + + url + String + address of remote cache + + + enabled + boolean + true + + + saveToRemote + boolean + false + Save output to remote cache. Recommended to enable on CI agents only. + + + + + + + ConfigurationType + + + enabled + boolean + + + hashAlgorithm + String + One of XX, XXMM, SHA-1, SHA-256, SHA-384, SHA-512 + + + validateXml + boolean + true + Validate cache config and builds metadata against xsd. + + + projectDiscoveryStrategy + + ProjectDiscoveryStrategy + + Specifies how to identify belonging to a cached project then submodule is being build. + + + remote + + Remote + + + + attachedOutputs + + AttachedOutputs + + + + local + + Local + + + + debugs + + String + * + + FileHash (causes file hash is saved in build metadata) or + EffectivePom (causes effective pom info is saved in build metadata) + + + + + + + ProjectDiscoveryStrategy + + + specificVersion + String + + Any project dependency this this version will be considered cache eligible and will + be processed cache aware + + + + + + + + AttachedOutputs + + + dirNames + + String + * + + Directory name in build output directory to attach to cached artifacts + + + + + + + Local + + + maxBuildsCached + int + 3 + Maximum number of cached build per artifact in local cache. First created cache (the + oldest) is evicted if breached. + + + + + + + InputType + + + global + + PathSetType + + Global input calculation rules applicable to all projects and plugins in the build + + + plugins + + PluginConfigurationScanType + * + + Plugin specific input calculation rules + + + + + + + PluginConfigurationScanType + CoordinatesBaseType + + + effectivePom + + EffectivePom + + Effective pom calculation rules + + + dirScan + + DirScanConfigType + + Specifies plugin level rules of configuration processing in search of referenced source files + + + executions + + ExecutionConfigurationScanType + * + + Specifies execution specific configuration processing in search of referenced source files + + + + + + + EffectivePom + + + excludeProperties + + String + * + + Plugin configuration property should be excluded from effective pom calculation + + + + + + + ExecutionConfigurationScanType + + + execIds + + String + * + + + + dirScan + + DirScanConfigType + + Specifies rules of configuration processing in search of referenced source files + + + ignoreParentConfig + boolean + ignore parent config or inherit/merge + + + + + + + TagScanConfigType + TagNameType + + + recursive + boolean + true + + + glob + String + * + + + + + + + DirScanConfigType + + + includes + + TagScanConfigType + * + + Forces cache to treat property value as input and include in calculation. If set, only included + properties will be takein in calculation (whitelist) + + + excludes + + TagNameType + * + + Tag to exclude when scanning plugin configuration for input files (blacklist) + + + tagScanConfigs + + TagScanConfigType + * + + Additional processing rules for non-blacklisted tags + + + ignoreParent + boolean + false + Ignore parent settings or inherit and merge + + + mode + String + + Either 'auto' (scan directory accordingly to cache implementation) or 'skip' (skip directory). + + + + + + + + OutputType + + + exclude + + OutputTypeExclude + + Patterns to exclude output artifacts applicable to all projects in the build + + + + + + OutputTypeExclude + + + patterns + + String + * + + + + + + + + PathSetType + + + glob + String + * + + + includes + + Include + * + + + + excludes + + Exclude + * + + + + + + Exclude + + + value + String + + + + + Include + + + value + String + + + recursive + boolean + true + + + glob + String + * + + + + + + + + + + GoalReconciliationType + GoalIdType + + + reconciles + + TrackedPropertyType + * + + + + logs + + PropertyNameType + * + + Specify property which should be logged to build metadata for exploration + + + nologs + + PropertyNameType + * + + Specify property which should not be logged + + + logAll + boolean + true + Controls if all plugin properties to be logged (true is default). All the properties logged + with respect to log/nolog children: + * true: logged all if no blacklists (<nolog/>) and whitelists (<log/>) specified on plugin + level + * false: logged only tracked and included by whitelists (<log/>) on plugin level + + + + + + + + + ExecutionControlType + + + runAlways + + ExecutablesType + + Specify which plugin should run always if present in build regardless of cached status + + + ignoreMissing + + ExecutablesType + + + Specify which executions/plugins/goals do not affect generated artifacts and do not affect build correctness. + If cached build lacks of ignorable executions only, it still could be reused. + Typically case is then cached build is produced with 'verify' and you locally you run 'install'. + Strictly speaking these are different builds but in most of cases you want this difference to be ignored + + + + reconcile + + Reconcile + + Specify which plugin should run always if present in build regardless of cached status + + + + + + + + Reconcile + + + plugins + + GoalReconciliationType + * + + Reconciliation rules for plugin properties which might be affected by command line flags, etc + + + logAllProperties + boolean + true + + Controls if all plugin properties to be logged (true is default). All the properties + logged with respect to children: + * logAll on plugin level overrides global value + * true: logged all if no blacklists (<nolog/>) and whitelists (<log/>) specified on + plugin level + * false: logged only tracked and included by whitelists (<log/>) on plugin level + <log/> + + + + + + + + + ExecutablesType + + + plugins + + PluginSetType + * + + Specify which executions should run always if present in build regardless of cached status + + + executions + + ExecutionIdsListType + * + + Specify which executions should run always if present in build regardless of cached status + + + goalsLists + + GoalsListType + * + + Specify which goals should run always if present in build regardless of cached status + + + + + + + + GoalsListType + CoordinatesBaseType + + + goals + + String + * + + Goals identification + + + + + + + + GoalIdType + CoordinatesBaseType + + + goal + String + true + + + + + + + + ExecutionIdsListType + CoordinatesBaseType + + + execIds + + String + * + + Executions ids list with plugin identifier + + + + + + + + PluginSetType + CoordinatesBaseType + + + + + + CoordinatesBaseType + + + groupId + String + + + artifactId + String + + + + + + + + TagNameType + + + tagName + String + true + + + + + + + + PropertyNameType + + + value + String + + + propertyName + String + + + + + + + + TrackedPropertyType + + + value + String + + + propertyName + String + + + skipValue + String + + + defaultValue + String + + + + + + + + diff --git a/maven-core/src/main/mdo/cache-report.mdo b/maven-core/src/main/mdo/cache-report.mdo new file mode 100644 index 000000000000..fed8d24f5472 --- /dev/null +++ b/maven-core/src/main/mdo/cache-report.mdo @@ -0,0 +1,108 @@ + + + + cache-report + CacheReport + cache-report.xml + ]]> + + + package + org.apache.maven.caching.xml.report + + + + + + CacheReportType + + + project + + ProjectReportType + * + + + + + + + + + + + + + + ProjectReportType + + + groupId + String + + + artifactId + String + + + checksum + String + + + checksumMatched + Boolean + + + lifecycleMatched + Boolean + + + pluginsMatched + Boolean + + + source + String + + + sharedToRemote + Boolean + + + url + String + + + + + + diff --git a/maven-core/src/main/resources/cache-config-instance.xml b/maven-core/src/main/resources/cache-config-instance.xml deleted file mode 100644 index 68555927800a..000000000000 --- a/maven-core/src/main/resources/cache-config-instance.xml +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - - true - SHA-256 - true - - http://host:port - - - 3 - - - - - - - {*.java,*.groovy,*.yaml,*.svcd,*.proto,*assembly.xml,assembly*.xml,*logback.xml,*.vm,*.ini,*.jks,*.properties,*.sh,*.bat} - - src/ - pom.xml - - - - 111 - - - - - - - - 1 - 2 - - - - - - - - - .*-processes.*\.zip - - - - - - - aaa - - - install - - - deploy - - - deploy-local - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/maven-core/src/main/resources/cache-config.xsd b/maven-core/src/main/resources/cache-config.xsd deleted file mode 100644 index 69437d993300..000000000000 --- a/maven-core/src/main/resources/cache-config.xsd +++ /dev/null @@ -1,640 +0,0 @@ - - - - - - - - - - - - - - - - - - - Cached build metadata - - - - - - - - - - Configuration of major cache properties - - - - - - - Configuration for source code input files participating in checksum calculation - - - - - - - Configuration for output artifacts, it's needed if you want to explicitly include/exclude something from caching - - - - - - - Execution rules for plugins in cached mode. Defines which plugins should run always - - - - - - - - - - - - - - - - 64 bit XX family hashing. Fast, but higher probability of collisions - - - - - - - 64 bit XX family hashing, with usage of Memory Mapped Buffer - - - - - - - - - - - - - - Validate cache config and builds metadata against xsd. - - - - - - - Specifies how to identify belonging to a cached project then submodule is being build. - - - - - - - - Any project dependency this this version will be considered cache eligible and will - be processed cache aware - - - - - - - - - - - - - address of remote cache - - - - - - - - - Save output to remote cache. Recommended to enable on CI agents only. - - - - - - - - - - - - Directory name in build output directory to attach to cached artifacts - - - - - - - - - - - - - Maximum number of cached build per artifact in local cache. First created cache (the - oldest) is - evicted if breached. - - - - - - - - - - - - - Causes file hash is saved in build metadata - - - - - - - Causes effective pom info is saved in build metadata - - - - - - - - - - - - - - - Global input calculation rules applicable to all projects and plugins in the build - - - - - - - Plugin specific input calculation rules - - - - - - - - - - - - - - Effective pom calculation rules - - - - - - - - Plugin configuration property should be excluded from effective pom - calculation - - - - - - - - - - Specifies plugin level rules of configuration processing in search of referenced source - files - - - - - - - Specifies execution specific configuration processing in search of referenced source - files - - - - - - - - - - - - - - - Specifies rules of configuration processing in search of referenced source files - - - - - - - - ignore parent config or inherit/merge - - - - - - - - - Common attributes for scanning paths - - - - - - Should walk directory specified in property recursively or not - - - - - - - Glob to apply when scanning dir denoted by this property - - - - - - - - - - - - - - - - - - - Forces cache to treat property value as input and include in calculation. If set, only included - properties will be takein in calculation (whitelist) - - - - - - - - Tag to exclude when scanning plugin configuration for input files (blacklist) - - - - - - - Additional processing rules for non-blacklisted tags - - - - - - - - - - Ignore parent settings or inherit and merge - - - - - - - - - - - Scan directory accordingly to cache implementation - - - - - - - Skip directory - - - - - - - - - - - - - - Patterns to exclude output artifacts applicable to all projects in the build - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Specify property which should be reconciled against running build - - - - - - - Specify property which should be logged to build metadata for exploration - - - - - - - Specify property which should not be logged - - - - - - - - Controls if all plugin properties to be logged (true is default). All the properties logged - with respect to log/nolog children: - * true: logged all if no blacklists () and whitelists () specified on plugin - level - * false: logged only tracked and included by whitelists () on plugin level - - - - - - - - - - - - - Specify which plugin should run always if present in build regardless of cached status - - - - - - - Specify which executions/plugins/goals do not affect generated artifacts and do not affect build correctness. - If cached build lacks of ignorable executions only, it still could be reused. - Typically case is then cached build is produced with 'verify' and you locally you run 'install'. - Strictly speaking these are different builds but in most of cases you want this difference to be ignored - - - - - - - Specify which plugin should run always if present in build regardless of cached status - - - - - - - - Reconciliation rules for plugin properties which might be affected by command line - flags, etc - - - - - - - - Controls if all plugin properties to be logged (true is default). All the properties - logged with respect to children: - * logAll on plugin level overrides global value - * true: logged all if no blacklists () and whitelists () specified on - plugin level - * false: logged only tracked and included by whitelists () on plugin level - - - - - - - - - - - - - - - Specify which plugin should run always if present in build regardless of cached status - - - - - - - Specify which executions should run always if present in build regardless of cached status - - - - - - - Specify which goals should run always if present in build regardless of cached status - - - - - - - - - - - - - - Goals identification - - - - - - - - - - - - - - - - - - - - - - - - - Executions ids list with plugin identifier - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Specify which value denotes skipped execution in plugin config. - If active build skips execution (property set to skipValue) cache will allow such - discrepancy. - - - - - - - Manual value for reconciliation. Required to reconcile runtime only properties - - - - - - - - diff --git a/maven-core/src/main/resources/cache-domain.xsd b/maven-core/src/main/resources/cache-domain.xsd deleted file mode 100644 index c233ed46e463..000000000000 --- a/maven-core/src/main/resources/cache-domain.xsd +++ /dev/null @@ -1,187 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/maven-core/src/test/java/org/apache/maven/caching/BuildInfoTest.java b/maven-core/src/test/java/org/apache/maven/caching/BuildInfoTest.java index 6c9b14c418aa..e05516884877 100644 --- a/maven-core/src/test/java/org/apache/maven/caching/BuildInfoTest.java +++ b/maven-core/src/test/java/org/apache/maven/caching/BuildInfoTest.java @@ -19,35 +19,34 @@ * under the License. */ - import com.google.common.collect.Lists; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.handler.DefaultArtifactHandler; import org.apache.maven.caching.hash.HashFactory; -import org.apache.maven.caching.jaxb.ArtifactType; -import org.apache.maven.caching.jaxb.BuildInfoType; -import org.apache.maven.caching.jaxb.CompletedExecutionType; -import org.apache.maven.caching.jaxb.DigestItemType; -import org.apache.maven.caching.jaxb.ProjectsInputInfoType; -import org.apache.maven.caching.jaxb.PropertyValueType; +import org.apache.maven.caching.xml.buildinfo.ArtifactType; +import org.apache.maven.caching.xml.buildinfo.BuildInfoType; +import org.apache.maven.caching.xml.buildinfo.CompletedExecutionType; +import org.apache.maven.caching.xml.buildinfo.DigestItemType; +import org.apache.maven.caching.xml.buildinfo.ProjectsInputInfoType; +import org.apache.maven.caching.xml.buildinfo.PropertyValueType; import org.apache.maven.caching.xml.BuildInfo; import org.apache.maven.caching.xml.XmlService; +import org.junit.Test; -import javax.xml.datatype.DatatypeFactory; import java.io.File; -import java.math.BigInteger; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.GregorianCalendar; - -import static org.apache.maven.caching.xml.BuildInfo.createGoals; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.List; public class BuildInfoTest { - // @Test + @Test public void name() throws Exception { XmlService xmlService = new XmlService(); @@ -64,16 +63,16 @@ public void name() throws Exception { artifact.setClassifier("c"); artifact.setScope("s"); artifact.setFileName("f"); - artifact.setFileSize(BigInteger.valueOf(123456)); + artifact.setFileSize(123456); artifact.setFileHash("456L"); BuildInfoType buildInfo = new BuildInfoType(); buildInfo.setCacheImplementationVersion("cacheImplementationVersion"); buildInfo.setBuildServer("server"); - buildInfo.setBuildTime(DatatypeFactory.newInstance().newXMLGregorianCalendar(new GregorianCalendar())); + buildInfo.setBuildTime(new Date()); buildInfo.setArtifact(artifact); buildInfo.setHashFunction("SHA-256"); - buildInfo.setGoals(createGoals(Lists.newArrayList("install"))); + buildInfo.setGoals(Lists.newArrayList("install")); final Artifact attachedArtifact = new DefaultArtifact("ag", "aa", "av", "as", "at", "ac", new DefaultArtifactHandler()); buildInfo.setAttachedArtifacts(BuildInfo.createAttachedArtifacts(Lists.newArrayList(attachedArtifact), HashFactory.XX.createAlgorithm())); buildInfo.setProjectsInputInfo(main); @@ -90,17 +89,14 @@ public void name() throws Exception { System.out.println(buildInfo1); } - private BuildInfoType.Executions createExecutions() { + private List createExecutions() { CompletedExecutionType execution = new CompletedExecutionType(); execution.setExecutionKey("execkey"); - execution.setConfiguration(new CompletedExecutionType.Configuration()); PropertyValueType property = new PropertyValueType(); property.setValue("value"); property.setName("key"); - execution.getConfiguration().getProperty().add(property); - BuildInfoType.Executions executions = new BuildInfoType.Executions(); - executions.getExecution().add(execution); - return executions; + execution.setConfiguration(new ArrayList<>(Arrays.asList(property))); + return new ArrayList<>(Arrays.asList(execution)); } private DigestItemType createItem(String pom, String s, String hash1) { diff --git a/maven-core/src/test/java/org/apache/maven/caching/xml/CacheConfigTest.java b/maven-core/src/test/java/org/apache/maven/caching/xml/CacheConfigTest.java index b18752fd0594..8b81a78dfdbc 100644 --- a/maven-core/src/test/java/org/apache/maven/caching/xml/CacheConfigTest.java +++ b/maven-core/src/test/java/org/apache/maven/caching/xml/CacheConfigTest.java @@ -19,17 +19,17 @@ * under the License. */ +import org.apache.maven.caching.xml.config.CacheType; import org.junit.Test; -import java.nio.file.Path; -import java.nio.file.Paths; +import java.io.InputStream; public class CacheConfigTest { @Test public void testMU() { -// final Path path = Paths.get("W:\\dev\\abfx\\maven-cache-config.xml"); -// final CacheConfig cacheConfig = CacheConfig.fromFile(path.toFile()); -// System.out.println(cacheConfig.toString()); + InputStream is = getClass().getResourceAsStream( "cache-config-instance.xml" ); + final CacheType cacheConfig = new XmlService().fromInputStream( CacheType.class, is ); + System.out.println(cacheConfig.toString()); } } \ No newline at end of file diff --git a/maven-core/src/test/resources/org/apache/maven/caching/xml/cache-config-instance.xml b/maven-core/src/test/resources/org/apache/maven/caching/xml/cache-config-instance.xml new file mode 100644 index 000000000000..92e3ce767fa0 --- /dev/null +++ b/maven-core/src/test/resources/org/apache/maven/caching/xml/cache-config-instance.xml @@ -0,0 +1,160 @@ + + + + + + + + true + SHA-256 + true + + http://host:port + + + 3 + + + + + + + {*.java,*.groovy,*.yaml,*.svcd,*.proto,*assembly.xml,assembly*.xml,*logback.xml,*.vm,*.ini,*.jks,*.properties,*.sh,*.bat} + + + src/ + + + pom.xml + + + + + + + 111 + + + + + + + + + + + + + + + 1 + 2 + + + + + + + + + + + + + + + .*-processes.*\.zip + + + + + + + + + + + + aaa + + + + + + + install + + + + + deploy + + + + + deploy-local + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/maven-core/src/main/resources/cache-domain-instance.xml b/maven-core/src/test/resources/org/apache/maven/caching/xml/cache-domain-instance.xml similarity index 100% rename from maven-core/src/main/resources/cache-domain-instance.xml rename to maven-core/src/test/resources/org/apache/maven/caching/xml/cache-domain-instance.xml diff --git a/pom.xml b/pom.xml index f76757ba9fc6..bfadcb6ee4a8 100644 --- a/pom.xml +++ b/pom.xml @@ -555,7 +555,6 @@ under the License. --> src/main/appended-resources/licenses/CDDL-1.0.txt src/main/appended-resources/licenses/EPL-1.0.txt - src/main/appended-resources/licenses/EDL-1.0.txt src/main/appended-resources/licenses/MPL-1.1.txt src/main/appended-resources/licenses/LGPL-3.0.txt .editorconfig