Skip to content

Commit

Permalink
[FELIX-6074] Do not analyze dependencies before the upToDate check
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1854551 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
gnodet committed Feb 28, 2019
1 parent e12e94c commit 9487647
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class AntPlugin extends BundlePlugin

@Override
protected void execute( Map<String, String> originalInstructions,
Jar[] classpath ) throws MojoExecutionException
ClassPathItem[] classpath ) throws MojoExecutionException
{
final String artifactId = getProject().getArtifactId();
final String baseDir = getProject().getBasedir().getPath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ protected boolean reportErrors( String prefix, Analyzer analyzer )


protected void execute(Map<String, String> originalInstructions,
Jar[] classpath) throws MojoExecutionException
ClassPathItem[] classpath) throws MojoExecutionException
{
try
{
Expand Down Expand Up @@ -512,7 +512,7 @@ else if ( customPackaging )


protected Builder getOSGiBuilder( MavenProject currentProject, Map<String, String> originalInstructions,
Jar[] classpath ) throws Exception
ClassPathItem[] classpath ) throws Exception
{
Properties properties = new Properties();
properties.putAll( getDefaultProperties( currentProject ) );
Expand Down Expand Up @@ -589,7 +589,11 @@ protected Builder getOSGiBuilder( MavenProject currentProject, Map<String, Strin
builder.setProperties( sanitize( properties ) );
if ( classpath != null )
{
builder.setClasspath( classpath );
Jar[] jars = new Jar[ classpath.length ];
for ( int i = 0; i < classpath.length; i++ ) {
jars[i] = new Jar( classpath[i].id, classpath[i].file );
}
builder.setClasspath( jars );
}

return builder;
Expand Down Expand Up @@ -916,7 +920,7 @@ public boolean updateExcludesInDeps( MavenProject project, List<Dependency> depe


protected Builder buildOSGiBundle(MavenProject currentProject, Map<String, String> originalInstructions,
Jar[] classpath) throws Exception
ClassPathItem[] classpath) throws Exception
{
Builder builder = getOSGiBuilder( currentProject, originalInstructions, classpath );

Expand Down Expand Up @@ -1574,14 +1578,14 @@ private void doMavenMetadata( MavenProject currentProject, Jar jar ) throws IOEx
}


protected Jar[] getClasspath(MavenProject currentProject) throws IOException, MojoExecutionException
protected ClassPathItem[] getClasspath(MavenProject currentProject) throws IOException, MojoExecutionException
{
List<Jar> list = new ArrayList<Jar>( currentProject.getArtifacts().size() + 1 );
List<ClassPathItem> list = new ArrayList<ClassPathItem>( currentProject.getArtifacts().size() + 1 );

String d = currentProject.getBuild() != null ? currentProject.getBuild().getOutputDirectory() : null;
if ( d != null )
{
list.add( new Jar( ".", d ) );
list.add( new ClassPathItem( ".", new File( d ) ) );
}

final Collection<Artifact> artifacts = getSelectedDependencies(currentProject.getArtifacts() );
Expand All @@ -1597,11 +1601,11 @@ protected Jar[] getClasspath(MavenProject currentProject) throws IOException, Mo
+ currentProject.getArtifact() );
continue;
}
Jar jar = new Jar( artifact.getArtifactId(), file );
ClassPathItem jar = new ClassPathItem( artifact.getArtifactId(), file );
list.add( jar );
}
}
Jar[] cp = new Jar[list.size()];
ClassPathItem[] cp = new ClassPathItem[list.size()];
list.toArray( cp );

return cp;
Expand Down Expand Up @@ -2139,4 +2143,13 @@ protected static void includeJava9Fixups(MavenProject currentProject, Analyzer a
analyzer.setProperty(Analyzer.FIXUPMESSAGES, fixups);
}

static class ClassPathItem {
final String id;
final File file;

public ClassPathItem(String id, File file) {
this.id = id;
this.file = file;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
public class InstructionsPlugin extends BundlePlugin
{
@Override
protected void execute( Map<String, String> instructions, Jar[] classpath )
protected void execute( Map<String, String> instructions, ClassPathItem[] classpath )
throws MojoExecutionException
{
if ( dumpInstructions == null )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public class ManifestPlugin extends BundlePlugin
private BuildContext buildContext;

@Override
protected void execute( Map<String, String> instructions, Jar[] classpath )
protected void execute( Map<String, String> instructions, ClassPathItem[] classpath )
throws MojoExecutionException
{

Expand Down Expand Up @@ -180,14 +180,14 @@ private boolean containsJavaFile(Scanner scanner) {
return scanner.getIncludedFiles().length > 0;
}

public Manifest getManifest( MavenProject project, Jar[] classpath ) throws IOException, MojoFailureException,
public Manifest getManifest( MavenProject project, ClassPathItem[] classpath ) throws IOException, MojoFailureException,
MojoExecutionException, Exception
{
return getManifest( project, new LinkedHashMap<String, String>(), classpath, buildContext );
}


public Manifest getManifest( MavenProject project, Map<String, String> instructions, Jar[] classpath,
public Manifest getManifest( MavenProject project, Map<String, String> instructions, ClassPathItem[] classpath,
BuildContext buildContext ) throws IOException, MojoFailureException, MojoExecutionException, Exception
{
Analyzer analyzer = getAnalyzer(project, instructions, classpath);
Expand Down Expand Up @@ -249,14 +249,14 @@ private static void writeSCR(Resource resource, File destination, BuildContext b
}
}

protected Analyzer getAnalyzer( MavenProject project, Jar[] classpath ) throws IOException, MojoExecutionException,
protected Analyzer getAnalyzer( MavenProject project, ClassPathItem[] classpath ) throws IOException, MojoExecutionException,
Exception
{
return getAnalyzer( project, new LinkedHashMap<>(), classpath );
}


protected Analyzer getAnalyzer( MavenProject project, Map<String, String> instructions, Jar[] classpath )
protected Analyzer getAnalyzer( MavenProject project, Map<String, String> instructions, ClassPathItem[] classpath )
throws IOException, MojoExecutionException, Exception
{
if ( rebuildBundle && supportedProjectTypes.contains( project.getArtifact().getType() ) )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.util.TreeMap;
import java.util.jar.Manifest;

import org.apache.felix.bundleplugin.BundlePlugin.ClassPathItem;
import org.apache.maven.model.Organization;
import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
import org.apache.maven.project.MavenProject;
Expand Down Expand Up @@ -346,7 +347,7 @@ public void testEmbedDependencyMissingNegativeKey() throws Exception
MavenProject project = getMavenProjectStub();
project.setDependencyArtifacts(artifacts);
Properties props = new Properties();
Jar[] classpath = plugin.getClasspath(project);
ClassPathItem[] classpath = plugin.getClasspath(project);

Map instructions1 = new HashMap();
instructions1.put( DependencyEmbedder.EMBED_DEPENDENCY, "!scope=compile" );
Expand Down

0 comments on commit 9487647

Please sign in to comment.