-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
541 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
130 changes: 130 additions & 0 deletions
130
...s/ivy/src/main/java/org/gradle/api/publish/ivy/internal/artifact/AbstractIvyArtifact.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
...c/main/java/org/gradle/api/publish/ivy/internal/artifact/ArchiveTaskBasedIvyArtifact.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* 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.collect.ImmutableSet; | ||
import org.gradle.api.internal.tasks.DefaultTaskDependency; | ||
import org.gradle.api.internal.tasks.TaskDependencyInternal; | ||
import org.gradle.api.publish.ivy.internal.publisher.IvyPublicationIdentity; | ||
import org.gradle.api.tasks.bundling.AbstractArchiveTask; | ||
|
||
import java.io.File; | ||
|
||
public class ArchiveTaskBasedIvyArtifact extends AbstractIvyArtifact { | ||
private final AbstractArchiveTask archiveTask; | ||
private final IvyPublicationIdentity identity; | ||
private final TaskDependencyInternal buildDependencies; | ||
|
||
public ArchiveTaskBasedIvyArtifact(AbstractArchiveTask archiveTask, IvyPublicationIdentity identity) { | ||
this.archiveTask = archiveTask; | ||
this.identity = identity; | ||
this.buildDependencies = new DefaultTaskDependency(null, ImmutableSet.<Object>of(archiveTask)); | ||
} | ||
|
||
@Override | ||
protected String getDefaultName() { | ||
return identity.getModule(); | ||
} | ||
|
||
@Override | ||
protected String getDefaultType() { | ||
return archiveTask.getExtension(); | ||
} | ||
|
||
@Override | ||
protected String getDefaultExtension() { | ||
return archiveTask.getExtension(); | ||
} | ||
|
||
@Override | ||
protected String getDefaultClassifier() { | ||
return archiveTask.getClassifier(); | ||
} | ||
|
||
@Override | ||
protected String getDefaultConf() { | ||
return null; | ||
} | ||
|
||
@Override | ||
protected TaskDependencyInternal getDefaultBuildDependencies() { | ||
return buildDependencies; | ||
} | ||
|
||
@Override | ||
public File getFile() { | ||
return archiveTask.getArchivePath(); | ||
} | ||
} |
107 changes: 0 additions & 107 deletions
107
...ts/ivy/src/main/java/org/gradle/api/publish/ivy/internal/artifact/DefaultIvyArtifact.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.