Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 45acb4a

Browse filesBrowse files
author
Igor Fedorenko
committed
Introduced API to report build errors and warnings back to build workspace host. The idea is to allow the host associate messages with file/line/column.
git-svn-id: file:///opt/svn/repositories/sonatype.org/spice/trunk/plexus-build-api@1791 5751e0cb-dcb7-432f-92e2-260806df54be
1 parent 1ad04e2 commit 45acb4a
Copy full SHA for 45acb4a

File tree

Expand file treeCollapse file tree

4 files changed

+62
-7
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+62
-7
lines changed
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
Copyright (c) 2008 Sonatype, Inc. All rights reserved.
3+
4+
This program is licensed to you under the Apache License Version 2.0,
5+
and you may not use this file except in compliance with the Apache License Version 2.0.
6+
You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
7+
8+
Unless required by applicable law or agreed to in writing,
9+
software distributed under the Apache License Version 2.0 is distributed on an
10+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
12+
*/
13+
package org.sonatype.plexus.build.incremental;
14+
15+
import java.io.File;
16+
17+
public interface BuildContext2 extends BuildContext {
18+
public void addWarning(File file, int line, int column, String message, Throwable cause);
19+
20+
public void addError(File file, int line, int column, String message, Throwable cause);
21+
}

‎src/main/java/org/sonatype/plexus/build/incremental/DefaultBuildContext.java

Copy file name to clipboardExpand all lines: src/main/java/org/sonatype/plexus/build/incremental/DefaultBuildContext.java
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,10 @@ public Object getValue(String key) {
7777

7878
public void setValue(String key, Object value) {
7979
}
80+
81+
public void addWarning(File file, int line, int column, String message, Throwable cause) {
82+
}
83+
84+
public void addError(File file, int line, int column, String message, Throwable cause) {
85+
}
8086
}

‎src/main/java/org/sonatype/plexus/build/incremental/ThreadBuildContext.java

Copy file name to clipboardExpand all lines: src/main/java/org/sonatype/plexus/build/incremental/ThreadBuildContext.java
+15-3Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
import java.io.OutputStream;
1919
import java.util.List;
2020

21-
import org.sonatype.plexus.build.incremental.BuildContext;
22-
import org.sonatype.plexus.build.incremental.DefaultBuildContext;
2321
import org.codehaus.plexus.util.Scanner;
2422

2523
/**
@@ -31,7 +29,7 @@
3129
* Apparently, older version of plexus used by maven-filtering and likely
3230
* other projects, does not honour "default" role-hint.
3331
*/
34-
public class ThreadBuildContext implements BuildContext {
32+
public class ThreadBuildContext implements BuildContext, BuildContext2 {
3533

3634
private static final ThreadLocal threadContext = new ThreadLocal();
3735

@@ -89,4 +87,18 @@ public void setValue(String key, Object value) {
8987
getContext().setValue(key, value);
9088
}
9189

90+
public void addWarning(File file, int line, int column, String message, Throwable cause) {
91+
BuildContext context = getContext();
92+
if (context instanceof BuildContext2) {
93+
((BuildContext2) context).addWarning(file, line, column, message, cause);
94+
}
95+
}
96+
97+
public void addError(File file, int line, int column, String message, Throwable cause) {
98+
BuildContext context = getContext();
99+
if (context instanceof BuildContext2) {
100+
((BuildContext2) context).addError(file, line, column, message, cause);
101+
}
102+
}
103+
92104
}

‎src/test/java/org/sonatype/plexus/build/incremental/test/TestIncrementalBuildContext.java

Copy file name to clipboardExpand all lines: src/test/java/org/sonatype/plexus/build/incremental/test/TestIncrementalBuildContext.java
+20-4Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import java.io.FileOutputStream;
1818
import java.io.IOException;
1919
import java.io.OutputStream;
20+
import java.util.ArrayList;
2021
import java.util.HashSet;
2122
import java.util.Iterator;
2223
import java.util.List;
@@ -26,10 +27,11 @@
2627
import org.codehaus.plexus.util.DirectoryScanner;
2728
import org.codehaus.plexus.util.Scanner;
2829
import org.sonatype.plexus.build.incremental.BuildContext;
30+
import org.sonatype.plexus.build.incremental.BuildContext2;
2931

3032

31-
public class TestIncrementalBuildContext implements BuildContext {
32-
33+
public class TestIncrementalBuildContext implements BuildContext, BuildContext2 {
34+
3335
private final File basedir;
3436

3537
private final HashSet refresh = new HashSet();
@@ -74,16 +76,25 @@ public File getBasedir() {
7476

7577
private final Map context;
7678

79+
private final List warnings;
80+
81+
private final List errors;
7782

78-
public TestIncrementalBuildContext(File basedir, Set files, Map context) {
79-
this(basedir, files, new HashSet(), context);
83+
public TestIncrementalBuildContext(File basedir, Set changedFiles, Map context) {
84+
this(basedir, changedFiles, new HashSet(), context);
8085
}
8186

8287
public TestIncrementalBuildContext(File basedir, Set changedFiles, Set deletedFiles, Map context) {
88+
this(basedir, changedFiles, new HashSet(), context, new ArrayList(), new ArrayList());
89+
}
90+
91+
public TestIncrementalBuildContext(File basedir, Set changedFiles, Set deletedFiles, Map context, List warnings, List errors) {
8392
this.basedir = basedir;
8493
this.changedFiles = changedFiles;
8594
this.deletedFiles = deletedFiles;
8695
this.context = context;
96+
this.warnings = warnings;
97+
this.errors = errors;
8798
}
8899

89100
public boolean hasDelta(String relpath) {
@@ -149,4 +160,9 @@ public Set getRefreshFiles() {
149160
return refresh;
150161
}
151162

163+
public void addError(File file, int line, int column, String message, Throwable cause) {
164+
}
165+
166+
public void addWarning(File file, int line, int column, String message, Throwable cause) {
167+
}
152168
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.