Drop support for local mode

This commit is contained in:
Mikolaj Izdebski 2013-01-25 01:50:17 +01:00
parent e1deac7d72
commit 2cf4fd6a25
15 changed files with 75 additions and 1505 deletions

View File

@ -1,28 +0,0 @@
From d0dbdcde31414336340a5089fecf4f93cb5125ad Mon Sep 17 00:00:00 2001
From: Stanislav Ochotnicky <sochotnicky@redhat.com>
Date: Tue, 12 Oct 2010 16:56:50 +0200
Subject: [PATCH 1/6] Add plugin-api deps
---
maven-plugin-api/pom.xml | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/maven-plugin-api/pom.xml b/maven-plugin-api/pom.xml
index abc2065..efea352 100644
--- a/maven-plugin-api/pom.xml
+++ b/maven-plugin-api/pom.xml
@@ -52,6 +52,11 @@ under the License.
<groupId>org.sonatype.sisu</groupId>
<artifactId>sisu-inject-plexus</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ <version>1.0.0</version>
+ </dependency>
</dependencies>
<build>
--
1.7.7.6

View File

@ -1,104 +0,0 @@
From c7d89b31e7764c514138135f91b2e290d410ebc7 Mon Sep 17 00:00:00 2001
From: Mikolaj Izdebski <mizdebsk@redhat.com>
Date: Thu, 22 Nov 2012 15:28:28 +0100
Subject: [PATCH] Customize compiler plugin
In local mode require source to be >= 1.5 and target >= source.
---
.../model/validation/DefaultModelValidator.java | 68 ++++++++++++++++++++++
1 file changed, 68 insertions(+)
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java b/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
index 6c76173..bc0b836 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
@@ -19,6 +19,10 @@ package org.apache.maven.model.validation;
* under the License.
*/
+import java.math.BigDecimal;
+import java.util.LinkedList;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+
import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
@@ -342,6 +346,8 @@ public class DefaultModelValidator
"distributionManagement.snapshotRepository", request );
}
}
+
+ customizeModel( model );
}
private void validateRawDependencies( ModelProblemCollector problems, List<Dependency> dependencies, String prefix,
@@ -924,4 +930,66 @@ public class DefaultModelValidator
}
}
+ private void customizeModel( Model model )
+ {
+ // Enable model customizations only in local mode
+ if ( System.getProperty( "maven.local.mode" ) == null )
+ return;
+
+ Build build = model.getBuild();
+ if ( build == null )
+ return;
+
+ List<Plugin> plugins = build.getPlugins();
+ if ( plugins == null )
+ return;
+
+ for ( Plugin plugin : plugins )
+ {
+ String groupId = plugin.getGroupId();
+ String artifactId = plugin.getArtifactId();
+
+ if ( groupId.equals( "org.apache.maven.plugins" ) && artifactId.equals( "maven-compiler-plugin" ) )
+ customizeCompilerPlugin( plugin );
+ }
+ }
+
+ private void customizeCompilerPlugin( Plugin plugin )
+ {
+ List<Object> configurations = new LinkedList<Object>();
+ configurations.add( plugin.getConfiguration() );
+
+ List<PluginExecution> executions = plugin.getExecutions();
+ for ( PluginExecution exec : executions )
+ configurations.add( exec.getConfiguration() );
+
+ for ( Object configObj : configurations )
+ {
+ try
+ {
+ Xpp3Dom config = (Xpp3Dom) configObj;
+ BigDecimal source = new BigDecimal( config.getChild( "source" ).getValue() );
+ BigDecimal target = new BigDecimal( config.getChild( "target" ).getValue() );
+
+ // Source must be at least 1.5
+ BigDecimal minSource = new BigDecimal( "1.5" );
+ if ( source.compareTo( minSource ) < 0 )
+ source = minSource;
+
+ // Target must not be less than source
+ if ( target.compareTo( source ) < 0 )
+ target = source;
+
+ config.getChild( "source" ).setValue( source.toString() );
+ config.getChild( "target" ).setValue( target.toString() );
+ }
+ catch ( NullPointerException e )
+ {
+ }
+ catch ( NumberFormatException e )
+ {
+ }
+ }
+ }
+
}
--
1.7.11.7

View File

@ -1,224 +0,0 @@
From 46e6dbc205065a670fa3b6e7c41e02e30b2fdb7a Mon Sep 17 00:00:00 2001
From: Stanislav Ochotnicky <sochotnicky@redhat.com>
Date: Tue, 18 Jan 2011 11:09:32 +0100
Subject: [PATCH 2/6] Use custom resolver
WorkspaceReader is used to resolve main dependencies, but we had to
add this resolve to ProjectModelResolver and DefaultModelResolver as
well because these are instantiated early and used to build model of
project when WorkspaceReader is not available yet.
---
.../repository/internal/DefaultModelResolver.java | 9 +++++++++
.../org/apache/maven/artifact/ArtifactUtils.java | 10 ++++++++--
.../main/java/org/apache/maven/DefaultMaven.java | 7 +++++++
.../apache/maven/plugin/MavenPluginValidator.java | 5 ++++-
.../internal/DefaultPluginVersionResolver.java | 9 +++++++++
.../apache/maven/project/ProjectModelResolver.java | 9 +++++++++
.../project/artifact/MavenMetadataSource.java | 9 +++++++++
.../model/validation/DefaultModelValidator.java | 16 +++++++++++++---
8 files changed, 68 insertions(+), 6 deletions(-)
diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelResolver.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelResolver.java
index 96b9fc3..f30bf94 100644
--- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelResolver.java
+++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelResolver.java
@@ -40,6 +40,7 @@ import org.sonatype.aether.repository.RemoteRepository;
import org.sonatype.aether.resolution.ArtifactRequest;
import org.sonatype.aether.resolution.ArtifactResolutionException;
import org.sonatype.aether.util.artifact.DefaultArtifact;
+import org.apache.maven.artifact.resolver.JavadirWorkspaceReader;
/**
* A model resolver to assist building of dependency POMs. This resolver gives priority to those repositories that have
@@ -114,6 +115,14 @@ class DefaultModelResolver
throws UnresolvableModelException
{
Artifact pomArtifact = new DefaultArtifact( groupId, artifactId, "", "pom", version );
+ if ( System.getProperty("maven.local.mode") != null) {
+ JavadirWorkspaceReader wReader = new JavadirWorkspaceReader();
+ File pomFile = wReader.findArtifact(pomArtifact);
+ // if pom file does not exist continue resolving using different
+ // resolvers (maybe they will have more luck)
+ if ( pomFile != null )
+ return new FileModelSource( pomFile );
+ }
try
{
diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/ArtifactUtils.java b/maven-artifact/src/main/java/org/apache/maven/artifact/ArtifactUtils.java
index 8efc45c..df7d4e9 100644
--- a/maven-artifact/src/main/java/org/apache/maven/artifact/ArtifactUtils.java
+++ b/maven-artifact/src/main/java/org/apache/maven/artifact/ArtifactUtils.java
@@ -99,12 +99,18 @@ public final class ArtifactUtils
{
throw new NullPointerException( "artifactId is null" );
}
- if ( version == null )
+ // in local mode we ignore versions because these would only cause
+ // problems
+ if ( version == null && System.getProperty("maven.local.mode") == null )
{
throw new NullPointerException( "version is null" );
}
- return groupId + ":" + artifactId + ":" + version;
+ if( System.getProperty("maven.local.mode") == null || version != null) {
+ return groupId + ":" + artifactId + ":" + version;
+ } else {
+ return versionlessKey(groupId, artifactId);
+ }
}
public static Map<String, Artifact> artifactMapByVersionlessId( Collection<Artifact> artifacts )
diff --git a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
index cd944a8..7bff4a0 100644
--- a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
+++ b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
@@ -56,6 +56,7 @@ import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.project.ProjectBuildingRequest;
import org.apache.maven.project.ProjectBuildingResult;
import org.apache.maven.project.ProjectSorter;
+import org.apache.maven.artifact.resolver.JavadirWorkspaceReader;
import org.apache.maven.repository.DelegatingLocalArtifactRepository;
import org.apache.maven.repository.LocalRepositoryNotAccessibleException;
import org.apache.maven.settings.Mirror;
@@ -375,6 +376,12 @@ public class DefaultMaven
session.setWorkspaceReader( workspaceRepository );
}
+ // Set our own workspace reader to resolve from /usr/share/java
+ if ( System.getProperty("maven.local.mode") != null)
+ {
+ session.setWorkspaceReader(new JavadirWorkspaceReader());
+ }
+
DefaultSettingsDecryptionRequest decrypt = new DefaultSettingsDecryptionRequest();
decrypt.setProxies( request.getProxies() );
decrypt.setServers( request.getServers() );
diff --git a/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginValidator.java b/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginValidator.java
index 2eb2738..28fcdd9 100644
--- a/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginValidator.java
+++ b/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginValidator.java
@@ -60,7 +60,10 @@ public class MavenPluginValidator
errors.add( "Plugin's descriptor contains the wrong artifact ID: " + pluginDescriptor.getArtifactId() );
}
- if ( !pluginArtifact.getBaseVersion().equals( pluginDescriptor.getVersion() ) )
+ // ignore incorrect version in local mode (we can have different
+ // versions in /usr/share/java
+ if ( !pluginArtifact.getBaseVersion().equals( pluginDescriptor.getVersion() )
+ && System.getProperty("maven.local.mode") == null)
{
errors.add( "Plugin's descriptor contains the wrong version: " + pluginDescriptor.getVersion() );
}
diff --git a/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResolver.java b/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResolver.java
index a215d28..754406a 100644
--- a/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResolver.java
+++ b/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResolver.java
@@ -89,6 +89,15 @@ public class DefaultPluginVersionResolver
throws PluginVersionResolutionException
{
logger.debug( "Resolving plugin version for " + request.getGroupId() + ":" + request.getArtifactId() );
+ if (System.getProperty("maven.local.mode") != null) {
+ // in local mode we always use "latest" as a resolved version
+ // (we ignore it anyway)
+ DefaultPluginVersionResult result = new DefaultPluginVersionResult("latest");
+ result.setRepository(request.getRepositorySession().getWorkspaceReader().getRepository());
+ logger.debug( "Resolved plugin version for " + request.getGroupId() + ":" + request.getArtifactId()
+ + " to latest from repository " + result.getRepository());
+ return result;
+ }
PluginVersionResult result = resolveFromProject( request );
diff --git a/maven-core/src/main/java/org/apache/maven/project/ProjectModelResolver.java b/maven-core/src/main/java/org/apache/maven/project/ProjectModelResolver.java
index e6cc411..bab7885 100644
--- a/maven-core/src/main/java/org/apache/maven/project/ProjectModelResolver.java
+++ b/maven-core/src/main/java/org/apache/maven/project/ProjectModelResolver.java
@@ -42,6 +42,7 @@ import org.sonatype.aether.repository.RemoteRepository;
import org.sonatype.aether.resolution.ArtifactRequest;
import org.sonatype.aether.resolution.ArtifactResolutionException;
import org.sonatype.aether.util.artifact.DefaultArtifact;
+import org.apache.maven.artifact.resolver.JavadirWorkspaceReader;
/**
* A model resolver to assist building of projects. This resolver gives priority to those repositories that have been
@@ -147,6 +148,14 @@ class ProjectModelResolver
if ( pomFile == null )
{
Artifact pomArtifact = new DefaultArtifact( groupId, artifactId, "", "pom", version );
+ if ( System.getProperty("maven.local.mode") != null) {
+ JavadirWorkspaceReader wReader = new JavadirWorkspaceReader();
+ pomFile = wReader.findArtifact(pomArtifact);
+ // if pom file does not exist continue resolving using different resolvers
+ // (maybe they will have more luck)
+ if ( pomFile != null)
+ return new FileModelSource( pomFile );
+ }
try
{
diff --git a/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java b/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
index 919f0ee..68a509d 100644
--- a/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
+++ b/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
@@ -325,6 +325,15 @@ public class MavenMetadataSource
return null;
}
+ // this is a workaround for 669034
+ // Seems like plexus-container-default has some quirks that
+ // cause it to lose version. Needs more looking into and fix it
+ // properly
+ if (dependency.getVersion() == null && System.getProperty("maven.local.mode") != null)
+ {
+ System.out.println("FIXING NULL VERSION:" + dependency.getGroupId() + ":" + dependency.getArtifactId() + ":" + dependency.getVersion());
+ dependency.setVersion("1.0.0");
+ }
VersionRange versionRange = VersionRange.createFromVersionSpec( dependency.getVersion() );
Artifact dependencyArtifact =
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java b/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
index d7a6ac9..6c76173 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
@@ -433,7 +433,11 @@ public class DefaultModelValidator
if ( !management )
{
- validateVersion( prefix + "version", problems, errOn30, d.getVersion(), d.getManagementKey(), d );
+ // in local mode set version to "latest" and validate
+ if(System.getProperty("maven.local.mode") != null && d.getVersion() == null)
+ d.setVersion("latest");
+ else
+ validateVersion( prefix + "version", problems, errOn30, d.getVersion(), d.getManagementKey(), d );
/*
* TODO: Extensions like Flex Mojos use custom scopes like "merged", "internal", "external", etc.
@@ -461,7 +465,11 @@ public class DefaultModelValidator
{
validateEffectiveDependency( problems, d, false, prefix, request );
- validateVersion( prefix + "version", problems, errOn30, d.getVersion(), d.getManagementKey(), d );
+ // in local mode set version to "latest" and validate
+ if(System.getProperty("maven.local.mode") != null && d.getVersion() == null)
+ d.setVersion("latest");
+ else
+ validateVersion( prefix + "version", problems, errOn30, d.getVersion(), d.getManagementKey(), d );
validateEnum( prefix + "scope", problems, errOn30, d.getScope(), d.getManagementKey(), d, "compile",
"runtime", "system" );
@@ -480,7 +488,9 @@ public class DefaultModelValidator
{
validateStringNotEmpty( prefix + "type", problems, Severity.ERROR, d.getType(), d.getManagementKey(), d );
- validateStringNotEmpty( prefix + "version", problems, Severity.ERROR, d.getVersion(), d.getManagementKey(),
+ // in local mode ignore missing version completely
+ if(System.getProperty("maven.local.mode") == null)
+ validateStringNotEmpty( prefix + "version", problems, Severity.ERROR, d.getVersion(), d.getManagementKey(),
d );
}
--
1.7.7.6

View File

@ -1,24 +0,0 @@
From b38e59d0512fed8f376fcbdea71204b04cdee1cb Mon Sep 17 00:00:00 2001
From: Stanislav Ochotnicky <sochotnicky@redhat.com>
Date: Mon, 22 Aug 2011 15:59:53 +0200
Subject: [PATCH 3/6] Use utf-8 source encoding
---
pom.xml | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/pom.xml b/pom.xml
index 3aacefc..8cba9cc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -65,6 +65,7 @@
<siteDeployUrl>scp://people.apache.org/www/maven.apache.org/ref/${project.version}/</siteDeployUrl>
<siteUrl>http://maven.apache.org/ref/${project.version}/</siteUrl>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<mailingLists>
--
1.7.7.6

View File

@ -1,160 +0,0 @@
From ed8122f5538d9000cd8a8579be8a107249e7b022 Mon Sep 17 00:00:00 2001
From: Stanislav Ochotnicky <sochotnicky@redhat.com>
Date: Tue, 30 Aug 2011 11:44:42 +0200
Subject: [PATCH 4/6] Fix text scope skipping with maven.test.skip
Previously maven put test dependencies into dependency graph even when
"maven.test.skip" was true, therefore. This patch fixes that with few
caveats:
maven-compat was changed so plugins using old api work like this as
well. We removed test deps from "artifacts" Set in
DefaultArtifactResolver if maven.test.skip system property is found.
We created new DependencySelector. Currently it's in wrong place and
possibly has other problems (never going to get upstreamed like
this). But as a hack this works OK.
Main problem: Is using "maven.test.skip" string literally OK? Also,
literally referencing "test" scope is probably not 100% clean.
---
.../artifact/resolver/DefaultArtifactResolver.java | 18 ++++++
.../main/java/org/apache/maven/DefaultMaven.java | 6 +-
.../maven/SkipTestScopeDependencySelector.java | 72 ++++++++++++++++++++++
3 files changed, 95 insertions(+), 1 deletion(-)
create mode 100644 maven-core/src/main/java/org/apache/maven/SkipTestScopeDependencySelector.java
diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
index 9c8364d..761ff92 100644
--- a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
+++ b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
@@ -460,6 +460,24 @@ public class DefaultArtifactResolver
return result;
}
+ // When we find maven.test.skip property we remove dependencies
+ // with scope "test" from artifact set. Current implementation
+ // of artifacts doesn't implement "remove" method so create a
+ // new object and copy non-test artifacts there
+ if (System.getProperty("maven.local.mode") != null &&
+ System.getProperty("maven.test.skip") != null) {
+ Set<Artifact> newArtifacts = new LinkedHashSet<Artifact>();
+ for (Artifact artifact: artifacts)
+ {
+ String scope = artifact.getScope();
+ if (scope == null || !scope.equals("test"))
+ {
+ newArtifacts.add(artifact);
+ }
+ }
+ artifacts = newArtifacts;
+ }
+
// After the collection we will have the artifact object in the result but they will not be resolved yet.
result =
artifactCollector.collect( artifacts, rootArtifact, managedVersions, collectionRequest, source,
diff --git a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
index 7bff4a0..71bbd29 100644
--- a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
+++ b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
@@ -31,6 +31,7 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
+import org.apache.maven.SkipTestScopeDependencySelector;
import org.apache.maven.artifact.ArtifactUtils;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
import org.apache.maven.eventspy.internal.EventSpyDispatcher;
@@ -449,7 +450,10 @@ public class DefaultMaven
DependencySelector depFilter =
new AndDependencySelector( new ScopeDependencySelector( "test", "provided" ), new OptionalDependencySelector(),
- new ExclusionDependencySelector() );
+ new ExclusionDependencySelector());
+ if ( System.getProperty("maven.local.mode") != null) {
+ depFilter = new AndDependencySelector(depFilter, new SkipTestScopeDependencySelector() );
+ }
session.setDependencySelector( depFilter );
DependencyGraphTransformer transformer =
diff --git a/maven-core/src/main/java/org/apache/maven/SkipTestScopeDependencySelector.java b/maven-core/src/main/java/org/apache/maven/SkipTestScopeDependencySelector.java
new file mode 100644
index 0000000..60be724
--- /dev/null
+++ b/maven-core/src/main/java/org/apache/maven/SkipTestScopeDependencySelector.java
@@ -0,0 +1,72 @@
+package org.apache.maven;
+
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+
+import org.sonatype.aether.collection.DependencyCollectionContext;
+import org.sonatype.aether.collection.DependencySelector;
+import org.sonatype.aether.graph.Dependency;
+import org.sonatype.aether.RepositorySystemSession;
+
+/**
+ * A dependency selector that filters dependencies with scope "test"
+ * when tests are being skipped.
+ *
+ * @author Stanislav Ochotnicky
+ */
+public class SkipTestScopeDependencySelector
+ implements DependencySelector
+{
+
+ private boolean testSkip;
+
+ /**
+ * Creates a new selector
+ */
+ public SkipTestScopeDependencySelector()
+ {
+ testSkip = System.getProperty("maven.test.skip") != null ? true : false;
+ }
+
+ public boolean selectDependency( Dependency dependency )
+ {
+ if (testSkip && dependency.getScope().equals("test"))
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+ }
+
+ public DependencySelector deriveChildSelector( DependencyCollectionContext context )
+ {
+ return this;
+ }
+
+ @Override
+ public boolean equals( Object obj )
+ {
+ if ( this == obj )
+ {
+ return true;
+ }
+ else if ( null == obj || !getClass().equals( obj.getClass() ) )
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return 42;
+ }
+
+}
--
1.7.11.7

View File

@ -1,33 +0,0 @@
From 62e01ae45ea1da847e4cabdcbd64950654f9d4a5 Mon Sep 17 00:00:00 2001
From: Stanislav Ochotnicky <sochotnicky@redhat.com>
Date: Thu, 9 Feb 2012 11:11:26 +0100
Subject: [PATCH 6/6] Make compiler plugin default to source 1.5
This will help with modello problems and is generally better probably
---
pom.xml | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/pom.xml b/pom.xml
index c55f33c..fd27b03 100644
--- a/pom.xml
+++ b/pom.xml
@@ -393,6 +393,15 @@
<pluginManagement>
<plugins>
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.1</version>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-metadata</artifactId>
<version>${plexusVersion}</version>
--
1.7.7.6

View File

@ -1,198 +0,0 @@
package org.apache.maven.artifact.resolver;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.LinkedList;
import java.util.List;
import org.apache.maven.artifact.repository.MavenJPackageDepmap;
import org.sonatype.aether.artifact.Artifact;
import org.sonatype.aether.repository.WorkspaceReader;
import org.sonatype.aether.repository.WorkspaceRepository;
public class JavadirWorkspaceReader implements WorkspaceReader {
private WorkspaceRepository workspaceRepository;
private static final char GROUP_SEPARATOR = '.';
private static final char PATH_SEPARATOR = File.separatorChar;
public JavadirWorkspaceReader() {
workspaceRepository = new WorkspaceRepository("javadir-workspace");
}
public WorkspaceRepository getRepository() {
return workspaceRepository;
}
private static final String LOG_FILE = System
.getProperty("maven.resolver.logfile");
private static final java.util.concurrent.Semaphore LOG_SEMAPHORE = new java.util.concurrent.Semaphore(
1);
public File findArtifact(Artifact artifact) {
File f = findArtifactImpl(artifact);
LOG_SEMAPHORE.acquireUninterruptibly();
try {
if (LOG_FILE != null && f != null) {
java.io.FileOutputStream fos = new java.io.FileOutputStream(
LOG_FILE, true);
java.io.PrintStream ps = new java.io.PrintStream(fos);
ps.println(f.getAbsolutePath());
ps.close();
}
} catch (Exception _) {
} finally {
LOG_SEMAPHORE.release();
return f;
}
}
private File findArtifactImpl(Artifact artifact) {
MavenJPackageDepmap.debug("=============JAVADIRREADER-FIND_ARTIFACT: "
+ artifact.getArtifactId());
StringBuffer path = new StringBuffer();
File ret = new File("");
String artifactId = artifact.getArtifactId();
String groupId = artifact.getGroupId();
String version = artifact.getVersion();
String wantedVersion = new String(version);
// let's check out local repo first
String m2_path = System.getProperty("maven.repo.local");
String gid_path = groupId.replace(".", File.separator);
String art_path = m2_path + File.separator + gid_path + File.separator
+ artifactId + File.separator + version + File.separator
+ artifactId + "-" + version + "." + artifact.getExtension();
ret = new File(art_path);
if (ret.isFile()) {
MavenJPackageDepmap.debug("Returning " + art_path.toString());
return ret;
}
// maven.repo.local does not have needed GAV (that's normal), so let's
// just continue with system packages
MavenJPackageDepmap.debug("Wanted GROUPID=" + groupId);
MavenJPackageDepmap.debug("Wanted ARTIFACTID=" + artifactId);
MavenJPackageDepmap.debug("Wanted VERSION=" + version);
ArrayList<Hashtable<String, String>> maps = new ArrayList<Hashtable<String, String>>();
if (!groupId.startsWith("JPP")) {
MavenJPackageDepmap map = MavenJPackageDepmap.getInstance();
// let's try to get exact GAV first
Hashtable<String, String> newInfo = map.getMappedInfo(groupId,
artifactId, version);
if (newInfo == null) {
// exact GAV does not exist in our mapping so let's just get all
// GAs and iterate until we find one that exists. Note that only
// one non-versioned jar/pom for given GA should exist in order
// to ensure reproducibility
maps = map.getUnversionedMappedInfo(groupId, artifactId,
version);
} else {
maps.add(newInfo);
}
}
for (Hashtable<String, String> map : maps) {
groupId = map.get("group");
artifactId = map.get("artifact");
version = map.get("version");
MavenJPackageDepmap.debug("Resolved GROUPID=" + groupId);
MavenJPackageDepmap.debug("Resolved ARTIFACTID=" + artifactId);
MavenJPackageDepmap.debug("Resolved VERSION=" + version);
if (artifact.getExtension().equals("pom")) {
path = getPOMPath(groupId, artifactId, wantedVersion);
ret = new File(path.toString());
if (ret.isFile()) {
MavenJPackageDepmap.debug("Returning " + path.toString());
return ret;
}
} else {
ArrayList<String> repos = new ArrayList<String>();
String custom_paths = System.getProperty(
"maven.local.jar.paths", null);
if (custom_paths != null) {
repos.addAll(Arrays.asList(custom_paths.split(":")));
}
repos.add("/usr/share/maven/repository/");
repos.add("/usr/share/maven/repository-java-jni/");
repos.add("/usr/share/maven/repository-jni/");
String verRelativeArtifactPath = groupId + "/" + artifactId
+ "-" + wantedVersion + "." + artifact.getExtension();
String relativeArtifactPath = groupId + "/" + artifactId + "."
+ artifact.getExtension();
for (String repo : repos) {
ret = new File(repo, verRelativeArtifactPath);
MavenJPackageDepmap.debug("Looking for " + ret.getPath());
if (ret.isFile()) {
MavenJPackageDepmap.debug("Returning " + ret.getPath());
return ret;
}
ret = new File(repo, relativeArtifactPath);
MavenJPackageDepmap.debug("Looking for " + ret.getPath());
if (ret.isFile()) {
MavenJPackageDepmap.debug("Returning " + ret.getPath());
return ret;
}
}
}
}
// if file doesn't exist return null to delegate to other
// resolvers (reactor/local repo)
MavenJPackageDepmap.debug("Returning null for gid:aid =>" + groupId
+ ":" + artifactId);
return null;
}
public List<String> findVersions(Artifact artifact) {
List<String> ret = new LinkedList<String>();
ret.add("LATEST");
return ret;
}
private StringBuffer getPOMPath(String groupId, String artifactId,
String version) {
String fName = groupId.replace(PATH_SEPARATOR, GROUP_SEPARATOR) + "-"
+ artifactId + ".pom";
String verfName = groupId.replace(PATH_SEPARATOR, GROUP_SEPARATOR)
+ "-" + artifactId + "-" + version + ".pom";
File f;
String custom_paths = System.getProperty("maven.local.pom.paths", null);
ArrayList<String> pomRepos = new ArrayList<String>();
if (custom_paths != null) {
pomRepos.addAll(Arrays.asList(custom_paths.split(":")));
}
pomRepos.add("/usr/share/maven2/poms/");
pomRepos.add("/usr/share/maven/poms/");
pomRepos.add("/usr/share/maven-poms/");
for (String pomRepo : pomRepos) {
f = new File(pomRepo, verfName);
MavenJPackageDepmap.debug("Looking for " + f.getPath());
if (f.exists()) {
return new StringBuffer(f.getPath());
}
f = new File(pomRepo, fName);
MavenJPackageDepmap.debug("Looking for " + f.getPath());
if (f.exists()) {
return new StringBuffer(f.getPath());
}
}
// final fallback to m2 default poms
return new StringBuffer("/usr/share/maven2/default_poms/" + fName);
}
}

