Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #561 - cleanup task input/output issues #567

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1407,6 +1407,7 @@ protected void configureRestModelGeneration(Project project, SourceSet sourceSet
changedFileReportTask.setIdlFiles(SharedFileUtils.getSuffixedFiles(project, apiIdlDir, IDL_FILE_SUFFIX));
changedFileReportTask.setSnapshotFiles(SharedFileUtils.getSuffixedFiles(project, apiSnapshotDir,
SNAPSHOT_FILE_SUFFIX));
changedFileReportTask.getOutputFile().set(project.getLayout().getBuildDirectory().file("changedFilesReport.txt"));
changedFileReportTask.mustRunAfter(publishRestliSnapshotTask, publishRestliIdlTask);
changedFileReportTask.doLast(new CacheableAction<>(t ->
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;

import com.linkedin.pegasus.gradle.IOUtil;
import org.gradle.api.DefaultTask;
import org.gradle.api.file.FileCollection;
import org.gradle.api.specs.Specs;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.tasks.InputFiles;
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.OutputFile;
import org.gradle.api.tasks.SkipWhenEmpty;
import org.gradle.api.tasks.TaskAction;
import org.gradle.api.tasks.incremental.IncrementalTaskInputs;
Expand All @@ -21,12 +24,7 @@ public class ChangedFileReportTask extends DefaultTask

private FileCollection _idlFiles = getProject().files();
private FileCollection _snapshotFiles = getProject().files();

public ChangedFileReportTask()
{
//with Gradle 6.0, Declaring an incremental task without outputs is not allowed.
getOutputs().upToDateWhen(Specs.satisfyNone());
}
private RegularFileProperty _outputFile = getProject().getObjects().fileProperty();

@TaskAction
public void checkFilesForChanges(IncrementalTaskInputs inputs)
Expand Down Expand Up @@ -60,27 +58,40 @@ public void checkFilesForChanges(IncrementalTaskInputs inputs)

inputs.removed(inputFileDetails -> filesRemoved.add(inputFileDetails.getFile().getAbsolutePath()));

StringBuilder sb = new StringBuilder();

if (!filesRemoved.isEmpty())
{
String files = joinByComma(filesRemoved);
_needCheckinFiles.add(files);
getLogger().lifecycle(
"The following files have been removed, be sure to remove them from source control: {}", files);
String removedFilesMsg = String.format("The following files have been removed, " +
"be sure to remove them from source control: %s\n", files);
sb.append(removedFilesMsg);
}

if (!filesAdded.isEmpty())
{
String files = joinByComma(filesAdded);
_needCheckinFiles.add(files);
getLogger().lifecycle("The following files have been added, be sure to add them to source control: {}", files);
String addedFilesMsg = String.format("The following files have been added, " +
"be sure to add them to source control: %s\n", files);
sb.append(addedFilesMsg);
}

if (!filesChanged.isEmpty())
{
String files = joinByComma(filesChanged);
_needCheckinFiles.add(files);
getLogger().lifecycle(
"The following files have been changed, be sure to commit the changes to source control: {}", files);
String modifiedFilesMsg = String.format("The following files have been changed, " +
"be sure to commit the changes to source control: %s\n", files);
sb.append(modifiedFilesMsg);
}

String output = sb.toString();
if (!output.isEmpty())
{
getLogger().lifecycle(output);
IOUtil.writeText(getOutputFile().get().getAsFile(), output);
}
}
}
Expand Down Expand Up @@ -119,4 +130,9 @@ public Collection<String> getNeedCheckinFiles()
{
return _needCheckinFiles;
}

@OutputFile
public RegularFileProperty getOutputFile() {
return _outputFile;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -166,102 +166,18 @@ public void setSummaryTarget(File summaryTarget)
_summaryTarget = summaryTarget;
}

/**
* This method is kept for backwards compatibility.
* <p>
* A Groovy property with this name was exposed, which leads to this lengthy
* getter name. In Java, boolean fields are named without the "is" prefix.
*
* @deprecated use {@link #isModelCompatible()} instead
*/
@Deprecated
public boolean getIsModelCompatible()
{
return isModelCompatible();
}

/**
* This method is kept for backwards compatibility.
* <p>
* A Groovy property with this name was exposed, which leads to this lengthy
* getter name. In Java, boolean fields are named without the "is" prefix.
*
* @deprecated use {@link #isModelCompatible()} instead
*/
@Deprecated
public boolean isIsModelCompatible()
{
return isModelCompatible();
}

@Internal
public boolean isModelCompatible()
{
return _modelCompatible;
}

/**
* This method is kept for backwards compatibility.
* <p>
* A Groovy property with this name was exposed, which leads to this lengthy
* getter name. In Java, boolean fields are named without the "is" prefix.
*
* @deprecated use {@link #isRestSpecCompatible()} instead
*/
@Deprecated
public boolean getIsRestSpecCompatible()
{
return isRestSpecCompatible();
}

/**
* This method is kept for backwards compatibility.
* <p>
* A Groovy property with this name was exposed, which leads to this lengthy
* getter name. In Java, boolean fields are named without the "is" prefix.
*
* @deprecated use {@link #isRestSpecCompatible()} instead
*/
@Deprecated
public boolean isIsRestSpecCompatible()
{
return isRestSpecCompatible();
}

@Internal
public boolean isRestSpecCompatible()
{
return _restSpecCompatible;
}

/**
* This method is kept for backwards compatibility.
* <p>
* A Groovy property with this name was exposed, which leads to this lengthy
* getter name. In Java, boolean fields are named without the "is" prefix.
*
* @deprecated use {@link #isEquivalent()} instead
*/
@Deprecated
public boolean getIsEquivalent()
{
return _equivalent;
}

/**
* This method is kept for backwards compatibility.
* <p>
* A Groovy property with this name was exposed, which leads to this lengthy
* getter name. In Java, boolean fields are named without the "is" prefix.
*
* @deprecated use {@link #isEquivalent()} instead
*/
@Deprecated
public boolean isIsEquivalent()
{
return _equivalent;
}

@Internal
public boolean isEquivalent()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,136 +201,24 @@ public void setSummaryTarget(File summaryTarget)
_summaryTarget = summaryTarget;
}

