Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion maven-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,40 @@ under the License.
</configuration>
<executions>
<execution>
<id>modello-site-doc</id>
<id>modello-site-docs-cache</id>
<phase>pre-site</phase>
<goals>
<goal>xdoc</goal>
<goal>xsd</goal>
</goals>
<configuration>
<version>1.0.0</version>
<models>
<model>src/main/mdo/cache-domain.mdo</model>
</models>
</configuration>
</execution>
<execution>
<id>modello-cache</id>
<goals>
<goal>java</goal>
<goal>xpp3-reader</goal>
<goal>xpp3-writer</goal>
Comment thread
hboutemy marked this conversation as resolved.
<goal>xsd</goal>
</goals>
<configuration>
<version>1.0.0</version>
<models>
<model>src/main/mdo/cache-config.mdo</model>
<model>src/main/mdo/cache-domain.mdo</model>
<model>src/main/mdo/cache-diff.mdo</model>
<model>src/main/mdo/cache-report.mdo</model>
</models>
<outputDirectory>${basedir}/target/generated-sources/modello</outputDirectory>
</configuration>
</execution>
<execution>
<id>modello-site-docs-extension</id>
<phase>pre-site</phase>
<goals>
<goal>xdoc</goal>
Expand Down Expand Up @@ -248,6 +281,7 @@ under the License.
</execution>
</executions>
</plugin>
<!--
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
Expand All @@ -268,6 +302,7 @@ under the License.
</sources>
</configuration>
</plugin>
-->
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/

import org.apache.maven.artifact.Artifact;
import org.apache.maven.caching.jaxb.CacheReportType;
import org.apache.maven.caching.domain.CacheReportType;
import org.apache.maven.caching.xml.BuildInfo;
import org.apache.maven.execution.MavenSession;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* under the License.
*/

import org.apache.maven.caching.jaxb.ProjectsInputInfoType;
import org.apache.maven.caching.domain.ProjectsInputInfoType;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.project.MavenProject;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.domain.Scm;
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.domain.ArtifactType;
import org.apache.maven.caching.domain.BuildDiffType;
import org.apache.maven.caching.domain.CacheReportType;
import org.apache.maven.caching.domain.CompletedExecutionType;
import org.apache.maven.caching.domain.DigestItemType;
import org.apache.maven.caching.domain.ProjectReportType;
import org.apache.maven.caching.domain.ProjectsInputInfoType;
import org.apache.maven.caching.domain.PropertyNameType;
import org.apache.maven.caching.domain.TrackedPropertyType;
import org.apache.maven.caching.xml.BuildInfo;
import org.apache.maven.caching.xml.CacheConfig;
import org.apache.maven.caching.xml.CacheSource;
Expand All @@ -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;
Expand Down Expand Up @@ -143,7 +142,7 @@ public class CacheControllerImpl implements CacheController

private final ConcurrentMap<String, CacheResult> cacheResults = new ConcurrentHashMap<>();

private volatile BuildInfoType.Scm scm;
private volatile Scm scm;

@Override
@Nonnull
Expand Down Expand Up @@ -434,7 +433,7 @@ public void save( CacheResult cacheResult, List<MojoExecution> 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
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 );
}
}
Expand Down
28 changes: 14 additions & 14 deletions maven-core/src/main/java/org/apache/maven/caching/CacheDiff.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.domain.BuildDiffType;
import org.apache.maven.caching.domain.BuildInfoType;
import org.apache.maven.caching.domain.CompletedExecutionType;
import org.apache.maven.caching.domain.DigestItemType;
import org.apache.maven.caching.domain.MismatchType;
import org.apache.maven.caching.domain.ProjectsInputInfoType;
import org.apache.maven.caching.domain.PropertyValueType;
import org.apache.maven.caching.xml.CacheConfig;

import java.util.ArrayList;
Expand Down Expand Up @@ -232,23 +232,23 @@ private void compareDependencies( ProjectsInputInfoType current, ProjectsInputIn
}