View File

@ -1,313 +0,0 @@
package org.apache.maven.artifact.repository;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import java.util.StringTokenizer;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
public class MavenJPackageDepmap {
private static class ArtifactDefinition {
String groupId = null;
String artifactId = null;
String version = null;
}
/**
*
* @author Stanislav Ochotnicky <sochotnicky@redhat.com>
*
* This class is used to wrap around fragments that are mapping
* artifacts to jar files in our _javadir. These used to be
* processed in a macro after every package installation. Fragments
* themselves are not proper xml files (they have no root element)
* so we have to fix them by wrapping them in one root element.
*/
private static class WrapFragmentStream extends InputStream {
String startTag = "<deps>";
String endTag = "</deps>";
byte fragmentContent[];
int position;
WrapFragmentStream(String fragmentPath) throws IOException {
FileInputStream fin = new FileInputStream(fragmentPath);
int nBytes = fin.available();
byte tmpContent[] = new byte[nBytes];
fin.read(tmpContent);
fin.close();
byte startBytes[] = startTag.getBytes();
byte endBytes[] = endTag.getBytes();
fragmentContent = new byte[nBytes + startBytes.length
+ endBytes.length];
System.arraycopy(startBytes, 0, fragmentContent, 0,
startBytes.length);
System.arraycopy(tmpContent, 0, fragmentContent, startBytes.length,
tmpContent.length);
System.arraycopy(endBytes, 0, fragmentContent, startBytes.length
+ tmpContent.length, endBytes.length);
position = 0;
}
public int read() throws IOException {
if (position < fragmentContent.length) {
return fragmentContent[position++];
} else {
return -1;
}
}
}
private static MavenJPackageDepmap instance;
private static Hashtable<String, String> jppArtifactMap;
private static Hashtable<String, ArrayList<String>> jppUnversionedArtifactMap;
private MavenJPackageDepmap() {
jppArtifactMap = new Hashtable<String, String>();
jppUnversionedArtifactMap = new Hashtable<String, ArrayList<String>>();
buildJppArtifactMap();
}
public static MavenJPackageDepmap getInstance() {
if (instance == null) {
instance = new MavenJPackageDepmap();
}
return instance;
}
/**
* This function can be used to query exact version of an artifact.
*
* @param groupId
* @param artifactId
* @param version
* @return Hashtable mapping for groupId, artifactId and version or null if
* exact mapping not found
*/
public Hashtable<String, String> getMappedInfo(String groupId,
String artifactId, String version) {
Hashtable<String, String> jppDep;
String idToCheck, jppCombination;
idToCheck = groupId + "," + artifactId + "," + version;
jppCombination = (String) jppArtifactMap.get(idToCheck);
jppDep = null;
if (jppCombination != null && jppCombination != "") {
StringTokenizer st = new StringTokenizer(jppCombination, ",");
jppDep = new Hashtable<String, String>();
jppDep.put("group", st.nextToken());
jppDep.put("artifact", st.nextToken());
jppDep.put("version", st.nextToken());
}
return jppDep;
}
/**
* This function can be used to query for all possible artifact resolutions.
* It works with multiple duplicate gid:aid mappings, but only one should
* have unversioned files (default version) to work properly later
*
* @param groupId
* @param artifactId
* @param version
* @return
*/
public ArrayList<Hashtable<String, String>> getUnversionedMappedInfo(
String groupId, String artifactId, String version) {
Hashtable<String, String> jppDep;
String idToCheck;
List<String> maps;
idToCheck = groupId + "," + artifactId;
maps = jppUnversionedArtifactMap.get(idToCheck);
ArrayList<Hashtable<String, String>> ret = new ArrayList<Hashtable<String, String>>();
if (maps != null) {
for (String jppPart : maps) {
jppDep = new Hashtable<String, String>();
StringTokenizer st = new StringTokenizer(jppPart, ",");
jppDep.put("group", st.nextToken());
jppDep.put("artifact", st.nextToken());
jppDep.put("version", st.nextToken());
// we add to index 0 to make it reversed order for compatibility
// with older code
ret.add(0, jppDep);
}
}
return ret;
}
private static void buildJppArtifactMap() {
if (new File("/etc/maven/maven2-versionless-depmap.xml").exists())
processDepmapFile("/etc/maven/maven2-versionless-depmap.xml");
// process fragments is usr. Once packages are rebuilt, we can skip
// fragments in /etc
File fragmentDir = new File("/usr/share/maven-fragments");
String[] flist = fragmentDir.list();
if (flist != null) {
java.util.Arrays.sort(flist);
for (String fragFilename : flist)
processDepmapFile("/usr/share/maven-fragments/" + fragFilename);
}
String customDepmapDir = System.getProperty("maven.local.depmap.dir",
null);
if (customDepmapDir != null) {
fragmentDir = new File(customDepmapDir);
flist = fragmentDir.list();
if (flist != null) {
java.util.Arrays.sort(flist);
for (String fragFilename : flist)
processDepmapFile(customDepmapDir + File.separator
+ fragFilename);
}
}
String customFileName = System.getProperty("maven.local.depmap.file",
null);
if (customFileName != null) {
processDepmapFile(customFileName);
}
}
private static void processDepmapFile(String fileName) {
Document mapDocument;
debug("Loading depmap file: " + fileName);
try {
DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance();
fact.setNamespaceAware(true);
DocumentBuilder builder = fact.newDocumentBuilder();
// we can wrap even old depmaps, no harm done
WrapFragmentStream wfs = new WrapFragmentStream(fileName);
mapDocument = builder.parse(wfs);
wfs.close();
} catch (FileNotFoundException fnfe) {
System.err.println("ERROR: Unable to find map file: " + fileName);
fnfe.printStackTrace();
return;
} catch (IOException ioe) {
System.err
.println("ERROR: I/O exception occured when opening map file");
ioe.printStackTrace();
return;
} catch (ParserConfigurationException pce) {
System.err
.println("ERROR: Parsing of depmap file failed - configuration");
pce.printStackTrace();
return;
} catch (SAXException se) {
System.err.println("ERROR: Parsing of depmap file failed");
se.printStackTrace();
return;
}
NodeList depNodes = (NodeList) mapDocument
.getElementsByTagName("dependency");
for (int i = 0; i < depNodes.getLength(); i++) {
Element depNode = (Element) depNodes.item(i);
NodeList mavenNodeList = (NodeList) depNode
.getElementsByTagName("maven");
if (mavenNodeList.getLength() != 1) {
debug("Number of maven sub-elements is not 1. Bailing from depmap generation");
debug("Maven node: " + depNode.getTextContent());
return;
}
ArtifactDefinition mavenAD = getArtifactDefinition((Element) mavenNodeList
.item(0));
ArtifactDefinition jppAD = null;
NodeList jppNodeList = (NodeList) depNode
.getElementsByTagName("jpp");
if (jppNodeList.getLength() == 1) {
jppAD = getArtifactDefinition((Element) jppNodeList.item(0));
debug("*** Adding: " + mavenAD.groupId + ","
+ mavenAD.artifactId + " => " + jppAD.groupId + ","
+ jppAD.artifactId + "," + jppAD.version + " to map...");
jppArtifactMap.put(mavenAD.groupId + "," + mavenAD.artifactId
+ "," + mavenAD.version, jppAD.groupId + ","
+ jppAD.artifactId + "," + jppAD.version);
ArrayList<String> maps = jppUnversionedArtifactMap
.get(mavenAD.groupId + "," + mavenAD.artifactId);
if (maps == null) {
maps = new ArrayList<String>();
}
maps.add(jppAD.groupId + "," + jppAD.artifactId + ","
+ jppAD.version);
jppUnversionedArtifactMap.put(mavenAD.groupId + ","
+ mavenAD.artifactId, maps);
} else {
debug("Number of jpp sub-elements is not 1. Dropping dependency for "
+ mavenAD.groupId + ":" + mavenAD.artifactId);
jppArtifactMap.put(mavenAD.groupId + "," + mavenAD.artifactId
+ "," + mavenAD.version, "JPP/maven,empty-dep,"
+ mavenAD.version);
ArrayList<String> maps = new ArrayList<String>();
maps.add("JPP/maven,empty-dep," + mavenAD.version);
jppUnversionedArtifactMap.put(mavenAD.groupId + ","
+ mavenAD.artifactId, maps);
}
}
}
private static ArtifactDefinition getArtifactDefinition(Element element) {
ArtifactDefinition ad = new ArtifactDefinition();
NodeList nodes = element.getElementsByTagName("groupId");
if (nodes.getLength() != 1) {
debug("groupId definition not found in depmap");
return null;
}
ad.groupId = nodes.item(0).getTextContent();
nodes = element.getElementsByTagName("artifactId");
if (nodes.getLength() != 1) {
debug("artifactId definition not found in depmap");
return null;
}
ad.artifactId = nodes.item(0).getTextContent();
nodes = element.getElementsByTagName("version");
if (nodes.getLength() != 1) {
ad.version = "DUMMY_VER";
} else {
ad.version = nodes.item(0).getTextContent();
}
return ad;
}
public static void debug(String msg) {
if (System.getProperty("maven.local.debug") != null)
System.err.println(msg);
}
}

