
de.pfabulist.loracle.attribution.LicenseWriter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of loracle-maven-plugin Show documentation
Show all versions of loracle-maven-plugin Show documentation
maven plugin to check the licenses of all dependencies and possible incompatibilities
package de.pfabulist.loracle.attribution;
import de.pfabulist.kleinod.nio.Filess;
import de.pfabulist.loracle.license.Coordinates;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import static de.pfabulist.kleinod.text.Strings.getBytes;
import static de.pfabulist.nonnullbydefault.NonnullCheck._nn;
/**
* Copyright (c) 2006 - 2016, Stephan Pfab
* SPDX-License-Identifier: BSD-2-Clause
*/
public class LicenseWriter {
public void write( Coordinates coo, String name, String txt ) {
if ( !txt.isEmpty()) {
Filess.write( getPath( coo, name ), getBytes( txt ) );
}
}
private Path getPath( Coordinates coo, String name ) {
Path dir = _nn( Paths.get( "target/generated-sources/loracle/coordinates/" + coo.toFilename() ).toAbsolutePath() );
Filess.createDirectories( dir );
int idx = 0;
while ( true ) {
Path ret = _nn(dir.resolve( name + "-"+ idx + ".txt" ));
if( !Files.exists( ret )) {
return ret;
}
idx++;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy