Java Code Examples for org.gradle.api.tasks.bundling.AbstractArchiveTask

The following examples show how to use org.gradle.api.tasks.bundling.AbstractArchiveTask. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: skara   Source File: ReproducePlugin.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public void apply(Project project) {
    project.afterEvaluate((p) -> {
        for (var entry : project.getAllTasks(true).entrySet()) {
            for (var task : entry.getValue()) {
                if (task instanceof AbstractArchiveTask) {
                    var archiveTask = (AbstractArchiveTask) task;
                    archiveTask.setPreserveFileTimestamps(false);
                    archiveTask.setReproducibleFileOrder(true);
                }
            }
        }
    });

    project.getTasks().create("reproduce", ReproduceTask.class, (task) -> {
        task.setDockerfile("Dockerfile");
    });
}
 
Example 2
public NotationParser<Object, MavenArtifact> create() {
    FileNotationParser fileNotationParser = new FileNotationParser(fileResolver);
    ArchiveTaskNotationParser archiveTaskNotationParser = new ArchiveTaskNotationParser();
    PublishArtifactNotationParser publishArtifactNotationParser = new PublishArtifactNotationParser();

    NotationParser<Object, MavenArtifact> sourceNotationParser = NotationParserBuilder
            .toType(MavenArtifact.class)
            .fromType(AbstractArchiveTask.class, archiveTaskNotationParser)
            .fromType(PublishArtifact.class, publishArtifactNotationParser)
            .converter(fileNotationParser)
            .toComposite();

    MavenArtifactMapNotationParser mavenArtifactMapNotationParser = new MavenArtifactMapNotationParser(sourceNotationParser);

    NotationParserBuilder<MavenArtifact> parserBuilder = NotationParserBuilder
            .toType(MavenArtifact.class)
            .fromType(AbstractArchiveTask.class, archiveTaskNotationParser)
            .fromType(PublishArtifact.class, publishArtifactNotationParser)
            .parser(mavenArtifactMapNotationParser)
            .converter(fileNotationParser);

    return parserBuilder.toComposite();
}
 
Example 3
public NotationParser<Object, MavenArtifact> create() {
    FileNotationParser fileNotationParser = new FileNotationParser(fileResolver);
    ArchiveTaskNotationParser archiveTaskNotationParser = new ArchiveTaskNotationParser();
    PublishArtifactNotationParser publishArtifactNotationParser = new PublishArtifactNotationParser();

    NotationParser<Object, MavenArtifact> sourceNotationParser = NotationParserBuilder
            .toType(MavenArtifact.class)
            .fromType(AbstractArchiveTask.class, archiveTaskNotationParser)
            .fromType(PublishArtifact.class, publishArtifactNotationParser)
            .converter(fileNotationParser)
            .toComposite();

    MavenArtifactMapNotationParser mavenArtifactMapNotationParser = new MavenArtifactMapNotationParser(sourceNotationParser);

    NotationParserBuilder<MavenArtifact> parserBuilder = NotationParserBuilder
            .toType(MavenArtifact.class)
            .fromType(AbstractArchiveTask.class, archiveTaskNotationParser)
            .fromType(PublishArtifact.class, publishArtifactNotationParser)
            .parser(mavenArtifactMapNotationParser)
            .converter(fileNotationParser);

    return parserBuilder.toComposite();
}
 
Example 4
public void convert(AbstractArchiveTask archiveTask, NotationConvertResult<? super MavenArtifact> result) throws TypeConversionException {
    DefaultMavenArtifact artifact = instantiator.newInstance(
            DefaultMavenArtifact.class,
            archiveTask.getArchivePath(), archiveTask.getExtension(), archiveTask.getClassifier());
    artifact.builtBy(archiveTask);
    result.converted(artifact);
}
 
Example 5
@Override
protected IvyArtifact parseType(AbstractArchiveTask archiveTask) {
    DefaultIvyArtifact ivyArtifact = createDefaultIvyArtifact(
            archiveTask.getArchivePath(), archiveTask.getExtension(), archiveTask.getExtension(), archiveTask.getClassifier());
    ivyArtifact.builtBy(archiveTask);
    return ivyArtifact;
}
 