View File

@ -88,5 +88,3 @@ _m2_complete()
}
complete -F _m2_complete -o filenames mvn
complete -F _m2_complete -o filenames mvn-local
complete -F _m2_complete -o filenames mvn-rpmbuild

Binary file not shown.

View File

@ -1,9 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>JPP/maven</groupId>
<artifactId>empty-dep</artifactId>
<version>2.0.4</version>
<name>Empty dependency</name>
<description>This is an empty dependency. For use in local mode when one or more dependencies need elimination.</description>
</project>

View File

@ -1,47 +0,0 @@
#!/bin/sh
if [ -f /usr/share/java-utils/java-functions ] ; then
. /usr/share/java-utils/java-functions
set_jvm
set_javacmd
fi
function help()
{
echo "mvn-local [options] [<goal(s)>] [<phase(s)>]"
echo
echo "mvn-local is custom Fedora maven used for building maven projects"
echo "using mix of jar files provided by system and remote maven repositories."
echo "You can modify its behaviour using several environment variables:"
echo
echo "-Dmaven.repo.local [default:$(pwd)/.m2] - custom location of maven repository"
echo "-Dmaven.local.depmap.file - file containing custom dependency mapping between"
echo " groupId:artifactId and jar file. File format see:"
echo " http://fedoraproject.org/wiki/Java/JPPMavenReadme"
echo "-Dmaven.local.debug - if set maven will print additional resolving information"
echo " that can be useful for debugging resolver problems"
}
function process_args()
{
while [ $# != 0 ]; do
flag="$1"
case "$flag" in
-h|--help)
help
;;
esac
shift
done
}
process_args "$@"
export M2_HOME=/usr/share/maven
echo $JAVA_HOME
export JAVA_HOME
# can't put it on command line due to
# http://jira.codehaus.org/browse/SUREFIRE-121
export MAVEN_OPTS="$MAVEN_OPTS -Dmaven.local.mode ${local_add}"
echo "Running mvn in local mode. Please report bugs to http://bugzilla.redhat.com"
$M2_HOME/bin/mvn "$@"

