diff --git a/mbi/jurand/src/org/fedoraproject/mbi/tool/jurand/JurandTool.java b/mbi/jurand/src/org/fedoraproject/mbi/tool/jurand/JurandTool.java new file mode 100644 index 0000000..a4a7646 --- /dev/null +++ b/mbi/jurand/src/org/fedoraproject/mbi/tool/jurand/JurandTool.java @@ -0,0 +1,83 @@ +/*- + * Copyright (c) 2024 Red Hat, Inc. + * + * 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.fedoraproject.mbi.tool.jurand; + +import java.lang.ProcessBuilder.Redirect; +import java.nio.file.Files; +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.io.file.PathUtils; +import org.fedoraproject.mbi.tool.Instruction; +import org.fedoraproject.mbi.tool.Tool; + +/** + * @author Mikolaj Izdebski + */ +public class JurandTool + extends Tool +{ + private final List cmd = new ArrayList<>(); + + @Override + public void initialize() + throws Exception + { + Files.createDirectories( getGeneratedSourcesDir() ); + cmd.add( "jurand" ); + cmd.add( "-i" ); + cmd.add( "-s" ); + cmd.add( "-a" ); + } + + @Instruction + public void source( String source ) + throws Exception + { + PathUtils.copyDirectory( getSourceRootDir().resolve( source ), getGeneratedSourcesDir() ); + } + + @Instruction + public void name( String name ) + { + cmd.add( "-n" ); + cmd.add( name ); + } + + @Instruction + public void pattern( String pattern ) + { + cmd.add( "-p" ); + cmd.add( pattern ); + } + + @Override + public void execute() + throws Exception + { + cmd.add( getGeneratedSourcesDir().toString() ); + ProcessBuilder pb = new ProcessBuilder( cmd ); + pb.redirectInput( Redirect.PIPE ); + pb.redirectOutput( getTargetDir().resolve( "jurand-stdout.log" ).toFile() ); + pb.redirectError( getTargetDir().resolve( "jurand-stderr.log" ).toFile() ); + Process process = pb.start(); + int exitCode = process.waitFor(); + if ( exitCode != 0 ) + { + throw new RuntimeException( "jurand failed with exit code " + exitCode ); + } + } +} diff --git a/project/byte-buddy.xml b/project/byte-buddy.xml index e1152fc..1cb489f 100644 --- a/project/byte-buddy.xml +++ b/project/byte-buddy.xml @@ -7,18 +7,12 @@ asm asm-commons - - - [copy todir="${generatedSources}"] - [fileset dir="${basedir}/byte-buddy-dep/src/main/java"/] - [fileset dir="${basedir}/byte-buddy-agent/src/main/java"/] - [/copy] - [exec executable="jurand" dir="${generatedSources}" failonerror="true" logerror="true"] - [arg line="-i -a ."/] - [arg line="-n SuppressFBWarnings -p javax\.annotation\."/] - [/exec] - - + + byte-buddy-dep/src/main/java + byte-buddy-agent/src/main/java + SuppressFBWarnings + javax\.annotation\. + net.bytebuddy diff --git a/project/guava.xml b/project/guava.xml index 3ea344d..9f57110 100644 --- a/project/guava.xml +++ b/project/guava.xml @@ -5,20 +5,13 @@ jsr-305 - - - [copy todir="${generatedSources}"] - [fileset dir="${basedir}/guava/src"/] - [/copy] - [exec executable="jurand" dir="${generatedSources}" failonerror="true" logerror="true"] - [arg line="-i -a ."/] - [arg line="-p ^org.checkerframework."/] - [arg line="-p ^com.google.common.annotations."/] - [arg line="-p ^com.google.errorprone.annotations."/] - [arg line="-p ^com.google.j2objc.annotations."/] - [/exec] - - + + guava/src + ^org.checkerframework. + ^com.google.common.annotations. + ^com.google.errorprone.annotations. + ^com.google.j2objc.annotations. + futures/failureaccess/src diff --git a/project/guice.xml b/project/guice.xml index 4a52ba3..7937d39 100644 --- a/project/guice.xml +++ b/project/guice.xml @@ -10,19 +10,12 @@ aopalliance jsr-305 - - - [copy todir="${generatedSources}"] - [fileset dir="${basedir}/core/src"/] - [/copy] - [exec executable="jurand" dir="${generatedSources}" failonerror="true" logerror="true"] - [arg line="-s -i -a ."/] - [arg line="-p ^com.google.common.annotations."/] - [arg line="-p ^com.google.errorprone.annotations."/] - [arg line="-p ^javax.annotation.concurrent."/] - [/exec] - - + + core/src + ^com.google.common.annotations. + ^com.google.errorprone.annotations. + ^javax.annotation.concurrent. + extensions/servlet/src diff --git a/project/jsoup.xml b/project/jsoup.xml index 5689376..d109677 100644 --- a/project/jsoup.xml +++ b/project/jsoup.xml @@ -4,17 +4,10 @@ - - - [copy todir="${generatedSources}"] - [fileset dir="${basedir}/src/main/java"/] - [/copy] - [exec executable="jurand" dir="${generatedSources}" failonerror="true" logerror="true"] - [arg line="-i -a ."/] - [arg line="-p ^javax\.annotation\."/] - [/exec] - - + + src/main/java + ^javax\.annotation\. + diff --git a/project/mbi.xml b/project/mbi.xml index 5cf469b..27066aa 100644 --- a/project/mbi.xml +++ b/project/mbi.xml @@ -164,4 +164,16 @@ + + mbi-jurand + jurand + mbi-core + commons-io + + + 11 + src + + + diff --git a/project/xmlunit.xml b/project/xmlunit.xml index 3252917..83848c2 100644 --- a/project/xmlunit.xml +++ b/project/xmlunit.xml @@ -6,18 +6,11 @@ hamcrest assertj-core - + - - [copy todir="${generatedSources}"] - [fileset dir="${basedir}/xmlunit-matchers/src/main/java"/] - [/copy] - [exec executable="jurand" dir="${generatedSources}" failonerror="true" logerror="true"] - [arg line="-i -a -s ."/] - [arg line="-p ^org.hamcrest.Factory"/] - [/exec] - - + xmlunit-matchers/src/main/java + ^org.hamcrest.Factory + xmlunit-core/src/main/java xmlunit-assertj3/src/main/java