Example 6
private void configureArchiveDefaults(final Project project, final BasePluginConvention pluginConvention) {
    project.getTasks().withType(AbstractArchiveTask.class, new Action<AbstractArchiveTask>() {
        public void execute(AbstractArchiveTask task) {
            ConventionMapping taskConventionMapping = task.getConventionMapping();

            Callable<File> destinationDir;
            if (task instanceof Jar) {
                destinationDir = new Callable<File>() {
                    public File call() throws Exception {
                        return pluginConvention.getLibsDir();
                    }
                };
            } else {
                destinationDir = new Callable<File>() {
                    public File call() throws Exception {
                        return pluginConvention.getDistsDir();
                    }
                };
            }
            taskConventionMapping.map("destinationDir", destinationDir);

            taskConventionMapping.map("version", new Callable<String>() {
                public String call() throws Exception {
                    return project.getVersion() == Project.DEFAULT_VERSION ? null : project.getVersion().toString();
                }
            });

            taskConventionMapping.map("baseName", new Callable<String>() {
                public String call() throws Exception {
                    return pluginConvention.getArchivesBaseName();
                }
            });
        }
    });
}
 
Example 7
@Override
protected MavenArtifact parseType(AbstractArchiveTask archiveTask) {
    DefaultMavenArtifact artifact = instantiator.newInstance(
            DefaultMavenArtifact.class,
            archiveTask.getArchivePath(), archiveTask.getExtension(), archiveTask.getClassifier());
    artifact.builtBy(archiveTask);
    return artifact;
}
 
Example 8
@Override
protected IvyArtifact parseType(AbstractArchiveTask archiveTask) {
    DefaultIvyArtifact ivyArtifact = createDefaultIvyArtifact(
            archiveTask.getArchivePath(), archiveTask.getExtension(), archiveTask.getExtension(), archiveTask.getClassifier());
    ivyArtifact.builtBy(archiveTask);
    return ivyArtifact;
}
 
Example 9
private void configureArchiveDefaults(final Project project, final BasePluginConvention pluginConvention) {
    project.getTasks().withType(AbstractArchiveTask.class, new Action<AbstractArchiveTask>() {
        public void execute(AbstractArchiveTask task) {
            ConventionMapping taskConventionMapping = task.getConventionMapping();

            Callable<File> destinationDir;
            if (task instanceof Jar) {
                destinationDir = new Callable<File>() {
                    public File call() throws Exception {
                        return pluginConvention.getLibsDir();
                    }
                };
            } else {
                destinationDir = new Callable<File>() {
                    public File call() throws Exception {
                        return pluginConvention.getDistsDir();
                    }
                };
            }
            taskConventionMapping.map("destinationDir", destinationDir);

            taskConventionMapping.map("version", new Callable<String>() {
                public String call() throws Exception {
                    return project.getVersion() == Project.DEFAULT_VERSION ? null : project.getVersion().toString();
                }
            });

            taskConventionMapping.map("baseName", new Callable<String>() {
                public String call() throws Exception {
                    return pluginConvention.getArchivesBaseName();
                }
            });
        }
    });
}
 
Example 10
Source Project: javaide   Source File: BasePlugin.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void configureArchiveDefaults(final Project project, final BasePluginConvention pluginConvention) {
    project.getTasks().withType(AbstractArchiveTask.class, new Action<AbstractArchiveTask>() {
        public void execute(AbstractArchiveTask task) {
            ConventionMapping taskConventionMapping = task.getConventionMapping();

            Callable<File> destinationDir;
            if (task instanceof Jar) {
                destinationDir = new Callable<File>() {
                    public File call() throws Exception {
                        return pluginConvention.getLibsDir();
                    }
                };
            } else {
                destinationDir = new Callable<File>() {
                    public File call() throws Exception {
                        return pluginConvention.getDistsDir();
                    }
                };
            }
            taskConventionMapping.map("destinationDir", destinationDir);

            taskConventionMapping.map("version", new Callable<String>() {
                public String call() throws Exception {
                    return project.getVersion() == Project.DEFAULT_VERSION ? null : project.getVersion().toString();
                }
            });

            taskConventionMapping.map("baseName", new Callable<String>() {
                public String call() throws Exception {
                    return pluginConvention.getArchivesBaseName();
                }
            });
        }
    });
}
 