View File

@ -1,93 +0,0 @@
#!/bin/bash
if [ -f /usr/share/java-utils/java-functions ] ; then
. /usr/share/java-utils/java-functions
set_jvm
set_javacmd
fi
function install_metadata()
{
mkdir -p "$1"
tar xf /usr/share/maven/repo-metadata.tar.xz -C "$1"
}
function help()
{
echo "mvn-rpmbuild [options] [<goal(s)>] [<phase(s)>]"
echo
echo "mvn-rpmbuild is custom Fedora maven used for building maven projects"
echo "using only jar files provided by rpms installed on your system. It will"
echo "never download artifacts from remote repositories. You can modify its"
echo "behaviour using several environment variables:"
echo
echo "-Dmaven.repo.local [default:$(pwd)/.m2] - custom location of maven repository"
echo "-Dmaven.local.depmap.file - file containing custom dependency mapping between"
echo " groupId:artifactId and jar file. File format see:"
echo " http://fedoraproject.org/wiki/Java/JPPMavenReadme"
echo "-Dmaven.local.debug - if set maven will print additional resolving information"
echo " that can be useful for debugging resolver problems"
}
# add maven.repo.local if it's not defined already
local_add="-Dmaven.repo.local=$(pwd)/.m2/"
# Check whether we are ran in mock
# FIXME: is there a better way to do this?
mock=test
test "$HOME" = /builddir && mock=:
if $mock; then
log_file="$(umask 2 && mktemp -t mvn-rpmbuild.$$.XXXXXXXXXX)"
logfile_add="-Dmaven.resolver.logfile=$log_file"
fi
function process_args()
{
while [ $# != 0 ]; do
flag="$1"
case "$flag" in
-h|--help)
help
;;
*) ind=`expr match "$flag" -Dmaven.repo.local=`
if [[ $ind != 0 ]];then
install_metadata "${flag/-Dmaven.repo.local=/}/"
local_add=""
fi
;;
esac
shift
done
}
process_args "$@"
if [ -n "$local_add" ];then
install_metadata "${local_add/-Dmaven.repo.local=/}/"
fi
export M2_HOME=/usr/share/maven
echo $JAVA_HOME
export JAVA_HOME
# can't put it on command line due to
# http://jira.codehaus.org/browse/SUREFIRE-121
export MAVEN_OPTS="$MAVEN_OPTS -Dmaven.local.mode ${local_add} ${logfile_add}"
$M2_HOME/bin/mvn -o "$@" || exit $?
$mock || exit 0
sanitize() {
for obj in $1; do
echo -n 'mvn-rpmbuild: possibly redundant dependency: '
rpm -qf "$(readlink -f $obj)" | sed 's/-[^-]*-[^-]*$//'
done | sort -u
}
installed=$(sanitize "$(rpm -ql `package-cleanup --all --leaves | xargs` | egrep '\.(jar|pom)$')")
used=$(sanitize "$(cat $log_file 2>/dev/null)")
diff - /dev/fd/3 <<<"$installed" 3<<<"$used" | grep '^< ' | sed s/..//
:

View File

