Skip to content

Commit

Permalink
Merge branch 'release'
Browse files Browse the repository at this point in the history
  • Loading branch information
ljacomet committed Feb 21, 2019
2 parents b2755a6 + c851162 commit ae6478d
Show file tree
Hide file tree
Showing 54 changed files with 604 additions and 255 deletions.
Expand Up @@ -24,16 +24,6 @@ public class OriginMetadata {
private final UniqueId buildInvocationId;
private final long executionTime;

@Deprecated
public static OriginMetadata fromCurrentBuild(UniqueId buildInvocationId, long executionTime) {
return new OriginMetadata(buildInvocationId, executionTime);
}

@Deprecated
public static OriginMetadata fromPreviousBuild(UniqueId buildInvocationId, long executionTime) {
return new OriginMetadata(buildInvocationId, executionTime);
}

public OriginMetadata(UniqueId buildInvocationId, long executionTime) {
this.buildInvocationId = Preconditions.checkNotNull(buildInvocationId, "buildInvocationId");
this.executionTime = executionTime;
Expand Down
Expand Up @@ -36,7 +36,7 @@
*/
public class CheckstylePlugin extends AbstractCodeQualityPlugin<Checkstyle> {

public static final String DEFAULT_CHECKSTYLE_VERSION = "8.12";
public static final String DEFAULT_CHECKSTYLE_VERSION = "8.17";
private static final String CONFIG_DIR_NAME = "config/checkstyle";
private CheckstyleExtension extension;

Expand Down
Expand Up @@ -16,20 +16,12 @@

package org.gradle.quality.integtest.fixtures

import org.gradle.api.JavaVersion
import org.gradle.api.plugins.quality.CheckstylePlugin
import org.gradle.util.VersionNumber

class CheckstyleCoverage {
// Note, this only work for major.minor versions
private final static List<String> ALL = ['5.9', '6.2', '6.9', '6.12', '7.0', '7.6', CheckstylePlugin.DEFAULT_CHECKSTYLE_VERSION].asImmutable()

private final static List<VersionNumber> ALL_VERSIONS = ALL.collect { VersionNumber.parse(it) }

// JDK7 support was dropped in 7.0
private final static List<String> JDK7_SUPPORTED = ALL_VERSIONS.findAll({ it < VersionNumber.parse("7.0") }).collect({ "${it.major}.${it.minor}" }).asImmutable()
private final static List<String> ALL = ['7.0', '7.6', '8.0', '8.12', CheckstylePlugin.DEFAULT_CHECKSTYLE_VERSION].asImmutable()

static List<String> getSupportedVersionsByJdk() {
JavaVersion.current().java7 ? JDK7_SUPPORTED : ALL
ALL
}
}
@@ -0,0 +1,37 @@
/*
* Copyright 2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.gradle.api.artifacts.transform;

import org.gradle.api.Incubating;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* <p>Attached to an {@link TransformAction} type to indicate that the build cache should be used for artifact transforms of this type.</p>
*
* <p>Only an artifact transform that produces reproducible and relocatable outputs should be marked with {@code CacheableTransformAction}.</p>
*
* @since 5.3
*/
@Incubating
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
public @interface CacheableTransformAction {
}
@@ -0,0 +1,72 @@
/*
* Copyright 2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.gradle.api.attributes;

import org.gradle.api.Incubating;
import org.gradle.api.Named;

/**
* This attribute describes how dependencies of a component are found.
* There are currently 3 supported modes:
* <ul>
* <li>{@code external}, the default, where dependencies, if any, are found transitively</li>
* <li>{@code embedded}, where dependencies are found inside the component, but using the same namespace as the original dependencies</li>
* <li>{@code shadowed}, where dependencies are found inside the component, but within a different namespace to avoid name clashes</li>
* </ul>
* <p>
* As a practical example, let's consider the Java ecosystem:
* <ul>
* <li>
* Jar component:
* <ul>
* <li>{@code external} indicates that transitive dependencies are themselves component jars</li>
* <li>{@code embedded} indicates that transitive dependencies have been included inside the component jar, without modifying their packages</li>
* <li>{@code shadowed} indicates that transitive dependencies have been included inside the component jar, under different packages to prevent conflicts</li>
* </ul>
* </li>
* <li>
* Sources component:
* <ul>
* <li>{@code external} indicates that the source of transitive dependencies are themselves source jars</li>
* <li>{@code embedded} indicates that the source of transitive dependencies have been included inside the component source jar, without modifying their packages</li>
* <li>{@code shadowed} indicates that the source of transitive dependencies have been included inside the component source jar, under different packages</li>
* </ul>
* </li>
* </ul>
*
* @since 5.3
*/
@Incubating
public interface Bundling extends Named {
Attribute<Bundling> BUNDLING_ATTRIBUTE = Attribute.of("org.gradle.dependency.bundling", Bundling.class);

/**
* The most common case: dependencies are provided as individual components.
*/
String EXTERNAL = "external";

/**
* Dependencies are packaged <i>within</i> the main component artifact.
*/
String EMBEDDED = "embedded";

/**
* Dependencies are packaged <i>within</i> the main component artifact
* but also in a different namespace to prevent conflicts.
*/
String SHADOWED = "shadowed";

}

This file was deleted.

Expand Up @@ -26,7 +26,7 @@
import org.gradle.api.attributes.CompatibilityCheckDetails;
import org.gradle.api.attributes.MultipleCandidatesDetails;
import org.gradle.api.attributes.Usage;
import org.gradle.api.attributes.java.Bundling;
import org.gradle.api.attributes.Bundling;
import org.gradle.api.internal.ReusableAction;
import org.gradle.api.model.ObjectFactory;

Expand Down
Expand Up @@ -20,6 +20,7 @@
import org.gradle.api.artifacts.ConfigurationContainer;
import org.gradle.api.artifacts.dsl.DependencyHandler;
import org.gradle.api.artifacts.dsl.RepositoryHandler;
import org.gradle.api.attributes.Bundling;
import org.gradle.api.attributes.Usage;
import org.gradle.api.initialization.dsl.ScriptHandler;
import org.gradle.api.internal.DynamicObjectAware;
Expand Down Expand Up @@ -112,6 +113,7 @@ private void defineConfiguration() {
if (classpathConfiguration == null) {
classpathConfiguration = configContainer.create(CLASSPATH_CONFIGURATION);
classpathConfiguration.getAttributes().attribute(Usage.USAGE_ATTRIBUTE, NamedObjectInstantiator.INSTANCE.named(Usage.class, Usage.JAVA_RUNTIME));
classpathConfiguration.getAttributes().attribute(Bundling.BUNDLING_ATTRIBUTE, NamedObjectInstantiator.INSTANCE.named(Bundling.class, Bundling.EXTERNAL));
}
}

Expand Down
Expand Up @@ -28,6 +28,8 @@
import org.gradle.api.tasks.FileNormalizer;
import org.gradle.internal.reflect.Instantiator;

import javax.annotation.Nullable;

public class PropertyAssociationTaskFactory implements ITaskFactory {
private final ITaskFactory delegate;
private final PropertyWalker propertyWalker;
Expand Down Expand Up @@ -62,7 +64,7 @@ public boolean visitOutputFilePropertiesOnly() {
}

@Override
public void visitInputFileProperty(String propertyName, boolean optional, boolean skipWhenEmpty, Class<? extends FileNormalizer> fileNormalizer, PropertyValue value, InputFilePropertyType filePropertyType) {
public void visitInputFileProperty(String propertyName, boolean optional, boolean skipWhenEmpty, @Nullable Class<? extends FileNormalizer> fileNormalizer, PropertyValue value, InputFilePropertyType filePropertyType) {
throw new UnsupportedOperationException();
}

Expand Down
Expand Up @@ -212,7 +212,7 @@ public String getDisplayName() {
public void visitContents(final FileCollectionResolveContext context) {
TaskPropertyUtils.visitProperties(propertyWalker, task, new PropertyVisitor.Adapter() {
@Override
public void visitInputFileProperty(final String propertyName, boolean optional, boolean skipWhenEmpty, Class<? extends FileNormalizer> fileNormalizer, PropertyValue value, InputFilePropertyType filePropertyType) {
public void visitInputFileProperty(final String propertyName, boolean optional, boolean skipWhenEmpty, @Nullable Class<? extends FileNormalizer> fileNormalizer, PropertyValue value, InputFilePropertyType filePropertyType) {
if (!TaskInputUnionFileCollection.this.skipWhenEmptyOnly || skipWhenEmpty) {
FileCollection actualValue = FileParameterUtils.resolveInputFileValue(fileCollectionFactory, filePropertyType, value);
context.add(new PropertyFileCollection(task.toString(), propertyName, "input", actualValue));
Expand All @@ -230,7 +230,7 @@ public boolean hasInputs() {
}

@Override
public void visitInputFileProperty(String propertyName, boolean optional, boolean skipWhenEmpty, Class<? extends FileNormalizer> fileNormalizer, PropertyValue value, InputFilePropertyType filePropertyType) {
public void visitInputFileProperty(String propertyName, boolean optional, boolean skipWhenEmpty, @Nullable Class<? extends FileNormalizer> fileNormalizer, PropertyValue value, InputFilePropertyType filePropertyType) {
hasInputs = true;
}

Expand Down
Expand Up @@ -71,13 +71,6 @@ public interface TaskExecutionContext {
*/
long markExecutionTime();

/**
* The previously marked execution time.
*
* Throws if the execution time was not previously marked.
*/
long getExecutionTime();

@Nullable
List<String> getUpToDateMessages();

Expand Down
Expand Up @@ -152,15 +152,6 @@ public long markExecutionTime() {
return this.executionTime = executionTimer.getElapsedMillis();
}

@Override
public long getExecutionTime() {
if (this.executionTime == null) {
throw new IllegalStateException("execution time not yet set");
}

return executionTime;
}

@Override
@Nullable
public List<String> getUpToDateMessages() {
Expand Down
Expand Up @@ -213,8 +213,7 @@ public <T> Optional<T> load(Function<BuildCacheKey, T> loader) {
if (task.isHasCustomActions()) {
LOGGER.info("Custom actions are attached to {}.", task);
}
if (buildCacheEnabled
&& context.isTaskCachingEnabled()
if (context.isTaskCachingEnabled()
&& context.getTaskExecutionMode().isAllowedToUseCachedResults()
&& context.getBuildCacheKey().isValid()
) {
Expand Down
Expand Up @@ -18,6 +18,8 @@

import org.gradle.api.tasks.FileNormalizer;

import javax.annotation.Nullable;

public class CompositePropertyVisitor implements PropertyVisitor {
private final PropertyVisitor[] visitors;

Expand All @@ -36,7 +38,7 @@ public boolean visitOutputFilePropertiesOnly() {
}

@Override
public void visitInputFileProperty(String propertyName, boolean optional, boolean skipWhenEmpty, Class<? extends FileNormalizer> fileNormalizer, PropertyValue value, InputFilePropertyType filePropertyType) {
public void visitInputFileProperty(String propertyName, boolean optional, boolean skipWhenEmpty, @Nullable Class<? extends FileNormalizer> fileNormalizer, PropertyValue value, InputFilePropertyType filePropertyType) {
for (PropertyVisitor visitor : visitors) {
visitor.visitInputFileProperty(propertyName, optional, skipWhenEmpty, fileNormalizer, value, filePropertyType);
}
Expand Down
Expand Up @@ -31,6 +31,7 @@
import org.gradle.api.tasks.TaskExecutionException;
import org.gradle.internal.Factory;

import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -248,7 +249,7 @@ private static class ValidationVisitor extends PropertyVisitor.Adapter {
private final List<ValidatingProperty> taskPropertySpecs = new ArrayList<ValidatingProperty>();

@Override
public void visitInputFileProperty(String propertyName, boolean optional, boolean skipWhenEmpty, Class<? extends FileNormalizer> fileNormalizer, PropertyValue value, InputFilePropertyType filePropertyType) {
public void visitInputFileProperty(String propertyName, boolean optional, boolean skipWhenEmpty, @Nullable Class<? extends FileNormalizer> fileNormalizer, PropertyValue value, InputFilePropertyType filePropertyType) {
taskPropertySpecs.add(new DefaultFinalizingValidatingProperty(propertyName, value, optional, filePropertyType.getValidationAction()));
}

Expand Down
Expand Up @@ -37,6 +37,7 @@
import org.gradle.internal.fingerprint.RelativePathInputNormalizer;
import org.gradle.util.DeferredUtil;

import javax.annotation.Nullable;
import java.io.File;
import java.util.Iterator;
import java.util.List;
Expand All @@ -61,6 +62,12 @@ public static Class<? extends FileNormalizer> determineNormalizerForPathSensitiv
}
}

public static Class<? extends FileNormalizer> normalizerOrDefault(@Nullable Class<? extends FileNormalizer> fileNormalizer) {
// If this default is ever changed, ensure the documentation on PathSensitive is updated as well as this guide:
// https://guides.gradle.org/using-build-cache/#relocatability
return fileNormalizer == null ? AbsolutePathInputNormalizer.class : fileNormalizer;
}

/**
* Collects property specs in a sorted set to ensure consistent ordering.
*
Expand Down
Expand Up @@ -23,6 +23,7 @@
import org.gradle.api.internal.tasks.PropertyFileCollection;
import org.gradle.api.tasks.FileNormalizer;

import javax.annotation.Nullable;
import java.util.List;

public class GetInputFilesVisitor extends PropertyVisitor.Adapter {
Expand All @@ -39,11 +40,11 @@ public GetInputFilesVisitor(String ownerDisplayName, FileCollectionFactory fileC
}

@Override
public void visitInputFileProperty(final String propertyName, boolean optional, boolean skipWhenEmpty, Class<? extends FileNormalizer> fileNormalizer, PropertyValue value, InputFilePropertyType filePropertyType) {
public void visitInputFileProperty(final String propertyName, boolean optional, boolean skipWhenEmpty, @Nullable Class<? extends FileNormalizer> fileNormalizer, PropertyValue value, InputFilePropertyType filePropertyType) {
FileCollection actualValue = FileParameterUtils.resolveInputFileValue(fileCollectionFactory, filePropertyType, value);
specs.add(new DefaultInputFilePropertySpec(
propertyName,
fileNormalizer,
FileParameterUtils.normalizerOrDefault(fileNormalizer),
new PropertyFileCollection(ownerDisplayName, propertyName, "input", actualValue),
skipWhenEmpty));
if (skipWhenEmpty) {
Expand Down

0 comments on commit ae6478d

Please sign in to comment.