Example 11
Source Project: app-gradle-plugin   Source File: SourceContextPlugin.java    License: Apache License 2.0 5 votes vote down vote up
private void configureArchiveTask(AbstractArchiveTask archiveTask) {
  if (archiveTask == null) {
    return;
  }
  archiveTask.dependsOn("_createSourceContext");
  archiveTask.from(extension.getOutputDirectory(), copySpec -> copySpec.into("WEB-INF/classes"));
}
 
Example 12
public void convert(AbstractArchiveTask archiveTask, NotationConvertResult<? super MavenArtifact> result) throws TypeConversionException {
    DefaultMavenArtifact artifact = instantiator.newInstance(
            DefaultMavenArtifact.class,
            archiveTask.getArchivePath(), archiveTask.getExtension(), archiveTask.getClassifier());
    artifact.builtBy(archiveTask);
    result.converted(artifact);
}
 
Example 13
@Override
protected IvyArtifact parseType(AbstractArchiveTask archiveTask) {
    DefaultIvyArtifact ivyArtifact = createDefaultIvyArtifact(
            archiveTask.getArchivePath(), archiveTask.getExtension(), archiveTask.getExtension(), archiveTask.getClassifier());
    ivyArtifact.builtBy(archiveTask);
    return ivyArtifact;
}
 
Example 14
Source Project: Pushjet-Android   Source File: BasePlugin.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void configureArchiveDefaults(final Project project, final BasePluginConvention pluginConvention) {
    project.getTasks().withType(AbstractArchiveTask.class, new Action<AbstractArchiveTask>() {
        public void execute(AbstractArchiveTask task) {
            ConventionMapping taskConventionMapping = task.getConventionMapping();

            Callable<File> destinationDir;
            if (task instanceof Jar) {
                destinationDir = new Callable<File>() {
                    public File call() throws Exception {
                        return pluginConvention.getLibsDir();
                    }
                };
            } else {
                destinationDir = new Callable<File>() {
                    public File call() throws Exception {
                        return pluginConvention.getDistsDir();
                    }
                };
            }
            taskConventionMapping.map("destinationDir", destinationDir);

            taskConventionMapping.map("version", new Callable<String>() {
                public String call() throws Exception {
                    return project.getVersion() == Project.DEFAULT_VERSION ? null : project.getVersion().toString();
                }
            });

            taskConventionMapping.map("baseName", new Callable<String>() {
                public String call() throws Exception {
                    return pluginConvention.getArchivesBaseName();
                }
            });
        }
    });
}
 
Example 15
@Override
protected MavenArtifact parseType(AbstractArchiveTask archiveTask) {
    DefaultMavenArtifact artifact = instantiator.newInstance(
            DefaultMavenArtifact.class,
            archiveTask.getArchivePath(), archiveTask.getExtension(), archiveTask.getClassifier());
    artifact.builtBy(archiveTask);
    return artifact;
}
 
Example 16
@Override
protected IvyArtifact parseType(AbstractArchiveTask archiveTask) {
    DefaultIvyArtifact ivyArtifact = createDefaultIvyArtifact(
            archiveTask.getArchivePath(), archiveTask.getExtension(), archiveTask.getExtension(), archiveTask.getClassifier());
    ivyArtifact.builtBy(archiveTask);
    return ivyArtifact;
}
 
