Search in sources :

Example 1 with BuildRequest

use of build.pluto.builder.BuildRequest in project spoofax by metaborg.

the class PackageBuilder method jar.

public Origin jar(File jarFile, File baseDir, @Nullable Origin origin, @Nullable File depPath, Iterable<File> paths) throws IOException {
    final Collection<JarBuilder.Entry> fileEntries = Lists.newLinkedList();
    for (File path : paths) {
        require(path, new DirectoryModifiedStamper());
        final Collection<File> files = findFiles(path);
        for (final File classFile : files) {
            final String relative = relativize(classFile, baseDir);
            // Ignore files that are not relative to the base directory.
            if (relative != null) {
                // Convert \ to / on Windows; ZIP/JAR files must use / for paths.
                // HACK: this should be fixed in the JarBuilder.
                final String forwardslashRelative = relative.replace('\\', '/');
                fileEntries.add(new JarBuilder.Entry(forwardslashRelative, classFile));
            }
        }
    }
    final BuildRequest<?, ?, ?, ?> buildRequest = new BuildRequest<>(JarBuilder.factory, new JarBuilder.Input(jarFile, fileEntries, origin, depPath));
    final Origin jarOrigin = Origin.from(buildRequest);
    requireBuild(jarOrigin);
    return jarOrigin;
}
Also used : Origin(build.pluto.dependency.Origin) DirectoryModifiedStamper(org.metaborg.spoofax.meta.core.pluto.stamp.DirectoryModifiedStamper) JarBuilder(build.pluto.buildjava.JarBuilder) BuildRequest(build.pluto.builder.BuildRequest) File(java.io.File)

Aggregations

BuildRequest (build.pluto.builder.BuildRequest)1 JarBuilder (build.pluto.buildjava.JarBuilder)1 Origin (build.pluto.dependency.Origin)1 File (java.io.File)1 DirectoryModifiedStamper (org.metaborg.spoofax.meta.core.pluto.stamp.DirectoryModifiedStamper)1