@ -2,7 +2,7 @@
Name: maven
Version: 3.0.4
Release: 28%{?dist}
Release: 29%{?dist}
Summary: Java project management and project comprehension tool
Group: Development/Tools
@ -10,39 +10,15 @@ License: ASL 2.0
URL: http://maven.apache.org/
# Source URL is for testing only, final version will be in different place:
# http://www.apache.org/dyn/closer.cgi/maven/source/apache-%{name}-%{version}-src.tar.gz
Source0: http://www.apache.org/dist//maven/source/apache-%{name}-%{version}-src.tar.gz
Source0: http://archive.apache.org/dist/maven/source/apache-%{name}-%{version}-src.tar.gz
Source1: maven-bash-completion
Source2: mvn.1
# custom resolver java files
# source: git clone git://fedorapeople.org/~sochotni/maven-javadir-resolver/
Source100: JavadirWorkspaceReader.java
Source101: MavenJPackageDepmap.java
# empty files for resolving to nothing
Source104: %{name}-empty-dep.pom
Source105: %{name}-empty-dep.jar
# 2xx for created non-buildable sources
Source200: %{name}-script
Source201: %{name}-script-local
Source202: %{name}-script-rpmbuild
# Other included files
Source250: repo-metadata.tar.xz
Source200: %{name}-script
# Patch1XX could be upstreamed probably
Patch100: 0005-Use-generics-in-modello-generated-code.patch
Patch101: 0006-Make-compiler-plugin-default-to-source-1.5.patch
# Patch15X are already upstream
Patch150: 0001-Add-plugin-api-deps.patch
Patch151: 0003-Use-utf-8-source-encoding.patch
# Patch2XX for non-upstreamable patches
Patch200: 0002-Use-custom-resolver.patch
Patch201: 0004-Fix-text-scope-skipping-with-maven.test.skip.patch
Patch202: 0001-Customize-compiler-plugin.patch
BuildArch: noarch
@ -76,33 +52,6 @@ BuildRequires: xmlunit
BuildRequires: animal-sniffer >= 1.6-5
%endif
Requires: aether >= 1.13.1
Requires: apache-commons-cli
Requires: apache-resource-bundles
Requires: async-http-client
Requires: atinject
Requires: google-guice >= 3.0
Requires: guava
Requires: hamcrest
Requires: hamcrest
Requires: java >= 1:1.6.0
Requires: maven-wagon
Requires: nekohtml
Requires: plexus-cipher
Requires: plexus-classworlds >= 2.4
Requires: plexus-containers-component-annotations
Requires: plexus-containers-container-default
Requires: plexus-interpolation
Requires: plexus-sec-dispatcher
Requires: plexus-utils
Requires: sisu >= 2.1.1-2
Requires: xbean
Requires: xerces-j2
Requires: yum-utils
%if 0%{?fedora}
Requires: animal-sniffer >= 1.6-5
%endif
# Require maven-local for now to allow a smooth transition from maven
# to maven-local. Once packages start requiring maven-local directly
# the Requires below should be removed.
@ -111,8 +60,7 @@ Requires: maven-local
# for noarch->arch change
Obsoletes: %{name} < 0:%{version}-%{release}
# maven2 bin package no longer exists. Replace it
# these should be around until F20
# maven2 bin package no longer exists.
Obsoletes: maven2 < 2.2.1-99
Provides: maven2 = %{version}-%{release}
@ -124,31 +72,13 @@ reporting and documentation from a central piece of information.
%package javadoc
Summary: API documentation for %{name}
Group: Documentation
Requires: jpackage-utils
BuildArch: noarch
%description javadoc
%{summary}.
%prep
%setup -q -n apache-%{name}-%{version}%{?ver_add}
%patch150 -p1
%patch151 -p1
%patch200 -p1
%patch201 -p1
%patch202 -p1
%patch100 -p1
%patch101 -p1
# get custom resolver in place
mkdir -p maven-aether-provider/src/main/java/org/apache/maven/artifact/resolver \
maven-aether-provider/src/main/java/org/apache/maven/artifact/repository
cp %{SOURCE100} maven-aether-provider/src/main/java/org/apache/maven/artifact/resolver
cp %{SOURCE101} maven-aether-provider/src/main/java/org/apache/maven/artifact/repository
# by adding our things this has become compile dep
sed -i 's:<scope>runtime</scope>::' maven-core/pom.xml
# not really used during build, but a precaution
rm maven-ant-tasks-*.jar
@ -159,14 +89,12 @@ sed -i 's:\r::' *.txt
# fix for animal-sniffer (we don't generate 1.5 signatures)
sed -i 's:check-java-1.5-compat:check-java-1.6-compat:' pom.xml
pushd apache-maven
rm src/bin/*bat
sed -i 's:\r::' src/conf/settings.xml
rm -f apache-maven/src/bin/*.bat
sed -i 's:\r::' apache-maven/src/conf/settings.xml
# Update shell scripts to use unversioned classworlds
sed -i -e s:'-classpath "${M2_HOME}"/boot/plexus-classworlds-\*.jar':'-classpath "${M2_HOME}"/boot/plexus-classworlds.jar':g \
src/bin/mvn*
popd
apache-maven/src/bin/mvn*
# Disable animal-sniffer on RHEL
# Temporarily disabled for fedora to solve asm & asm4 clashing on classpath
@ -174,226 +102,103 @@ popd
%pom_remove_plugin :animal-sniffer-maven-plugin
#fi
%pom_add_dep org.codehaus.plexus:plexus-container-default maven-plugin-api
# Test dependencies
%pom_add_dep aopalliance:aopalliance:any:test maven-model-builder
%pom_add_dep cglib:cglib:any:test maven-model-builder
%build
mvn-rpmbuild -e install javadoc:aggregate
# Put all JARs in standard location, but create symlinks in Maven lib
# directory so that Plexus Classworlds can find them.
%mvn_file ":{*}" %{name}/@1 %{_datadir}/%{name}/lib/@1
%mvn_build -- -Dproject.build.sourceEncoding=UTF-8
mkdir m2home
(cd m2home
tar --delay-directory-restore -xvf ../apache-maven/target/*tar.gz
chmod -R +rwX apache-%{name}-%{version}%{?ver_add}
chmod -x apache-%{name}-%{version}%{?ver_add}/conf/settings.xml
tar --delay-directory-restore -xvf ../apache-maven/target/*tar.gz
chmod -R +rwX apache-%{name}-%{version}%{?ver_add}
chmod -x apache-%{name}-%{version}%{?ver_add}/conf/settings.xml
)
%install
%mvn_install
export M2_HOME=$(pwd)/m2home/apache-maven-%{version}%{?ver_add}
# maven2 directory in /usr/share/java
install -dm 755 $RPM_BUILD_ROOT%{_javadir}/%{name}
install -d -m 755 %{buildroot}%{_datadir}/%{name}/bin
install -d -m 755 %{buildroot}%{_datadir}/%{name}/conf
install -d -m 755 %{buildroot}%{_datadir}/%{name}/boot
install -d -m 755 %{buildroot}%{_datadir}/%{name}/lib
install -d -m 755 %{buildroot}%{_datadir}/%{name}/ext
install -d -m 755 %{buildroot}%{_bindir}
install -d -m 755 %{buildroot}%{_sysconfdir}/bash_completion.d
install -d -m 755 %{buildroot}%{_mandir}/man1
# put global m2 config into /etc and symlink it later
install -dm 755 $RPM_BUILD_ROOT%{_sysconfdir}
mv $M2_HOME/bin/m2.conf $RPM_BUILD_ROOT%{_sysconfdir}/
install -p -m 755 %{SOURCE200} %{buildroot}%{_bindir}/mvn
install -p -m 644 %{SOURCE2} %{buildroot}%{_mandir}/man1
install -p -m 644 %{SOURCE1} %{buildroot}%{_sysconfdir}/bash_completion.d/%{name}
mv $M2_HOME/bin/m2.conf %{buildroot}%{_sysconfdir}
ln -sf %{_sysconfdir}/m2.conf %{buildroot}%{_datadir}/%{name}/bin/m2.conf
###########
# M2_HOME #
###########
install -dm 755 $RPM_BUILD_ROOT%{_datadir}/%{name}
cp -a $M2_HOME/bin/* %{buildroot}%{_datadir}/%{name}/bin
cp -a $M2_HOME/conf/* %{buildroot}%{_datadir}/%{name}/conf
#################
# Repo metadata #
#################
install -m 755 %{SOURCE250} $RPM_BUILD_ROOT%{_datadir}/%{name}/
ln -sf $(build-classpath plexus/classworlds) \
%{buildroot}%{_datadir}/%{name}/boot/plexus-classworlds.jar
###############
# M2_HOME/bin #
###############
install -dm 755 $RPM_BUILD_ROOT%{_datadir}/%{name}/bin
cp -a $M2_HOME/bin/* $RPM_BUILD_ROOT%{_datadir}/%{name}/bin
ln -sf %{_sysconfdir}/m2.conf $RPM_BUILD_ROOT%{_datadir}/%{name}/bin/m2.conf
# Fallback scripts
cp -af %{SOURCE201} $RPM_BUILD_ROOT%{_datadir}/%{name}/bin/mvn-local
cp -af %{SOURCE202} $RPM_BUILD_ROOT%{_datadir}/%{name}/bin/mvn-rpmbuild
################
# M2_HOME/boot #
################
install -dm 755 $RPM_BUILD_ROOT%{_datadir}/%{name}/boot
# this dangling symlink will be filled in by Requires
(cd $RPM_BUILD_ROOT%{_datadir}/%{name}/boot
ln -sf `build-classpath plexus/classworlds` plexus-classworlds.jar
(cd %{buildroot}%{_datadir}/%{name}/lib
build-jar-repository -s -p . \
aether/api \
aether/connector-wagon \
aether/impl \
aether/spi \
aether/util \
aopalliance \
atinject \
cglib \
commons-cli \
google-guice \
guava \
maven-wagon/file \
maven-wagon/http-lightweight \
maven-wagon/http-shared \
maven-wagon/provider-api \
nekohtml \
objectweb-asm \
plexus/containers-component-annotations \
plexus/interpolation \
plexus/plexus-cipher \
plexus/plexus-sec-dispatcher \
plexus/utils \
sisu/sisu-inject-bean \
sisu/sisu-inject-plexus \
slf4j/api \
slf4j/nop \
xbean/xbean-reflect \
xerces-j2 \
)
################
# M2_HOME/conf #
################
install -dm 755 $RPM_BUILD_ROOT%{_datadir}/%{name}/conf
cp -a $M2_HOME/conf/* $RPM_BUILD_ROOT%{_datadir}/%{name}/conf/
###############
# M2_HOME/lib #
###############
install -dm 755 $RPM_BUILD_ROOT%{_datadir}/%{name}/lib
# jdom is needed for our custom resolving code only
(cd $RPM_BUILD_ROOT%{_datadir}/%{name}/lib
build-jar-repository -s -p . aether/api aether/connector-wagon aether/impl aether/spi aether/util \
commons-cli guava google-guice nekohtml plexus/plexus-cipher \
plexus/containers-component-annotations \
plexus/interpolation plexus/plexus-sec-dispatcher plexus/utils \
sisu/sisu-inject-bean sisu/sisu-inject-plexus maven-wagon/file \
maven-wagon/http-lightweight maven-wagon/http-shared maven-wagon/provider-api \
xbean/xbean-reflect xerces-j2 atinject aopalliance cglib \
slf4j/api slf4j/nop objectweb-asm
# dependency of our resolver
mkdir ext/
build-jar-repository -s -p ext/ xml-commons-apis
)
################
# M2_HOME/poms #
#*##############
install -dm 755 $RPM_BUILD_ROOT%{_datadir}/%{name}/poms
########################
# /etc/maven/fragments #
########################
install -dm 755 $RPM_BUILD_ROOT/%{_sysconfdir}/maven/fragments
##############################
# /usr/share/java repository #
##############################
install -dm 755 $RPM_BUILD_ROOT%{_datadir}/%{name}/repository
ln -s %{_javadir} $RPM_BUILD_ROOT%{_datadir}/%{name}/repository/JPP
##############################
# /usr/share/java-jni repository #
##############################
install -dm 755 $RPM_BUILD_ROOT%{_datadir}/%{name}/repository-java-jni
ln -s %{_javajnidir} $RPM_BUILD_ROOT%{_datadir}/%{name}/repository-java-jni/JPP
##############################
# _libdir/java repository #
##############################
install -dm 755 $RPM_BUILD_ROOT%{_datadir}/%{name}/repository-jni
# create symlink in post, remove in preun so we can stay noarch
##################
# javadir/maven #
#*################
install -dm 755 $RPM_BUILD_ROOT%{_javadir}/%{name}
#######################
# javadir/maven/poms #
#*#####################
ln -s %{_datadir}/%{name}/poms $RPM_BUILD_ROOT%{_javadir}/%{name}/poms
# for our custom resolver to remove dependencies we need empty jar and
# pom file
install -m 644 %{SOURCE104} $RPM_BUILD_ROOT%{_datadir}/%{name}/poms/JPP.maven-empty-dep.pom
install -m 644 %{SOURCE105} $RPM_BUILD_ROOT%{_javadir}/%{name}/empty-dep.jar
# Dependencies that should be ignored.
%add_to_maven_depmap javax.activation activation any JPP/%{name} empty-dep
%add_to_maven_depmap org.eclipse.jetty.orbit javax.activation any JPP/%{name} empty-dep
%add_to_maven_depmap org.apache.maven.wagon wagon-webdav any JPP/%{name} empty-dep
%add_to_maven_depmap org.apache.maven.wagon wagon-webdav-jackrabbit any JPP/%{name} empty-dep
############
# /usr/bin #
############
install -dm 755 $RPM_BUILD_ROOT%{_bindir}
# Wrapper
cp -af %{SOURCE200} $RPM_BUILD_ROOT%{_bindir}/mvn
###################
# Individual jars #
###################
for module in maven-aether-provider maven-artifact maven-compat \
maven-core maven-embedder maven-model \
maven-model-builder maven-plugin-api \
maven-repository-metadata maven-settings \
maven-settings-builder;do
pushd $module
install -m 644 target/$module-%{version}%{?ver_add}.jar $RPM_BUILD_ROOT%{_javadir}/%{name}/$module.jar
ln -s %{_javadir}/%{name}/$module.jar $RPM_BUILD_ROOT%{_datadir}/%{name}/lib/$module.jar
install -m 644 pom.xml $RPM_BUILD_ROOT%{_datadir}/%{name}/poms/JPP.%{name}-$module.pom
%add_to_maven_depmap org.apache.maven $module %{version} JPP/%{name} $module
popd
done
# maven pom
install -m 644 pom.xml $RPM_BUILD_ROOT%{_datadir}/%{name}/poms/JPP.%{name}-maven.pom
%add_to_maven_depmap org.apache.maven maven %{version} JPP/%{name} maven
# javadocs
install -d -m 755 $RPM_BUILD_ROOT%{_javadocdir}/%{name}
cp -pr target/site/apidocs/* $RPM_BUILD_ROOT%{_javadocdir}/%{name}
# Install bash-completion
install -Dm 644 %{SOURCE1} %{buildroot}%{_sysconfdir}/bash_completion.d/%{name}
# Manual page
install -dm 755 $RPM_BUILD_ROOT%{_mandir}/man1
install -pm 644 %{SOURCE2} $RPM_BUILD_ROOT%{_mandir}/man1
gzip -9 $RPM_BUILD_ROOT%{_mandir}/man1/*
%preun
if [ $1 -eq 0 ] ; then
if [ -h %{_datadir}/%{name}/repository-jni/JPP ];then
rm %{_datadir}/%{name}/repository-jni/JPP
fi
fi
%posttrans
# ugly as hell
ln -sf `rpm --eval '%%{_jnidir}'` %{_datadir}/%{name}/repository-jni/JPP
%files
%files -f .mfiles
%doc LICENSE.txt NOTICE.txt README.txt
%attr(0755,root,root) %{_bindir}/mvn
%dir %{_datadir}/%{name}
%dir %{_datadir}/%{name}/bin
%attr(0755,root,root) %{_datadir}/%{name}/bin/mvn
%attr(0755,root,root) %{_datadir}/%{name}/bin/mvnyjp
%attr(0755,root,root) %{_datadir}/%{name}/bin/mvnDebug
%attr(0755,root,root) %{_datadir}/%{name}/bin/mvn-local
%attr(0755,root,root) %{_datadir}/%{name}/bin/mvn-rpmbuild
%{_datadir}/%{name}/bin/*.conf
%{_datadir}/%{name}
%{_bindir}/mvn
%dir %{_javadir}/%{name}
%config(noreplace) %{_sysconfdir}/m2.conf
%{_datadir}/%{name}/boot
%{_datadir}/%{name}/conf
%{_datadir}/%{name}/lib
%{_datadir}/%{name}/poms
%{_datadir}/%{name}/repository
%{_datadir}/%{name}/repository-jni
%{_datadir}/%{name}/repository-java-jni
%{_mavendepmapfragdir}/%{name}
%{_javadir}/%{name}
%{_datadir}/%{name}/repo-metadata.tar.xz
%config(noreplace) %{_sysconfdir}/bash_completion.d/%{name}
%{_mandir}/man1/mvn.1.gz
%files javadoc
%files javadoc -f .mfiles-javadoc
%doc LICENSE.txt NOTICE.txt
%{_javadocdir}/%{name}
%changelog
* Fri Jan 25 2013 Mikolaj Izdebski <mizdebsk@redhat.com> - 3.0.4-29
- Drop support for local mode
- Build with xmvn, rely on auto-requires
* Wed Jan 23 2013 Mikolaj Izdebski <mizdebsk@redhat.com> - 3.0.4-28
- Move mvn-local and mvn-rpmbuild out of %_bindir

Binary file not shown.