Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement dedicated jurand tool #155

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions mbi/jurand/src/org/fedoraproject/mbi/tool/jurand/JurandTool.java
Original file line number Diff line number Diff line change
@@ -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<String> 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 );
}
}
}
18 changes: 6 additions & 12 deletions project/byte-buddy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,12 @@
<dependency>asm</dependency>
<dependency>asm-commons</dependency>
<build>
<ant>
<run>
[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]
</run>
</ant>
<jurand>
<source>byte-buddy-dep/src/main/java</source>
<source>byte-buddy-agent/src/main/java</source>
<name>SuppressFBWarnings</name>
<pattern>javax\.annotation\.</pattern>
</jurand>
<compiler>
<automaticModuleName>net.bytebuddy</automaticModuleName>
</compiler>
Expand Down
21 changes: 7 additions & 14 deletions project/guava.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,13 @@
<module>
<dependency>jsr-305</dependency>
<build>
<ant>
<run>
[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]
</run>
</ant>
<jurand>
<source>guava/src</source>
<pattern>^org.checkerframework.</pattern>
<pattern>^com.google.common.annotations.</pattern>
<pattern>^com.google.errorprone.annotations.</pattern>
<pattern>^com.google.j2objc.annotations.</pattern>
</jurand>
<compiler>
<accessInternalJavaAPI/>
<addSourceRoot>futures/failureaccess/src</addSourceRoot>
Expand Down
19 changes: 6 additions & 13 deletions project/guice.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,12 @@
<dependency>aopalliance</dependency>
<dependency>jsr-305</dependency>
<build>
<ant>
<run>
[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]
</run>
</ant>
<jurand>
<source>core/src</source>
<pattern>^com.google.common.annotations.</pattern>
<pattern>^com.google.errorprone.annotations.</pattern>
<pattern>^javax.annotation.concurrent.</pattern>
</jurand>
<compiler>
<addSourceRoot>extensions/servlet/src</addSourceRoot>
</compiler>
Expand Down
15 changes: 4 additions & 11 deletions project/jsoup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,10 @@
</licensing>
<module>
<build>
<ant>
<run>
[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]
</run>
</ant>
<jurand>
<source>src/main/java</source>
<pattern>^javax\.annotation\.</pattern>
</jurand>
<compiler/>
</build>
</module>
Expand Down
12 changes: 12 additions & 0 deletions project/mbi.xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,16 @@
</compiler>
</build>
</module>
<module>
<name>mbi-jurand</name>
<subDir>jurand</subDir>
<dependency>mbi-core</dependency>
<dependency>commons-io</dependency>
<build>
<compiler>
<release>11</release>
<addSourceRoot>src</addSourceRoot>
</compiler>
</build>
</module>
</project>
15 changes: 4 additions & 11 deletions project/xmlunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,11 @@
<dependency>hamcrest</dependency>
<dependency>assertj-core</dependency>
<build>
<ant>
<jurand>
<!-- Port to hamcrest 2.1 -->
<run>
[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]
</run>
</ant>
<source>xmlunit-matchers/src/main/java</source>
<pattern>^org.hamcrest.Factory</pattern>
</jurand>
<compiler>
<addSourceRoot>xmlunit-core/src/main/java</addSourceRoot>
<addSourceRoot>xmlunit-assertj3/src/main/java</addSourceRoot>
Expand Down
Loading