xmvn/xmvn-effective-pom.patch
Mikolaj Izdebski e176466b18 Install effective POMs into a separate directory
With this patch XMvn MOJO will install raw POMs into
/usr/share/maven-poms as this was always done.

Additionally effective POMs will be installed into some other location
(perhaps /usr/share/maven-fragments) for every non-POM artifact.
2013-02-25 09:16:27 +01:00

85 lines
4.0 KiB
Diff

diff --git a/xmvn-core/src/main/java/org/fedoraproject/maven/Configuration.java b/xmvn-core/src/main/java/org/fedoraproject/maven/Configuration.java
index 8c5e8a6..b2996a3 100644
--- a/xmvn-core/src/main/java/org/fedoraproject/maven/Configuration.java
+++ b/xmvn-core/src/main/java/org/fedoraproject/maven/Configuration.java
@@ -114,6 +114,13 @@ public class Configuration
return Paths.get( installPomDir );
}
+ private static String installEffectivePomDir = "usr/share/maven-effective-poms";
+
+ public static Path getInstallEffectivePomDir()
+ {
+ return Paths.get( installEffectivePomDir );
+ }
+
private static String installDepmapDir = "usr/share/maven-fragments";
public static Path getInstallDepmapDir()
diff --git a/xmvn-mojo/src/main/java/org/fedoraproject/maven/rpminstall/plugin/InstallMojo.java b/xmvn-mojo/src/main/java/org/fedoraproject/maven/rpminstall/plugin/InstallMojo.java
index 39a8db4..09e127d 100644
--- a/xmvn-mojo/src/main/java/org/fedoraproject/maven/rpminstall/plugin/InstallMojo.java
+++ b/xmvn-mojo/src/main/java/org/fedoraproject/maven/rpminstall/plugin/InstallMojo.java
@@ -66,7 +66,6 @@ public class InstallMojo
Path jppGroup;
Path jppName;
- Path pomFile;
DependencyVisitor metadata = targetPackage.getMetadata();
if ( file != null )
@@ -77,11 +76,7 @@ public class InstallMojo
+ "\" has unsupported extension. The only supported extension is \".jar\"" );
}
- pomFile = Files.createTempFile( "xmvn-" + artifactId + "-", ".pom.xml" );
- DependencyExtractor.simplifyEffectiveModel( project.getModel() );
- DependencyExtractor.writeModel( project.getModel(), pomFile );
List<Path> extraList = new LinkedList<>();
-
for ( Rule rule : Configuration.getInstallFiles() )
{
String name = rule.match( groupId, artifactId, version );
@@ -101,10 +96,14 @@ public class InstallMojo
targetPackage.addJarFile( file, baseFile, extraList );
DependencyExtractor.getJavaCompilerTarget( project, metadata );
+
+ Path effectivePomFile = Files.createTempFile( "xmvn-" + artifactId + "-", ".pom.xml" );
+ DependencyExtractor.simplifyEffectiveModel( project.getModel() );
+ DependencyExtractor.writeModel( project.getModel(), effectivePomFile );
+ targetPackage.addEffectivePomFile( effectivePomFile, jppGroup, jppName );
}
else
{
- pomFile = project.getFile().toPath();
jppGroup = Paths.get( "JPP" ).resolve( Configuration.getInstallName() );
jppName = Paths.get( groupId + "@" + artifactId );
@@ -112,7 +111,7 @@ public class InstallMojo
DependencyExtractor.generateRawRequires( rawModel, metadata );
}
- targetPackage.addPomFile( pomFile, jppGroup, jppName );
+ targetPackage.addPomFile( project.getFile().toPath(), jppGroup, jppName );
targetPackage.createDepmaps( groupId, artifactId, version, jppGroup, jppName );
DependencyExtractor.generateEffectiveRuntimeRequires( project.getModel(), metadata );
diff --git a/xmvn-mojo/src/main/java/org/fedoraproject/maven/rpminstall/plugin/Package.java b/xmvn-mojo/src/main/java/org/fedoraproject/maven/rpminstall/plugin/Package.java
index a228971..2df3434 100644
--- a/xmvn-mojo/src/main/java/org/fedoraproject/maven/rpminstall/plugin/Package.java
+++ b/xmvn-mojo/src/main/java/org/fedoraproject/maven/rpminstall/plugin/Package.java
@@ -86,6 +86,12 @@ public class Package
addFile( file, Configuration.getInstallPomDir(), pomName, 0644 );
}
+ public void addEffectivePomFile( Path file, Path jppGroupId, Path jppArtifactId )
+ {
+ Path pomName = Paths.get( jppGroupId.toString().replace( '/', '.' ) + "-" + jppArtifactId + ".pom" );
+ addFile( file, Configuration.getInstallEffectivePomDir(), pomName, 0644 );
+ }
+
private static boolean containsNativeCode( Path jar )
throws IOException
{