/**
* This method is kept for backwards compatibility.
* <p>
* A Groovy property with this name was exposed, which leads to this lengthy
* getter name. In Java, boolean fields are named without the "is" prefix.
*
* @deprecated use {@link #isModelCompatible()} instead
*/
@Deprecated
public boolean getIsModelCompatible()
{
return isModelCompatible();
}

/**
* This method is kept for backwards compatibility.
* <p>
* A Groovy property with this name was exposed, which leads to this lengthy
* getter name. In Java, boolean fields are named without the "is" prefix.
*
* @deprecated use {@link #isModelCompatible()} instead
*/
@Deprecated
public boolean isIsModelCompatible()
{
return isModelCompatible();
}

@Internal
public boolean isModelCompatible()
{
return _modelCompatible;
}

/**
* This method is kept for backwards compatibility.
* <p>
* A Groovy property with this name was exposed, which leads to this lengthy
* getter name. In Java, boolean fields are named without the "is" prefix.
*
* @deprecated use {@link #isRestSpecCompatible()} instead
*/
@Deprecated
public boolean getIsRestSpecCompatible()
{
return isRestSpecCompatible();
}

/**
* This method is kept for backwards compatibility.
* <p>
* A Groovy property with this name was exposed, which leads to this lengthy
* getter name. In Java, boolean fields are named without the "is" prefix.
*
* @deprecated use {@link #isRestSpecCompatible()} instead
*/
@Deprecated
public boolean isIsRestSpecCompatible()
{
return isRestSpecCompatible();
}

@Internal
public boolean isRestSpecCompatible()
{
return _restSpecCompatible;
}

/**
* This method is kept for backwards compatibility.
* <p>
* A Groovy property with this name was exposed, which leads to this lengthy
* getter name. In Java, boolean fields are named without the "is" prefix.
*
* @deprecated use {@link #isEquivalent()} instead
*/
@Deprecated
public boolean getIsEquivalent()
{
return isEquivalent();
}

/**
* This method is kept for backwards compatibility.
* <p>
* A Groovy property with this name was exposed, which leads to this lengthy
* getter name. In Java, boolean fields are named without the "is" prefix.
*
* @deprecated use {@link #isEquivalent()} instead
*/
@Deprecated
public boolean isIsEquivalent()
{
return isEquivalent();
}

@Internal
public boolean isEquivalent()
{
return _equivalent;
}

/**
* This method is kept for backwards compatibility.
* <p>
* A Groovy property with this name was exposed, which leads to this lengthy
* getter name. In Java, boolean fields are named without the "is" prefix.
*
* @deprecated use {@link #isRestSpecEquivalent()} instead
*/
@Deprecated
public boolean getIsRestSpecEquivalent()
{
return isRestSpecEquivalent();
}

/**
* This method is kept for backwards compatibility.
* <p>
* A Groovy property with this name was exposed, which leads to this lengthy
* getter name. In Java, boolean fields are named without the "is" prefix.
*
* @deprecated use {@link #isRestSpecEquivalent()} instead
*/
@Deprecated
public boolean isIsRestSpecEquivalent()
{
return isRestSpecEquivalent();
}

@Internal
public boolean isRestSpecEquivalent()
{
Expand Down