private void compareExecutions( BuildInfoType.Executions current, BuildInfoType.Executions baseline )
private void compareExecutions( List<CompletedExecutionType> current, List<CompletedExecutionType> baseline )
{
Map<String, CompletedExecutionType> baselineExecutionsByKey = new HashMap<>();
for ( CompletedExecutionType completedExecutionType : baseline.getExecution() )
for ( CompletedExecutionType completedExecutionType : baseline )
{
baselineExecutionsByKey.put( completedExecutionType.getExecutionKey(), completedExecutionType );
}

Map<String, CompletedExecutionType> 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() ) )
{
Expand All @@ -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() ) )
{
Expand All @@ -285,7 +285,7 @@ private void comparePlugins( CompletedExecutionType current, CompletedExecutionT
{
// TODO add support for skip values
final List<PropertyValueType> trackedProperties = new ArrayList<>();
for ( PropertyValueType propertyValueType : current.getConfiguration().getProperty() )
for ( PropertyValueType propertyValueType : current.getConfiguration() )
{
if ( propertyValueType.isTracked() )
{
Expand All @@ -298,7 +298,7 @@ private void comparePlugins( CompletedExecutionType current, CompletedExecutionT
}

final Map<String, PropertyValueType> baselinePropertiesByName = new HashMap<>();
for ( PropertyValueType propertyValueType : baseline.getConfiguration().getProperty() )
for ( PropertyValueType propertyValueType : baseline.getConfiguration() )
{
baselinePropertiesByName.put( propertyValueType.getName(), propertyValueType );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* under the License.
*/

import org.apache.maven.caching.xml.CacheConfig;
import org.apache.maven.eventspy.AbstractEventSpy;
import org.apache.maven.eventspy.EventSpy;
import org.apache.maven.execution.ExecutionEvent;
Expand All @@ -31,18 +32,24 @@
@Component( role = EventSpy.class )
public class CacheEventSpy extends AbstractEventSpy
{
@Requirement
private CacheConfig cacheConfig;

@Requirement
private CacheController cacheController;

@Override
public void onEvent( Object event ) throws Exception
{
if ( event instanceof ExecutionEvent )
if ( cacheConfig.isEnabled() )
{
ExecutionEvent executionEvent = (ExecutionEvent) event;
if ( executionEvent.getType() == ExecutionEvent.Type.SessionEnded )
if ( event instanceof ExecutionEvent )
{
cacheController.saveCacheReport( executionEvent.getSession() );
ExecutionEvent executionEvent = (ExecutionEvent) event;
if ( executionEvent.getType() == ExecutionEvent.Type.SessionEnded )
{
cacheController.saveCacheReport( executionEvent.getSession() );
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,6 @@ public RestoreStatus getStatus()

public boolean isFinal()
{
return buildInfo != null && buildInfo.getDto().isFinal();
return buildInfo != null && buildInfo.getDto().is_final();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* under the License.
*/

import org.apache.maven.caching.jaxb.DirScanConfigType;
import org.apache.maven.caching.domain.DirScanConfigType;

import javax.annotation.Nonnull;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.domain.ArtifactType;
import org.apache.maven.caching.domain.BuildInfoType;
import org.apache.maven.caching.domain.CacheReportType;
import org.apache.maven.caching.domain.ProjectReportType;
import org.apache.maven.caching.xml.BuildInfo;
import org.apache.maven.caching.xml.CacheConfig;
import org.apache.maven.caching.xml.CacheSource;
Expand Down Expand Up @@ -268,7 +268,7 @@ public Optional<BuildInfo> 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() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/

import com.google.common.base.Optional;
import org.apache.maven.caching.jaxb.ArtifactType;
import org.apache.maven.caching.domain.ArtifactType;
import org.apache.maven.caching.xml.BuildInfo;
import org.apache.maven.caching.xml.CacheSource;
import org.apache.maven.execution.MavenSession;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@
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.domain.ArtifactType;
import org.apache.maven.caching.domain.BuildInfoType;
import org.apache.maven.caching.domain.CacheReportType;
import org.apache.maven.caching.domain.Scm;
import org.apache.maven.caching.xml.BuildInfo;
import org.apache.maven.caching.xml.CacheConfig;
import org.apache.maven.caching.xml.CacheSource;
Expand Down Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
*/

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.domain.CompletedExecutionType;
import org.apache.maven.caching.domain.TrackedPropertyType;
import org.apache.maven.caching.xml.BuildInfo;
import org.apache.maven.caching.xml.CacheConfig;
import org.apache.maven.caching.xml.DtoUtils;
Expand Down Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* under the License.
*/

import org.apache.maven.caching.jaxb.DirScanConfigType;
import org.apache.maven.caching.domain.DirScanConfigType;

import javax.annotation.Nonnull;

Expand Down
Loading