
org.eolang.maven.BinarizeMojo Maven / Gradle / Ivy
/*
* The MIT License (MIT)
*
* Copyright (c) 2016-2024 Objectionary.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.eolang.maven;
import com.jcabi.log.Logger;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collection;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.eolang.maven.rust.Buildable;
import org.eolang.maven.rust.Names;
/**
* Compile binaries.
*
* @since 0.1
* @checkstyle ClassDataAbstractionCouplingCheck (500 lines)
*/
@Mojo(
name = "binarize",
defaultPhase = LifecyclePhase.PROCESS_SOURCES,
threadSafe = true,
requiresDependencyResolution = ResolutionScope.COMPILE
)
@SuppressWarnings("PMD.LongVariable")
public final class BinarizeMojo extends SafeMojo {
/**
* The directory where to binarize to.
*/
public static final Path DIR = Paths.get("binarize");
/**
* Target directory.
* @checkstyle MemberNameCheck (7 lines)
*/
@Parameter(
required = true,
defaultValue = "${project.build.directory}/eo-binaries"
)
@SuppressWarnings("PMD.UnusedPrivateField")
private File generatedDir;
/**
* File where to save {@link org.eolang.maven.rust.Names} map.
* @checkstyle MemberNameCheck (7 lines)
*/
@Parameter(
required = true,
defaultValue = "${project.build.directory}/names"
)
@SuppressWarnings("PMD.UnusedPrivateField")
private File namesDir;
/**
* The directory with portal project. It is a necessary dependency
* that provides rust-eo interaction.
* @checkstyle MemberNameCheck (8 lines)
*/
@Parameter(
property = "eo.portal",
required = true,
defaultValue = "${project.basedir}/src/main/rust/eo"
)
@SuppressWarnings("PMD.UnusedPrivateField")
private File eoPortalDir;
@Override
public void exec() throws IOException {
final Collection ffis = new BinarizeParse(
this.generatedDir,
this.eoPortalDir,
new Names(this.namesDir.toPath()),
this.targetDir
).exec(this.scopedTojos().withOptimized());
ffis.stream().parallel().forEach(ffi -> ffi.build(this.cache));
Logger.info(this, "Built in total %d cargo projects", ffis.size());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy