Commit f6623d76 authored by Saif Abdul Cassim's avatar Saif Abdul Cassim Committed by Emmanuel Bourg
Browse files

Backported the refactored IvyArtifact classes from Gradle 4.8 to help building Kotlin

parent 47973ee2
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
gradle (4.4.1-7) UNRELEASED; urgency=medium

  * Team upload.

  [ Jongmin Kim ]
  * Use JRE provided xml-apis (Closes: #925586)

  [ Saif Abdul Cassim ]
  * Backported the refactored IvyArtifact classes from Gradle 4.8
    to help building Kotlin

 -- Jongmin Kim <jmkim@pukyong.ac.kr>  Tue, 25 Jun 2019 11:32:22 +0200

gradle (4.4.1-6) unstable; urgency=medium
+224 −0
Original line number Diff line number Diff line
Description: Backports the refactored IvyArtifact classes from Gradle 4.8 to help building Kotlin
Origin: backport, https://github.com/gradle/gradle/commit/e076a783
--- /dev/null
+++ b/subprojects/ivy/src/main/java/org/gradle/api/publish/ivy/internal/artifact/AbstractIvyArtifact.java
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2018 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.publish.ivy.internal.artifact;
+
+import com.google.common.base.Strings;
+import org.gradle.api.internal.tasks.AbstractTaskDependency;
+import org.gradle.api.internal.tasks.DefaultTaskDependency;
+import org.gradle.api.internal.tasks.TaskDependencyInternal;
+import org.gradle.api.internal.tasks.TaskDependencyResolveContext;
+import org.gradle.api.publish.ivy.IvyArtifact;
+import org.gradle.api.tasks.TaskDependency;
+
+import javax.annotation.Nullable;
+
+public abstract class AbstractIvyArtifact implements IvyArtifact {
+    private final TaskDependency allBuildDependencies;
+    private final DefaultTaskDependency additionalBuildDependencies;
+
+    private String name;
+    private String type;
+    private String extension;
+    private String classifier;
+    private String conf;
+
+    protected AbstractIvyArtifact() {
+        this.additionalBuildDependencies = new DefaultTaskDependency();
+        this.allBuildDependencies = new CompositeTaskDependency();
+    }
+
+    @Override
+    public String getName() {
+        return name != null ? name : getDefaultName();
+    }
+
+    protected abstract String getDefaultName();
+
+    @Override
+    public void setName(String name) {
+        this.name = Strings.nullToEmpty(name);
+    }
+
+    @Override
+    public String getType() {
+        return type != null ? type : getDefaultType();
+    }
+
+    protected abstract String getDefaultType();
+
+    @Override
+    public void setType(String type) {
+        this.type = Strings.nullToEmpty(type);
+    }
+
+    @Override
+    public String getExtension() {
+        return extension != null ? extension : getDefaultExtension();
+    }
+
+    protected abstract String getDefaultExtension();
+
+    @Override
+    public void setExtension(String extension) {
+        this.extension = Strings.nullToEmpty(extension);
+    }
+
+    @Nullable
+    @Override
+    public String getClassifier() {
+        return Strings.emptyToNull(classifier != null ? classifier : getDefaultClassifier());
+    }
+
+    protected abstract String getDefaultClassifier();
+
+    @Override
+    public void setClassifier(@Nullable String classifier) {
+        this.classifier = Strings.nullToEmpty(classifier);
+    }
+
+    @Nullable
+    @Override
+    public String getConf() {
+        return Strings.emptyToNull(conf != null ? conf : getDefaultConf());
+    }
+
+    protected abstract String getDefaultConf();
+
+    @Override
+    public void setConf(@Nullable String conf) {
+        this.conf = Strings.nullToEmpty(conf);
+    }
+
+    @Override
+    public void builtBy(Object... tasks) {
+        additionalBuildDependencies.add(tasks);
+    }
+
+    @Override
+    public TaskDependency getBuildDependencies() {
+        return allBuildDependencies;
+    }
+
+    protected abstract TaskDependencyInternal getDefaultBuildDependencies();
+
+    @Override
+    public String toString() {
+        return String.format("%s %s:%s:%s:%s", getClass().getSimpleName(), getName(), getType(), getExtension(), getClassifier());
+    }
+
+    private class CompositeTaskDependency extends AbstractTaskDependency {
+        @Override
+        public void visitDependencies(TaskDependencyResolveContext context) {
+            getDefaultBuildDependencies().visitDependencies(context);
+            additionalBuildDependencies.visitDependencies(context);
+        }
+    }
+}
--- /dev/null
+++ b/subprojects/ivy/src/main/java/org/gradle/api/publish/ivy/internal/artifact/FileBasedIvyArtifact.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2018 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.publish.ivy.internal.artifact;
+
+import com.google.common.io.Files;
+import org.gradle.api.Task;
+import org.gradle.api.internal.tasks.TaskDependencyInternal;
+import org.gradle.api.internal.tasks.TaskDependencyResolveContext;
+import org.gradle.api.tasks.TaskDependency;
+
+import javax.annotation.Nullable;
+import java.util.Collections;
+import java.util.Set;
+import org.gradle.api.publish.ivy.internal.publisher.IvyPublicationIdentity;
+
+import java.io.File;
+
+public class FileBasedIvyArtifact extends AbstractIvyArtifact {
+    private final File file;
+    private final String extension;
+    private final IvyPublicationIdentity identity;
+
+    public FileBasedIvyArtifact(File file, IvyPublicationIdentity identity) {
+        this.file = file;
+        extension = Files.getFileExtension(file.getName());
+        this.identity = identity;
+    }
+
+    @Override
+    protected String getDefaultName() {
+        return identity.getModule();
+    }
+
+    @Override
+    protected String getDefaultType() {
+        return extension;
+    }
+
+    @Override
+    protected String getDefaultExtension() {
+        return extension;
+    }
+
+    @Override
+    protected String getDefaultClassifier() {
+        return null;
+    }
+
+    @Override
+    protected String getDefaultConf() {
+        return null;
+    }
+
+    @Override
+    protected TaskDependencyInternal getDefaultBuildDependencies() {
+        return new TaskDependencyInternal() {
+        @Override
+        public Set<? extends Task> getDependencies(@Nullable Task task) {
+            return Collections.emptySet();
+        }
+
+        @Override
+        public void visitDependencies(TaskDependencyResolveContext context) {
+        }
+};
+    }
+
+    @Override
+    public File getFile() {
+        return file;
+    }
+}
+1 −0
Original line number Diff line number Diff line
@@ -26,3 +26,4 @@ disable-google-apis.patch
disable-internal-android-performance-testing.patch
java11-compatibility.patch
asm7.patch
ivy-artifact-backport.patch