Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Better handling of alternate local repo vs. default local repo. More …

…sanity checks. Code formatting.
  • Loading branch information...
commit a903b9e63f267ea9717e851534f8fd1b0e984113 1 parent ac19d1f
@nawroth nawroth authored
View
9 example-aggregate/pom.xml
@@ -1,4 +1,5 @@
-<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/xsd/maven-4.0.0.xsd">
+<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>ease-maven-plugin-parent</artifactId>
@@ -13,17 +14,17 @@
<dependency>
<groupId>org.neo4j.build.plugins</groupId>
<artifactId>ease-example-freeze</artifactId>
- <version>1-SNAPSHOT</version>
+ <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.neo4j.build.plugins</groupId>
<artifactId>ease-example-freeze3</artifactId>
- <version>1-SNAPSHOT</version>
+ <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.neo4j.build.plugins</groupId>
<artifactId>ease-example-freeze4</artifactId>
- <version>1-SNAPSHOT</version>
+ <version>${project.version}</version>
<type>pom</type>
</dependency>
</dependencies>
View
3  example-attach/pom.xml
@@ -1,4 +1,5 @@
-<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/xsd/maven-4.0.0.xsd">
+<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>ease-maven-plugin-parent</artifactId>
View
5 example-freeze/pom.xml
@@ -1,7 +1,6 @@
<?xml version="1.0"?>
-<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
->
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>ease-maven-plugin-parent</artifactId>
View
11 example-freeze2/pom.xml
@@ -1,7 +1,6 @@
<?xml version="1.0"?>
-<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
->
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>ease-maven-plugin-parent</artifactId>
@@ -16,12 +15,6 @@
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
- <dependency>
- <groupId>org.neo4j.build.plugins</groupId>
- <artifactId>docs-maven-plugin</artifactId>
- <version>5</version>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
View
7 example-freeze3/pom.xml
@@ -1,7 +1,6 @@
<?xml version="1.0"?>
-<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
->
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>ease-maven-plugin-parent</artifactId>
@@ -15,7 +14,7 @@
<dependency>
<artifactId>ease-example-freeze2</artifactId>
<groupId>org.neo4j.build.plugins</groupId>
- <version>1-SNAPSHOT</version>
+ <version>${project.version}</version>
</dependency>
<!-- check that scope=test doesn't get included -->
<dependency>
View
5 example-freeze4/pom.xml
@@ -1,7 +1,6 @@
<?xml version="1.0"?>
-<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
->
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>ease-maven-plugin-parent</artifactId>
View
7 plugin/pom.xml
@@ -1,4 +1,5 @@
-<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">
+<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>
<parent>
<groupId>org.neo4j.build</groupId>
@@ -243,7 +244,8 @@
<artifactId>maven-license-plugin</artifactId>
<version>1.9.0</version>
</plugin>
- <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. -->
+ <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build
+ itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
@@ -281,4 +283,3 @@
</distributionManagement>
</project>
-
View
28 plugin/src/main/java/org/neo4j/build/plugins/ease/AggregateMojo.java
@@ -136,13 +136,15 @@ public void execute() throws MojoExecutionException
SortedMap<String, String> aggregate = new TreeMap<String, String>();
for ( Artifact dependency : getDependencies() )
{
- Artifact findArtifactsArtifact = artifactFactory.createArtifactWithClassifier( dependency.getGroupId(),
- dependency.getArtifactId(), dependency.getVersion(), "txt", "artifacts" );
+ Artifact findArtifactsArtifact = artifactFactory.createArtifactWithClassifier(
+ dependency.getGroupId(), dependency.getArtifactId(),
+ dependency.getVersion(), "txt", "artifacts" );
Artifact artifactsArtifact = localRepository.find( findArtifactsArtifact );
File artifactsFile = artifactsArtifact.getFile();
if ( !artifactsFile.exists() )
{
- throw new MojoExecutionException( "Could not find an artifact list for: " + dependency );
+ throw new MojoExecutionException(
+ "Could not find an artifact list for: " + dependency );
}
String artifactList = null;
@@ -152,7 +154,8 @@ public void execute() throws MojoExecutionException
}
catch ( IOException ioe )
{
- throw new MojoExecutionException( "Could not read artifact list for: " + dependency, ioe );
+ throw new MojoExecutionException(
+ "Could not read artifact list for: " + dependency, ioe );
}
aggregate.put( dependency.getId(), artifactList );
}
@@ -161,7 +164,8 @@ public void execute() throws MojoExecutionException
{
builder.append( artifactList );
}
- EaseHelper.writeAndAttachArtifactList( builder, project, projectHelper, getLog() );
+ EaseHelper.writeAndAttachArtifactList( builder, project, projectHelper,
+ getLog() );
}
private Set<Artifact> getDependencies() throws MojoExecutionException
@@ -191,18 +195,21 @@ public void execute() throws MojoExecutionException
return artifacts;
}
- private Set<Artifact> getFilteredTransitiveDependencies( ArtifactFilter filter ) throws MojoExecutionException
+ private Set<Artifact> getFilteredTransitiveDependencies(
+ ArtifactFilter filter ) throws MojoExecutionException
{
HashSet<Artifact> artifacts = new HashSet<Artifact>();
DependencyNode rootNode = null;
try
{
- rootNode = treeBuilder.buildDependencyTree( project, localRepository, artifactFactory,
- artifactMetadataSource, null, artifactCollector );
+ rootNode = treeBuilder.buildDependencyTree( project,
+ localRepository, artifactFactory, artifactMetadataSource,
+ null, artifactCollector );
}
catch ( DependencyTreeBuilderException dtbe )
{
- throw new MojoExecutionException( "Failed to traverse dependencies.", dtbe );
+ throw new MojoExecutionException(
+ "Failed to traverse dependencies.", dtbe );
}
CollectingDependencyNodeVisitor visitor = new CollectingDependencyNodeVisitor();
@@ -220,7 +227,8 @@ public void execute() throws MojoExecutionException
for ( DependencyNode dependencyNode : nodes )
{
int state = dependencyNode.getState();
- if ( state == DependencyNode.INCLUDED && filter.include( dependencyNode.getArtifact() ) )
+ if ( state == DependencyNode.INCLUDED
+ && filter.include( dependencyNode.getArtifact() ) )
{
artifacts.add( dependencyNode.getArtifact() );
}
View
107 plugin/src/main/java/org/neo4j/build/plugins/ease/AttachMojo.java
@@ -45,6 +45,8 @@
public class AttachMojo extends AbstractMojo
{
/**
+ * File system location of artifact list.
+ *
* @parameter expression="${artifactListLocation}"
* @required
* @readonly
@@ -52,6 +54,10 @@
private String artifactListLocation;
/**
+ * File system location of artifact repository to fetch artifacts from. It
+ * is not allowed to point artifactRepositoryLocation to the location of the
+ * local repository.
+ *
* @parameter expression="${artifactRepositoryLocation}"
* @readonly
*/
@@ -82,21 +88,28 @@
*/
protected ArtifactRepository localRepository;
+ /**
+ * Is either the local repo or a separate artifact repo in the file system.
+ */
private ArtifactRepository artifactRepository = null;
@Override
public void execute() throws MojoExecutionException
{
- project.getAttachedArtifacts().clear();
+ project.getAttachedArtifacts()
+ .clear();
String[] lines = null;
try
{
- lines = FileUtils.fileRead( artifactListLocation, "UTF-8" ).split( "\n" );
+ lines = FileUtils.fileRead( artifactListLocation, "UTF-8" )
+ .split( "\n" );
}
catch ( IOException ioe )
{
- throw new MojoExecutionException( "Could not read artifact list from: " + artifactListLocation );
+ throw new MojoExecutionException(
+ "Could not read artifact list from: "
+ + artifactListLocation );
}
if ( artifactRepositoryLocation != null )
@@ -105,80 +118,112 @@ public void execute() throws MojoExecutionException
File artifactRepositoryDirectory = FileUtils.getFile( artifactRepositoryLocation );
try
{
- url = artifactRepositoryDirectory.toURI().toURL().toExternalForm();
+ url = artifactRepositoryDirectory.toURI()
+ .toURL()
+ .toExternalForm();
}
catch ( MalformedURLException mue )
{
- throw new MojoExecutionException( "Could not parse repository location: " + artifactRepositoryLocation,
- mue );
+ throw new MojoExecutionException(
+ "Could not parse repository location: "
+ + artifactRepositoryLocation, mue );
}
if ( !artifactRepositoryDirectory.exists() )
{
- throw new MojoExecutionException( "The repository location does not exist: "
- + artifactRepositoryLocation );
+ throw new MojoExecutionException(
+ "The repository location does not exist: "
+ + artifactRepositoryLocation );
}
String id = "ease-source-repo";
DefaultRepositoryLayout layout = new DefaultRepositoryLayout();
- ArtifactRepositoryPolicy snapshotsPolicy = new ArtifactRepositoryPolicy( false,
- ArtifactRepositoryPolicy.UPDATE_POLICY_NEVER, ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL );
- ArtifactRepositoryPolicy releasesPolicy = new ArtifactRepositoryPolicy( true,
- ArtifactRepositoryPolicy.UPDATE_POLICY_NEVER, ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL );
- artifactRepository = new MavenArtifactRepository( id, url, layout, snapshotsPolicy, releasesPolicy );
+ ArtifactRepositoryPolicy snapshotsPolicy = new ArtifactRepositoryPolicy(
+ false, ArtifactRepositoryPolicy.UPDATE_POLICY_NEVER,
+ ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL );
+ ArtifactRepositoryPolicy releasesPolicy = new ArtifactRepositoryPolicy(
+ true, ArtifactRepositoryPolicy.UPDATE_POLICY_NEVER,
+ ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL );
+ artifactRepository = new MavenArtifactRepository( id, url, layout,
+ snapshotsPolicy, releasesPolicy );
+ if ( artifactRepository.getBasedir()
+ .equals( localRepository.getBasedir() ) )
+ {
+ throw new MojoExecutionException(
+ "It is not allowed to point artifactRepositoryLocation to the location of the local repository." );
+ }
}
else
{
artifactRepository = localRepository;
}
+ getLog().info(
+ "Loading artifacts from repository at: "
+ + artifactRepository.getBasedir() );
+
for ( String artifactString : lines )
{
Artifact findArtifact = createArtifact( artifactString );
if ( findArtifact == null )
{
- throw new MojoExecutionException( "Could not create artifact from coordinates: " + artifactString );
+ throw new MojoExecutionException(
+ "Could not create artifact from coordinates: "
+ + artifactString );
}
findAndAttachExternalArtifact( findArtifact, artifactRepository );
}
}
- private void findAndAttachExternalArtifact( Artifact findArtifact, ArtifactRepository repository )
- throws MojoExecutionException
+ private void findAndAttachExternalArtifact( Artifact findArtifact,
+ ArtifactRepository repository ) throws MojoExecutionException
{
Artifact artifactToAttach = repository.find( findArtifact );
- if ( !artifactToAttach.getFile().exists() )
+ if ( !artifactToAttach.getFile()
+ .exists() )
{
- throw new MojoExecutionException( "Missing artifact file: " + findArtifact.getFile() );
+ throw new MojoExecutionException( "Missing artifact file: "
+ + findArtifact.getFile() );
}
- String fileName = artifactToAttach.getFile().getName();
- File destination = new File( new File( project.getBuild().getDirectory() ), fileName );
- try
+ if ( repository == localRepository )
{
- FileUtils.copyFileIfModified( artifactToAttach.getFile(), destination );
- }
- catch ( IOException ioe )
- {
- throw new MojoExecutionException( "Could not copy file: " + fileName, ioe );
+ String fileName = artifactToAttach.getFile()
+ .getName();
+ File destination = new File( new File( project.getBuild()
+ .getDirectory() ), fileName );
+ try
+ {
+ FileUtils.copyFileIfModified( artifactToAttach.getFile(),
+ destination );
+ }
+ catch ( IOException ioe )
+ {
+ throw new MojoExecutionException( "Could not copy file: "
+ + fileName, ioe );
+ }
+ artifactToAttach.setFile( destination );
}
- artifactToAttach.setFile( destination );
project.addAttachedArtifact( artifactToAttach );
getLog().info( "Attached: " + artifactToAttach );
}
- private Artifact createArtifact( String groupId, String artifactId, String version, String type, String classifier )
+ private Artifact createArtifact( String groupId, String artifactId,
+ String version, String type, String classifier )
{
- return artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type, classifier );
+ return artifactFactory.createArtifactWithClassifier( groupId,
+ artifactId, version, type, classifier );
}
- private Artifact createArtifact( String coords ) throws MojoExecutionException
+ private Artifact createArtifact( String coords )
+ throws MojoExecutionException
{
String[] strings = coords.split( ":" );
if ( strings.length < 4 || strings.length > 5 )
{
- throw new MojoExecutionException( "Can not parse coordinates: " + coords );
+ throw new MojoExecutionException( "Can not parse coordinates: "
+ + coords );
}
String groupId = strings[0];
String artifactId = strings[1];
View
18 plugin/src/main/java/org/neo4j/build/plugins/ease/EaseHelper.java
@@ -30,12 +30,14 @@
class EaseHelper
{
- static void writeAndAttachArtifactList( StringBuilder builder, MavenProject project,
- MavenProjectHelper projectHelper, Log log ) throws MojoExecutionException
+ static void writeAndAttachArtifactList( StringBuilder builder,
+ MavenProject project, MavenProjectHelper projectHelper, Log log )
+ throws MojoExecutionException
{
- String buildDir = project.getBuild().getDirectory();
- String destFile = buildDir + File.separator + project.getArtifactId() + "-" + project.getVersion()
- + "-artifacts.txt";
+ String buildDir = project.getBuild()
+ .getDirectory();
+ String destFile = buildDir + File.separator + project.getArtifactId()
+ + "-" + project.getVersion() + "-artifacts.txt";
try
{
if ( FileUtils.fileExists( destFile ) )
@@ -50,9 +52,11 @@ static void writeAndAttachArtifactList( StringBuilder builder, MavenProject proj
}
catch ( IOException ioe )
{
- throw new MojoExecutionException( "Could not write artifact list.", ioe );
+ throw new MojoExecutionException( "Could not write artifact list.",
+ ioe );
}
- projectHelper.attachArtifact( project, "txt", "artifacts", FileUtils.getFile( destFile ) );
+ projectHelper.attachArtifact( project, "txt", "artifacts",
+ FileUtils.getFile( destFile ) );
log.info( "Successfully attached artifact list to the project." );
}
}
View
33 plugin/src/main/java/org/neo4j/build/plugins/ease/FreezeMojo.java
@@ -73,14 +73,16 @@ public void execute() throws MojoExecutionException
}
if ( !pomWasAdded )
{
- addArtifactCoordinates( builder, project.getGroupId(), project.getArtifactId(), "pom",
- project.getVersion(), null );
+ addArtifactCoordinates( builder, project.getGroupId(),
+ project.getArtifactId(), "pom", project.getVersion(), null );
}
- EaseHelper.writeAndAttachArtifactList( builder, project, projectHelper, getLog() );
+ EaseHelper.writeAndAttachArtifactList( builder, project, projectHelper,
+ getLog() );
}
- private void addArtifactCoordinates( StringBuilder builder, Artifact attached )
+ private void addArtifactCoordinates( StringBuilder builder,
+ Artifact attached )
{
String groupId = attached.getGroupId();
String artifactId = attached.getArtifactId();
@@ -88,7 +90,8 @@ private void addArtifactCoordinates( StringBuilder builder, Artifact attached )
String type = "pom";
if ( !"pom".equals( attached.getType() ) )
{
- type = FileUtils.extension( attached.getFile().getName() );
+ type = FileUtils.extension( attached.getFile()
+ .getName() );
}
String version = attached.getVersion();
String classifier = null;
@@ -96,17 +99,25 @@ private void addArtifactCoordinates( StringBuilder builder, Artifact attached )
{
classifier = attached.getClassifier();
}
- addArtifactCoordinates( builder, groupId, artifactId, type, version, classifier );
+ addArtifactCoordinates( builder, groupId, artifactId, type, version,
+ classifier );
}
- private void addArtifactCoordinates( StringBuilder builder, String groupId, String artifactId, String type,
- String version, String classifier )
+ private void addArtifactCoordinates( StringBuilder builder, String groupId,
+ String artifactId, String type, String version, String classifier )
{
- builder.append( groupId ).append( ':' ).append( artifactId ).append( ':' ).append( type ).append( ':' );
+ builder.append( groupId )
+ .append( ':' )
+ .append( artifactId )
+ .append( ':' )
+ .append( type )
+ .append( ':' );
if ( classifier != null )
{
- builder.append( classifier ).append( ':' );
+ builder.append( classifier )
+ .append( ':' );
}
- builder.append( version ).append( '\n' );
+ builder.append( version )
+ .append( '\n' );
}
}
View
3  pom.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<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">
+<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>
<parent>
<groupId>org.neo4j.build</groupId>
View
10 readme.asciidoc
@@ -3,20 +3,20 @@
This plugin lets you release Maven artifacts in a very controlled way.
The plugin works by adding metadata to artifacts during the release build,
-and then reading the data when deploying.
+and then reading that data when deploying.
Which means release build and deploy are fully separated.
Use the `freeze` and `aggregate` goals while building a release.
-Use `attach` goal when deploying the release.
+Use the `attach` goal when deploying the release.
-Add the plugin executions to the pom.xml files.
+Add the plugin executions to the 'pom.xml' files.
Then just use normal `install` or `deploy` goals to bring it to action.
=== Goals ===
* `freeze`: Lists the artifacts (like the default jar, the sources jar etc.) atttached to a project and attaches the list to the project, as a -artifacts.txt artifact.
-* `aggregate`: Traverses the dependencies of a project and aggragates artifacts.txt files into one single list, which is then attached to the project. Note that any missing artifacts.txt file will fail the build -- use includes/excludes filtering to target the dependencies you want.
-* `attach`: Attaches all artifacts in a given artifacts.txt file to the project. A file location for this file is used to prevent any dependency resolution whatsoever to take place.
+* `aggregate`: Traverses the dependencies of a project and aggragates artifacts.txt files into one single list, which is then attached to the project. Note that _any_ missing artifacts.txt file will fail the build -- use includes/excludes filtering to target the dependencies you want.
+* `attach`: Attaches all artifacts in a given artifacts.txt file to the project. A file location for this file is used to prevent any dependency resolution whatsoever to take place. A separate local repo can be defined for loading the artifacts from, which is very much recommended.
=== Use the included test/example projects ===
Please sign in to comment.
Something went wrong with that request. Please try again.