Example 17
Source Project: Pushjet-Android   Source File: BasePlugin.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void configureArchiveDefaults(final Project project, final BasePluginConvention pluginConvention) {
    project.getTasks().withType(AbstractArchiveTask.class, new Action<AbstractArchiveTask>() {
        public void execute(AbstractArchiveTask task) {
            ConventionMapping taskConventionMapping = task.getConventionMapping();

            Callable<File> destinationDir;
            if (task instanceof Jar) {
                destinationDir = new Callable<File>() {
                    public File call() throws Exception {
                        return pluginConvention.getLibsDir();
                    }
                };
            } else {
                destinationDir = new Callable<File>() {
                    public File call() throws Exception {
                        return pluginConvention.getDistsDir();
                    }
                };
            }
            taskConventionMapping.map("destinationDir", destinationDir);

            taskConventionMapping.map("version", new Callable<String>() {
                public String call() throws Exception {
                    return project.getVersion() == Project.DEFAULT_VERSION ? null : project.getVersion().toString();
                }
            });

            taskConventionMapping.map("baseName", new Callable<String>() {
                public String call() throws Exception {
                    return pluginConvention.getArchivesBaseName();
                }
            });
        }
    });
}
 
Example 18
private ArchiveTaskNotationParser() {
    super(AbstractArchiveTask.class);
}
 
Example 19
@Override
protected PublishArtifact parseType(AbstractArchiveTask notation) {
    return instantiator.newInstance(ArchivePublishArtifact.class, notation);
}
 
Example 20
private ArchiveTaskNotationParser() {
    super(AbstractArchiveTask.class);
}
 
Example 21
public ArchivePublishArtifact(AbstractArchiveTask archiveTask) {
    super(archiveTask);
    this.archiveTask = archiveTask;
}
 
Example 22
public AbstractArchiveTask getArchiveTask() {
    return archiveTask;
}
 
Example 23
private ArchiveTaskNotationParser() {
    super(AbstractArchiveTask.class);
}
 
Example 24
private ArchiveTaskNotationParser() {
    super(AbstractArchiveTask.class);
}
 
Example 25
@Override
protected PublishArtifact parseType(AbstractArchiveTask notation) {
    return instantiator.newInstance(ArchivePublishArtifact.class, notation);
}
 
Example 26
private ArchiveTaskNotationParser() {
    super(AbstractArchiveTask.class);
}
 
Example 27
public ArchivePublishArtifact(AbstractArchiveTask archiveTask) {
    super(archiveTask);
    this.archiveTask = archiveTask;
}
 
Example 28
public AbstractArchiveTask getArchiveTask() {
    return archiveTask;
}
 
Example 29
Source Project: gradle-plugins   Source File: WarOverlayPlugin.java    License: MIT License 4 votes vote down vote up
private void configureOverlay(WarOverlay overlay) {

        if (overlay.isDeferProvidedConfiguration()) {
            //Delay this to trick IntelliJ
            //noinspection Convert2Lambda
            overlay.getWarTask().doFirst(new Action<Task>() {
                @Override
                public void execute(Task w) {
                    overlay.getWarCopySpec().exclude(element -> overlay.isProvided());
                }
            });
        } else {
            overlay.getWarCopySpec().exclude(element -> overlay.isProvided());
        }

        Object source = overlay.getSource();

        if (source instanceof AbstractArchiveTask) {
            configureOverlay(overlay, (AbstractArchiveTask) source);
        } else if (source instanceof Project && overlay.getConfigureClosure() == null) {
            configureOverlay(overlay, (Project) source);
        } else if (source instanceof File) {
            configureOverlay(overlay, (File) source);
        } else {
            Closure configClosure = overlay.getConfigureClosure();
            Dependency dependency;
            if (configClosure == null) {
                dependency = project.getDependencies().create(source);
            } else {
                dependency = project.getDependencies().create(source, configClosure);
            }

            if (dependency instanceof ProjectDependency) {
                configureOverlay(overlay, ((ProjectDependency) dependency).getDependencyProject());
            } else if (dependency instanceof ExternalDependency) {
                configureOverlay(overlay, (ExternalDependency) dependency);
            } else {
                throw new GradleException("Unsupported dependency type: " + dependency.getClass().getName());
            }
        }
    }
 
Example 30
Source Project: gradle-plugins   Source File: WarOverlayPlugin.java    License: MIT License 4 votes vote down vote up
private void configureOverlay(WarOverlay overlay, AbstractArchiveTask from) {
    overlay.getWarCopySpec().with(from.getRootSpec());
}