diff --git a/README.md b/README.md index b169314..b814735 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -http://wiki.jenkins-ci.org/display/JENKINS/LineNumber \ No newline at end of file +https://plugins.jenkins.io/linenumbers \ No newline at end of file diff --git a/pom.xml b/pom.xml index a70d62b..0e26899 100644 --- a/pom.xml +++ b/pom.xml @@ -3,30 +3,34 @@ org.jenkins-ci.plugins plugin - 2.32 + 4.24 linenumbers 1.3-SNAPSHOT hpi - + Line Numbers plugin This decorates the console with line numbers - https://wiki.jenkins-ci.org/display/JENKINS/Line+Numbers+Plugin - + https://plugins.jenkins.io/linenumbers + + + 8 + + vlatombe Vincent Latombe - + scm:git:git://github.com/jenkinsci/${project.artifactId}-plugin.git scm:git:git@github.com:jenkinsci/${project.artifactId}-plugin.git HEAD - + The MIT license @@ -49,7 +53,7 @@ https://repo.jenkins-ci.org/public/ - + repo.jenkins-ci.org diff --git a/src/main/java/org/jenkinsci/plugins/linenumbers/LineNumbersAnnotator.java b/src/main/java/org/jenkinsci/plugins/linenumbers/LineNumbersAnnotator.java index a6becb7..9f7c772 100644 --- a/src/main/java/org/jenkinsci/plugins/linenumbers/LineNumbersAnnotator.java +++ b/src/main/java/org/jenkinsci/plugins/linenumbers/LineNumbersAnnotator.java @@ -1,20 +1,18 @@ /* * The MIT License - * - * Copyright (c) 20import hudson.MarkupText; -import hudson.console.ConsoleAnnotator; -import hudson.model.Run; - -import java.text.MessageFormat; -d associated documentation files (the "Software"), to deal + * + * Copyright (c) 2014, Vincent Latombe + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -31,7 +29,7 @@ d associated documentation files (the "Software"), to deal import java.text.MessageFormat; -public class LineNumbersAnnotator extends ConsoleAnnotator { +public class LineNumbersAnnotator extends ConsoleAnnotator> { private int calls = 0; @@ -44,14 +42,11 @@ public LineNumbersAnnotator(long offset) { } @Override - public ConsoleAnnotator annotate(Object context, MarkupText text) { - if (!(context instanceof Run)) { - return this; - } - Run r = (Run)context; - long start; + public ConsoleAnnotator> annotate(Run r, MarkupText text) { + + final long start; if (offset < 0) { - start = r.getLogFile().length() + offset; + start = r.getLogText().length() + offset; } else { start = offset; } diff --git a/src/main/java/org/jenkinsci/plugins/linenumbers/LineNumbersAnnotatorFactory.java b/src/main/java/org/jenkinsci/plugins/linenumbers/LineNumbersAnnotatorFactory.java index e019d02..87fd00b 100644 --- a/src/main/java/org/jenkinsci/plugins/linenumbers/LineNumbersAnnotatorFactory.java +++ b/src/main/java/org/jenkinsci/plugins/linenumbers/LineNumbersAnnotatorFactory.java @@ -1,18 +1,18 @@ /* * The MIT License - * + * * Copyright (c) 2014, Vincent Latombe - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -26,20 +26,21 @@ import hudson.Extension; import hudson.console.ConsoleAnnotator; import hudson.console.ConsoleAnnotatorFactory; +import hudson.model.Run; import org.kohsuke.stapler.Stapler; import org.kohsuke.stapler.StaplerRequest; /** * Adds line numbers to the console logs as well as bookmarkable anchors - * + * * @author vlatombe - * + * */ @Extension(ordinal = -100) -public class LineNumbersAnnotatorFactory extends ConsoleAnnotatorFactory { +public class LineNumbersAnnotatorFactory extends ConsoleAnnotatorFactory> { @Override - public ConsoleAnnotator newInstance(Object context) { + public ConsoleAnnotator> newInstance(Run context) { long offset = getOffset(Stapler.getCurrentRequest()); return new LineNumbersAnnotator(offset); } @@ -49,7 +50,7 @@ public ConsoleAnnotator newInstance(Object context) { * is from the start of the file, and a negative offset is back from the end * of the file. * Note : Copied from hudson.plugins.timestamper.annotator.TimestampAnnotatorFactory - * + * * @param request * @return the offset in bytes */