FELIX-4822 : Create markers in m2e for baseline warnings/errors - revert changes for now
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1663974 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
index 4d3074f..4e5835f 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
@@ -524,7 +524,7 @@
{
sb.append(",");
}
- sb.append(sb);
+ sb.append(s);
}
properties.setProperty(Analyzer.PLUGIN, sb.toString());
}
diff --git a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/baseline/AbstractBaselinePlugin.java b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/baseline/AbstractBaselinePlugin.java
index c167b61..6d43198 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/baseline/AbstractBaselinePlugin.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/baseline/AbstractBaselinePlugin.java
@@ -232,15 +232,6 @@
try
{
- this.reportErrors(infos);
- }
- catch ( final IOException ioe )
- {
- throw new MojoExecutionException("Unable to parse baselining information.", ioe);
- }
-
- try
- {
// go!
context = this.init(context);
startBaseline( context, generationDate, project.getArtifactId(), project.getVersion(), previousArtifact.getVersion() );
@@ -424,12 +415,6 @@
protected abstract void endBaseline(final Object context);
- protected void reportErrors(final Info[] infos)
- throws IOException
- {
- // nothing to do, will be overridden by baseline plugin
- }
-
// internals
private Jar getCurrentBundle()
diff --git a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/baseline/BaselinePlugin.java b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/baseline/BaselinePlugin.java
index 8ef49b5..74219f2 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/baseline/BaselinePlugin.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/baseline/BaselinePlugin.java
@@ -21,21 +21,12 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
-import java.io.LineNumberReader;
-import java.io.StringReader;
import java.util.Map;
import java.util.Map.Entry;
-import org.codehaus.plexus.util.FileUtils;
-import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
import org.codehaus.plexus.util.xml.XMLWriter;
-import org.sonatype.plexus.build.incremental.BuildContext;
-import aQute.bnd.differ.Baseline.Info;
-import aQute.bnd.service.diff.Delta;
-import aQute.bnd.service.diff.Diff;
-import aQute.bnd.service.diff.Type;
import aQute.bnd.version.Version;
/**
@@ -67,11 +58,6 @@
*/
private boolean logResults;
- /**
- * @component
- */
- private BuildContext buildContext;
-
private static final class Context {
public FileWriter writer;
public XMLWriter xmlWriter;
@@ -301,225 +287,4 @@
xmlWriter.writeText( value );
xmlWriter.endElement();
}
-
- @Override
- protected void reportErrors(final Info[] infos)
- throws IOException
- {
- for ( final Info info : infos )
- {
- // clear previous messages
- final FileMarker packageMarker = findMarkerLocationForPackage(info.packageName);
-
- if ( info.suggestedVersion != null )
- {
- if ( info.newerVersion.compareTo( info.suggestedVersion ) > 0 )
- {
- final String msg = "Excessive version increase: detected " + info.newerVersion + ", suggested " + info.suggestedVersion;
-
- this.buildContext.addMessage(packageMarker.file, packageMarker.line, packageMarker.col, msg, BuildContext.SEVERITY_WARNING, null);
- }
- else if ( info.newerVersion.compareTo( info.suggestedVersion ) < 0 )
- {
- final String msg = "Version increase required: detected " + info.newerVersion + ", suggested " + info.suggestedVersion;
-
- this.buildContext.addMessage(packageMarker.file, packageMarker.line, packageMarker.col, msg, BuildContext.SEVERITY_ERROR, null);
- }
- }
-
- if ( info.packageDiff.getDelta() == Delta.UNCHANGED && info.newerVersion.compareTo( info.suggestedVersion ) != 0 )
- {
- final String msg = "Version has been increased but analysis detected no changes: detected " + info.newerVersion + ", suggested " + info.suggestedVersion;
- this.buildContext.addMessage(packageMarker.file, packageMarker.line, packageMarker.col, msg, BuildContext.SEVERITY_WARNING, null);
- }
- generateStructuralChangeMarkers(info);
- }
- }
-
- private File getPackageFile(final String packageName)
- {
- final String sourceDir = this.project.getBuild().getSourceDirectory();
- final File packageDir = new File((sourceDir + '/' + packageName.replace('.', '/')).replace('/', File.separatorChar));
-
- return packageDir;
- }
-
- private File getSourceFile(final String className)
- {
- final String sourceDir = this.project.getBuild().getSourceDirectory();
- final File packageDir = new File((sourceDir + '/' + className.replace('.', '/') + ".java").replace('/', File.separatorChar));
-
- return packageDir;
- }
-
- private static final class FileMarker
- {
- public File file;
- public int line;
- public int col;
- }
-
- /**
- * Find marker location for a package
- * and clear old markers.
- */
- private FileMarker findMarkerLocationForPackage(final String packageName)
- throws IOException
- {
- final File packageDir = getPackageFile(packageName);
- this.buildContext.removeMessages(packageDir);
-
- final File packageInfoFile = new File(packageDir, "packageinfo");
- this.buildContext.removeMessages(packageInfoFile);
-
- final File packageInfoJavaFile = new File(packageDir, "package-info.java");
- this.buildContext.removeMessages(packageInfoJavaFile);
-
- // package-info.java has precedence
- if ( packageInfoJavaFile != null && packageInfoJavaFile.exists() )
- {
- return findVersionLocationInPackageInfoJava(packageInfoJavaFile);
- }
- // packageinfo next
- if ( packageInfoFile != null && packageInfoFile.exists() )
- {
- return findVersionLocationInPackageInfo(packageInfoFile);
- }
-
- final FileMarker defaultMarker = new FileMarker();
- defaultMarker.file = packageDir;
-
- return defaultMarker;
- }
-
- private FileMarker findVersionLocationInPackageInfo(final File file)
- throws IOException
- {
- final FileMarker marker = new FileMarker();
- marker.file = file;
- final String contents = FileUtils.fileRead(file);
- final LineNumberReader reader = new LineNumberReader(new StringReader(contents));
- try
- {
- String line;
- while ( (line = reader.readLine()) != null )
- {
- final int pos = line.indexOf("version ");
- if ( pos > -1 )
- {
- marker.col = pos;
- marker.line = reader.getLineNumber();
-
- break;
- }
- }
- }
- finally
- {
- IOUtil.close(reader);
- }
- return marker;
- }
-
- private FileMarker findVersionLocationInPackageInfoJava(final File file)
- throws IOException
- {
- final FileMarker marker = new FileMarker();
- marker.file = file;
- final String contents = FileUtils.fileRead(file);
- final LineNumberReader reader = new LineNumberReader(new StringReader(contents));
- try
- {
- String line;
- while ( (line = reader.readLine()) != null )
- {
- final int pos = line.indexOf("@Version");
- if ( pos > -1 )
- {
- marker.col = pos;
- marker.line = reader.getLineNumber();
-
- break;
- }
- }
- }
- finally
- {
- IOUtil.close(reader);
- }
- return marker;
- }
-
- private void generateStructuralChangeMarkers(final Info baselineInfo)
- {
- final Delta packageDelta = baselineInfo.packageDiff.getDelta();
-
- // Iterate into the package member diffs
- for (final Diff pkgMemberDiff : baselineInfo.packageDiff.getChildren())
- {
- // only deal with interfaces and classes
- if ( pkgMemberDiff.getType() != Type.INTERFACE && pkgMemberDiff.getType() != Type.CLASS )
- {
- continue;
- }
-
- // clear old marker
- final String className = pkgMemberDiff.getName();
- final File classFile = this.getSourceFile(className);
- this.buildContext.removeMessages(classFile);
-
- // Skip deltas that have lesser significance than the overall package delta
- if (pkgMemberDiff.getDelta().ordinal() < packageDelta.ordinal())
- {
- continue;
- }
-
- if (Delta.ADDED == pkgMemberDiff.getDelta())
- {
- // TODO
- }
- else if (Delta.REMOVED == pkgMemberDiff.getDelta())
- {
- // TODO
- }
- else
- {
- // Iterate into the class member diffs
- for (final Diff classMemberDiff : pkgMemberDiff.getChildren())
- {
- // Skip deltas that have lesser significance than the overall package delta (again)
- if (classMemberDiff.getDelta().ordinal() < packageDelta.ordinal())
- continue;
-
- if (Delta.ADDED == classMemberDiff.getDelta())
- {
- addAddedMarker(classFile, classMemberDiff);
- }
- else if (Delta.REMOVED == classMemberDiff.getDelta())
- {
- addRemovedMarker(classFile, classMemberDiff);
- }
- else if (Delta.CHANGED == classMemberDiff.getDelta())
- {
- addChangedMarker(classFile, classMemberDiff);
- }
- }
- }
- }
- }
-
- private void addAddedMarker(final File classFile, final Diff diff)
- {
- this.buildContext.addMessage(classFile, 0, 0, diff.getType() + " " + diff.getName() + " has been added.", BuildContext.SEVERITY_ERROR, null);
- }
-
- private void addRemovedMarker(final File classFile, final Diff diff)
- {
- this.buildContext.addMessage(classFile, 0, 0, diff.getType() + " " + diff.getName() + " has been removed.", BuildContext.SEVERITY_ERROR, null);
- }
-
- private void addChangedMarker(final File classFile, final Diff diff)
- {
- this.buildContext.addMessage(classFile, 0, 0, diff.getType() + " " + diff.getName() + " has been changed.", BuildContext.SEVERITY_ERROR, null);
- }
}
diff --git a/bundleplugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml b/bundleplugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
deleted file mode 100644
index f0c0290..0000000
--- a/bundleplugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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.
--->
-<lifecycleMappingMetadata>
- <pluginExecutions>
- <pluginExecution>
- <pluginExecutionFilter>
- <goals>
- <goal>baseline</goal>
- </goals>
- </pluginExecutionFilter>
- <action>
- <execute>
- <runOnIncremental>true</runOnIncremental>
- </execute>
- </action>
- </pluginExecution>
- </pluginExecutions>
-</lifecycleMappingMetadata>