diff options
Diffstat (limited to 'framework/src/maven/apache-maven-3.3.3/maven-builder-support')
18 files changed, 1328 insertions, 0 deletions
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-builder-support/pom.xml b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/pom.xml new file mode 100644 index 00000000..791b5e4e --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/pom.xml @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- +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. +--> + +<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> + <groupId>org.apache.maven</groupId> + <artifactId>maven</artifactId> + <version>3.3.3</version> + </parent> + + <artifactId>maven-builder-support</artifactId> + + <name>Maven Builder Support</name> + <description>Support for descriptor builders (model, setting, toolchains)</description> + + <scm><!-- remove when git scm url format can accept artifact-id at the end, as automatically inherited --> + <connection>scm:git:https://git-wip-us.apache.org/repos/asf/maven.git</connection> + <developerConnection>scm:git:https://git-wip-us.apache.org/repos/asf/maven.git</developerConnection> + <tag>maven-3.3.3</tag> + </scm> + + <dependencies> + <dependency> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-utils</artifactId> + </dependency> + </dependencies> + +</project> diff --git a/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/main/java/org/apache/maven/building/DefaultProblem.java b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/main/java/org/apache/maven/building/DefaultProblem.java new file mode 100644 index 00000000..ad1fc40f --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/main/java/org/apache/maven/building/DefaultProblem.java @@ -0,0 +1,161 @@ +package org.apache.maven.building; + +/* + * 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. + */ + +/** + * Describes a problem that was encountered during settings building. A problem can either be an exception that was + * thrown or a simple string message. In addition, a problem carries a hint about its source, e.g. the settings file + * that exhibits the problem. + * + * @author Benjamin Bentmann + * @author Robert Scholte + */ +class DefaultProblem + implements Problem +{ + + private final String source; + + private final int lineNumber; + + private final int columnNumber; + + private final String message; + + private final Exception exception; + + private final Severity severity; + + /** + * Creates a new problem with the specified message and exception. + * Either {@code message} or {@code exception} is required + * + * @param message The message describing the problem, may be {@code null}. + * @param severity The severity level of the problem, may be {@code null} to default to + * {@link SettingsProblem.Severity#ERROR}. + * @param source A hint about the source of the problem like a file path, may be {@code null}. + * @param lineNumber The one-based index of the line containing the problem or {@code -1} if unknown. + * @param columnNumber The one-based index of the column containing the problem or {@code -1} if unknown. + * @param exception The exception that caused this problem, may be {@code null}. + */ + public DefaultProblem( String message, Severity severity, String source, int lineNumber, int columnNumber, + Exception exception ) + { + this.message = message; + this.severity = ( severity != null ) ? severity : Severity.ERROR; + this.source = ( source != null ) ? source : ""; + this.lineNumber = lineNumber; + this.columnNumber = columnNumber; + this.exception = exception; + } + + public String getSource() + { + return source; + } + + public int getLineNumber() + { + return lineNumber; + } + + public int getColumnNumber() + { + return columnNumber; + } + + public String getLocation() + { + StringBuilder buffer = new StringBuilder( 256 ); + + if ( getSource().length() > 0 ) + { + if ( buffer.length() > 0 ) + { + buffer.append( ", " ); + } + buffer.append( getSource() ); + } + + if ( getLineNumber() > 0 ) + { + if ( buffer.length() > 0 ) + { + buffer.append( ", " ); + } + buffer.append( "line " ).append( getLineNumber() ); + } + + if ( getColumnNumber() > 0 ) + { + if ( buffer.length() > 0 ) + { + buffer.append( ", " ); + } + buffer.append( "column " ).append( getColumnNumber() ); + } + + return buffer.toString(); + } + + public Exception getException() + { + return exception; + } + + public String getMessage() + { + String msg; + + if ( message != null && message.length() > 0 ) + { + msg = message; + } + else + { + msg = exception.getMessage(); + + if ( msg == null ) + { + msg = ""; + } + } + + return msg; + } + + public Severity getSeverity() + { + return severity; + } + + @Override + public String toString() + { + StringBuilder buffer = new StringBuilder( 128 ); + + buffer.append( "[" ).append( getSeverity() ).append( "] " ); + buffer.append( getMessage() ); + buffer.append( " @ " ).append( getLocation() ); + + return buffer.toString(); + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/main/java/org/apache/maven/building/DefaultProblemCollector.java b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/main/java/org/apache/maven/building/DefaultProblemCollector.java new file mode 100644 index 00000000..567f620e --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/main/java/org/apache/maven/building/DefaultProblemCollector.java @@ -0,0 +1,64 @@ +package org.apache.maven.building; + +/* + * 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. + */ + +import java.util.ArrayList; +import java.util.List; + +/** + * Collects problems that are encountered during settings building. + * + * @author Benjamin Bentmann + * @author Robert Scholte + */ +class DefaultProblemCollector + implements ProblemCollector +{ + + private List<Problem> problems; + + private String source; + + public DefaultProblemCollector( List<Problem> problems ) + { + this.problems = ( problems != null ) ? problems : new ArrayList<Problem>(); + } + + @Override + public List<Problem> getProblems() + { + return problems; + } + + @Override + public void setSource( String source ) + { + this.source = source; + } + + @Override + public void add( Problem.Severity severity, String message, int line, int column, Exception cause ) + { + Problem problem = new DefaultProblem( message, severity, source, line, column, cause ); + + problems.add( problem ); + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/main/java/org/apache/maven/building/FileSource.java b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/main/java/org/apache/maven/building/FileSource.java new file mode 100644 index 00000000..1a6fc2f4 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/main/java/org/apache/maven/building/FileSource.java @@ -0,0 +1,79 @@ +package org.apache.maven.building; + +/* + * 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. + */ + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; + +/** + * Wraps an ordinary {@link File} as a source. + * + * @author Benjamin Bentmann + */ +public class FileSource + implements Source +{ + private final File file; + + /** + * Creates a new source backed by the specified file. + * + * @param file The file, must not be {@code null}. + */ + public FileSource( File file ) + { + if ( file == null ) + { + throw new IllegalArgumentException( "no file specified" ); + } + this.file = file.getAbsoluteFile(); + } + + @Override + public InputStream getInputStream() + throws IOException + { + return new FileInputStream( file ); + } + + @Override + public String getLocation() + { + return file.getPath(); + } + + /** + * Gets the file of this source. + * + * @return The underlying file, never {@code null}. + */ + public File getFile() + { + return file; + } + + @Override + public String toString() + { + return getLocation(); + } +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/main/java/org/apache/maven/building/Problem.java b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/main/java/org/apache/maven/building/Problem.java new file mode 100644 index 00000000..9ab9b3a8 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/main/java/org/apache/maven/building/Problem.java @@ -0,0 +1,101 @@ +package org.apache.maven.building; + +/* + * 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. + */ + +/** + * Describes a problem that was encountered during settings building. A problem can either be an exception that was + * thrown or a simple string message. In addition, a problem carries a hint about its source, e.g. the settings file + * that exhibits the problem. + * + * @author Benjamin Bentmann + * @author Robert Scholte + */ +public interface Problem +{ + + /** + * The different severity levels for a problem, in decreasing order. + */ + enum Severity + { + + FATAL, // + ERROR, // + WARNING // + + } + + /** + * Gets the hint about the source of the problem. While the syntax of this hint is unspecified and depends on the + * creator of the problem, the general expectation is that the hint provides sufficient information to the user to + * track the problem back to its origin. A concrete example for such a source hint can be the file path or URL from + * which the settings were read. + * + * @return The hint about the source of the problem or an empty string if unknown, never {@code null}. + */ + String getSource(); + + /** + * Gets the one-based index of the line containing the problem. The line number should refer to some text file that + * is given by {@link #getSource()}. + * + * @return The one-based index of the line containing the problem or a non-positive value if unknown. + */ + int getLineNumber(); + + /** + * Gets the one-based index of the column containing the problem. The column number should refer to some text file + * that is given by {@link #getSource()}. + * + * @return The one-based index of the column containing the problem or non-positive value if unknown. + */ + int getColumnNumber(); + + /** + * Gets the location of the problem. The location is a user-friendly combination of the values from + * {@link #getSource()}, {@link #getLineNumber()} and {@link #getColumnNumber()}. The exact syntax of the returned + * value is undefined. + * + * @return The location of the problem, never {@code null}. + */ + String getLocation(); + + /** + * Gets the exception that caused this problem (if any). + * + * @return The exception that caused this problem or {@code null} if not applicable. + */ + Exception getException(); + + /** + * Gets the message that describes this problem. + * + * @return The message describing this problem, never {@code null}. + */ + String getMessage(); + + /** + * Gets the severity level of this problem. + * + * @return The severity level of this problem, never {@code null}. + */ + Severity getSeverity(); + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/main/java/org/apache/maven/building/ProblemCollector.java b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/main/java/org/apache/maven/building/ProblemCollector.java new file mode 100644 index 00000000..e7015676 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/main/java/org/apache/maven/building/ProblemCollector.java @@ -0,0 +1,59 @@ +package org.apache.maven.building; + +/* + * 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. + */ + +import java.util.List; + +/** + * Collects problems that are encountered during settings building. + * + * @author Benjamin Bentmann + * @author Robert Scholte + */ +public interface ProblemCollector +{ + + /** + * Adds the specified problem. + * Either message or exception is required + * + * @param severity The severity of the problem, must not be {@code null}. + * @param message The detail message of the problem, may be {@code null}. + * @param line The one-based index of the line containing the problem or {@code -1} if unknown. + * @param column The one-based index of the column containing the problem or {@code -1} if unknown. + * @param cause The cause of the problem, may be {@code null}. + */ + void add( Problem.Severity severity, String message, int line, int column, Exception cause ); + + /** + * The next messages will be bound to this source. When calling this method again, previous messages keep + * their source, but the next messages will use the new source. + * + * @param source + */ + void setSource( String source ); + + /** + * + * @return the collected Problems, never {@code null} + */ + List<Problem> getProblems(); + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/main/java/org/apache/maven/building/ProblemCollectorFactory.java b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/main/java/org/apache/maven/building/ProblemCollectorFactory.java new file mode 100644 index 00000000..c1c23737 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/main/java/org/apache/maven/building/ProblemCollectorFactory.java @@ -0,0 +1,43 @@ +package org.apache.maven.building; + +/* + * 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. + */ + +import java.util.List; + +/** + * + * @author Robert Scholte + * @since 3.3.0 + */ +public class ProblemCollectorFactory +{ + + /** + * The default implementation is not visible, create it with this factory + * + * @param problems starting set of problems, may be {@code null} + * @return a new instance of a ProblemCollector + */ + public static ProblemCollector newInstance( List<Problem> problems ) + { + return new DefaultProblemCollector( problems ); + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/main/java/org/apache/maven/building/Source.java b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/main/java/org/apache/maven/building/Source.java new file mode 100644 index 00000000..1f7510ba --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/main/java/org/apache/maven/building/Source.java @@ -0,0 +1,49 @@ +package org.apache.maven.building; + +/* + * 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. + */ + +import java.io.IOException; +import java.io.InputStream; + +/** + * Provides access to the contents of a source independently of the backing store (e.g. file system, database, memory). + * + * @author Benjamin Bentmann + */ +public interface Source +{ + + /** + * Gets a byte stream to the source contents. Closing the returned stream is the responsibility of the caller. + * + * @return A byte stream to the source contents, never {@code null}. + */ + InputStream getInputStream() + throws IOException; + + /** + * Provides a user-friendly hint about the location of the source. This could be a local file path, a URI or just an + * empty string. The intention is to assist users during error reporting. + * + * @return A user-friendly hint about the location of the source, never {@code null}. + */ + String getLocation(); + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/main/java/org/apache/maven/building/StringSource.java b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/main/java/org/apache/maven/building/StringSource.java new file mode 100644 index 00000000..f9d87c0b --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/main/java/org/apache/maven/building/StringSource.java @@ -0,0 +1,90 @@ +package org.apache.maven.building; + +/* + * 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. + */ + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; + +/** + * Wraps an ordinary {@link CharSequence} as a source. + * + * @author Benjamin Bentmann + */ +public class StringSource + implements Source +{ + + private String content; + + private String location; + + /** + * Creates a new source backed by the specified string. + * + * @param content The String representation, may be empty or {@code null}. + */ + public StringSource( CharSequence content ) + { + this( content, null ); + } + + /** + * Creates a new source backed by the specified string. + * + * @param content The String representation, may be empty or {@code null}. + * @param location The location to report for this use, may be {@code null}. + */ + public StringSource( CharSequence content, String location ) + { + this.content = ( content != null ) ? content.toString() : ""; + this.location = ( location != null ) ? location : "(memory)"; + } + + @Override + public InputStream getInputStream() + throws IOException + { + return new ByteArrayInputStream( content.getBytes( "UTF-8" ) ); + } + + @Override + public String getLocation() + { + return location; + } + + /** + * Gets the content of this source. + * + * @return The underlying character stream, never {@code null}. + */ + public String getContent() + { + return content; + } + + @Override + public String toString() + { + return getLocation(); + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/main/java/org/apache/maven/building/UrlSource.java b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/main/java/org/apache/maven/building/UrlSource.java new file mode 100644 index 00000000..7bd3e3c3 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/main/java/org/apache/maven/building/UrlSource.java @@ -0,0 +1,80 @@ +package org.apache.maven.building; + +/* + * 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. + */ + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; + +/** + * Wraps an ordinary {@link URL} as a source. + * + * @author Benjamin Bentmann + */ +public class UrlSource + implements Source +{ + + private URL url; + + /** + * Creates a new source backed by the specified URL. + * + * @param url The file, must not be {@code null}. + */ + public UrlSource( URL url ) + { + if ( url == null ) + { + throw new IllegalArgumentException( "no url specified" ); + } + this.url = url; + } + + @Override + public InputStream getInputStream() + throws IOException + { + return url.openStream(); + } + + @Override + public String getLocation() + { + return url.toString(); + } + + /** + * Gets the URL of this source. + * + * @return The underlying URL, never {@code null}. + */ + public URL getUrl() + { + return url; + } + + @Override + public String toString() + { + return getLocation(); + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/site/site.xml b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/site/site.xml new file mode 100644 index 00000000..3a16bf98 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/site/site.xml @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- +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. +--> + +<project xmlns="http://maven.apache.org/DECORATION/1.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd"> + <body> + <menu name="Overview"> + <item name="Introduction" href="index.html"/> + <item name="JavaDocs" href="apidocs/index.html"/> + <item name="Source Xref" href="xref/index.html"/> + <!--item name="FAQ" href="faq.html"/--> + </menu> + + <menu ref="parent"/> + <menu ref="reports"/> + </body> +</project>
\ No newline at end of file diff --git a/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/DefaultProblemCollectorTest.java b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/DefaultProblemCollectorTest.java new file mode 100644 index 00000000..bf0f8477 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/DefaultProblemCollectorTest.java @@ -0,0 +1,76 @@ +package org.apache.maven.building; + +/* + * 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. + */ + +import static org.junit.Assert.*; + +import org.apache.maven.building.Problem.Severity; +import org.junit.Test; + +public class DefaultProblemCollectorTest +{ + + @Test + public void testGetProblems() + { + DefaultProblemCollector collector = new DefaultProblemCollector( null ); + assertNotNull( collector.getProblems() ); + assertEquals( 0, collector.getProblems().size() ); + + collector.add( null, "MESSAGE1", -1, -1, null ); + + Exception e2 = new Exception(); + collector.add( Severity.WARNING, null, 42, 127, e2 ); + + assertEquals( 2, collector.getProblems().size() ); + + Problem p1 = collector.getProblems().get(0); + assertEquals( Severity.ERROR, p1.getSeverity() ); + assertEquals( "MESSAGE1",p1.getMessage() ); + assertEquals( -1, p1.getLineNumber() ); + assertEquals( -1, p1.getColumnNumber() ); + assertEquals( null, p1.getException() ); + + Problem p2 = collector.getProblems().get(1); + assertEquals( Severity.WARNING, p2.getSeverity() ); + assertEquals( "",p2.getMessage() ); + assertEquals( 42, p2.getLineNumber() ); + assertEquals( 127, p2.getColumnNumber() ); + assertEquals( e2, p2.getException() ); + } + + @Test + public void testSetSource() + { + DefaultProblemCollector collector = new DefaultProblemCollector( null ); + + collector.add( null, "PROBLEM1", -1, -1, null ); + + collector.setSource( "SOURCE_PROBLEM2" ); + collector.add( null, "PROBLEM2", -1, -1, null ); + + collector.setSource( "SOURCE_PROBLEM3" ); + collector.add( null, "PROBLEM3", -1, -1, null ); + + assertEquals( "", collector.getProblems().get( 0 ).getSource() ); + assertEquals( "SOURCE_PROBLEM2", collector.getProblems().get( 1 ).getSource() ); + assertEquals( "SOURCE_PROBLEM3", collector.getProblems().get( 2 ).getSource() ); + } +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/DefaultProblemTest.java b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/DefaultProblemTest.java new file mode 100644 index 00000000..80a20da9 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/DefaultProblemTest.java @@ -0,0 +1,136 @@ +package org.apache.maven.building; + +/* + * 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. + */ + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertSame; + +import org.apache.maven.building.Problem.Severity; +import org.junit.Test; + +public class DefaultProblemTest +{ + + @Test + public void testGetSeverity() + { + DefaultProblem problem = new DefaultProblem( null, null, null, -1, -1, null ); + assertEquals( Severity.ERROR, problem.getSeverity() ); + + problem = new DefaultProblem( null, Severity.FATAL, null, -1, -1, null ); + assertEquals( Severity.FATAL, problem.getSeverity() ); + + problem = new DefaultProblem( null, Severity.ERROR, null, -1, -1, null ); + assertEquals( Severity.ERROR, problem.getSeverity() ); + + problem = new DefaultProblem( null, Severity.WARNING, null, -1, -1, null ); + assertEquals( Severity.WARNING, problem.getSeverity() ); + } + + @Test + public void testGetLineNumber() + { + DefaultProblem problem = new DefaultProblem( null, null, null, -1, -1, null ); + assertEquals( -1, problem.getLineNumber() ); + + problem = new DefaultProblem( null, null, null, 42, -1, null ); + assertEquals( 42, problem.getLineNumber() ); + + problem = new DefaultProblem( null, null, null, Integer.MAX_VALUE, -1, null ); + assertEquals( Integer.MAX_VALUE, problem.getLineNumber() ); + + // this case is not specified, might also return -1 + problem = new DefaultProblem( null, null, null, Integer.MIN_VALUE, -1, null ); + assertEquals( Integer.MIN_VALUE, problem.getLineNumber() ); + } + + @Test + public void testGetColumnNumber() + { + DefaultProblem problem = new DefaultProblem( null, null, null, -1, -1, null ); + assertEquals( -1, problem.getColumnNumber() ); + + problem = new DefaultProblem( null, null, null, -1, 42, null ); + assertEquals( 42, problem.getColumnNumber() ); + + problem = new DefaultProblem( null, null, null, -1, Integer.MAX_VALUE, null ); + assertEquals( Integer.MAX_VALUE, problem.getColumnNumber() ); + + // this case is not specified, might also return -1 + problem = new DefaultProblem( null, null, null, -1, Integer.MIN_VALUE, null ); + assertEquals( Integer.MIN_VALUE, problem.getColumnNumber() ); + } + + @Test + public void testGetException() + { + DefaultProblem problem = new DefaultProblem( null, null, null, -1, -1, null ); + assertEquals( null, problem.getException() ); + + Exception e = new Exception(); + problem = new DefaultProblem( null, null, null, -1, -1, e ); + assertSame( e, problem.getException() ); + } + + @Test + public void testGetSource() + { + DefaultProblem problem = new DefaultProblem( null, null, null, -1, -1, null ); + assertEquals( "", problem.getSource() ); + + problem = new DefaultProblem( null, null, "", -1, -1, null ); + assertEquals( "", problem.getSource() ); + + problem = new DefaultProblem( null, null, "SOURCE", -1, -1, null ); + assertEquals( "SOURCE", problem.getSource() ); + } + + @Test + public void testGetLocation() + { + DefaultProblem problem = new DefaultProblem( null, null, null, -1, -1, null ); + assertEquals( "", problem.getLocation() ); + + problem = new DefaultProblem( null, null, "SOURCE", -1, -1, null ); + assertEquals( "SOURCE", problem.getLocation() ); + + problem = new DefaultProblem( null, null, null, 42, -1, null ); + assertEquals( "line 42", problem.getLocation() ); + + problem = new DefaultProblem( null, null, null, -1, 127, null ); + assertEquals( "column 127", problem.getLocation() ); + + problem = new DefaultProblem( null, null, "SOURCE", 42, 127, null ); + assertEquals( "SOURCE, line 42, column 127", problem.getLocation() ); + } + + @Test + public void testGetMessage() + { + DefaultProblem problem = new DefaultProblem( "MESSAGE", null, null, -1, -1, null ); + assertEquals( "MESSAGE", problem.getMessage() ); + + problem = new DefaultProblem( null, null, null, -1, -1, new Exception() ); + assertEquals( "", problem.getMessage() ); + + problem = new DefaultProblem( null, null, null, -1, -1, new Exception( "EXCEPTION MESSAGE" ) ); + assertEquals( "EXCEPTION MESSAGE", problem.getMessage() ); + } +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/FileSourceTest.java b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/FileSourceTest.java new file mode 100644 index 00000000..086adda8 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/FileSourceTest.java @@ -0,0 +1,93 @@ +package org.apache.maven.building; + +/* + * 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. + */ + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import java.io.File; +import java.io.InputStream; +import java.util.Scanner; + +import org.junit.Test; + +public class FileSourceTest +{ + + @Test + public void testFileSource() + { + try + { + new FileSource( null ); + fail( "Should fail, since you must specify a file" ); + } + catch ( IllegalArgumentException e ) + { + assertEquals( "no file specified", e.getMessage() ); + } + } + + @Test + public void testGetInputStream() + throws Exception + { + File txtFile = new File( "target/test-classes/source.txt" ); + FileSource source = new FileSource( txtFile ); + + Scanner scanner = null; + InputStream is = null; + try + { + is = source.getInputStream(); + + scanner = new Scanner( is ); + assertEquals( "Hello World!", scanner.nextLine() ); + } + finally + { + if ( scanner != null ) + { + scanner.close(); + } + if ( is != null ) + { + is.close(); + } + } + } + + @Test + public void testGetLocation() + { + File txtFile = new File( "target/test-classes/source.txt" ); + FileSource source = new FileSource( txtFile ); + assertEquals( txtFile.getAbsolutePath(), source.getLocation() ); + } + + @Test + public void testGetFile() + { + File txtFile = new File( "target/test-classes/source.txt" ); + FileSource source = new FileSource( txtFile ); + assertEquals( txtFile.getAbsoluteFile(), source.getFile() ); + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/ProblemCollectorFactoryTest.java b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/ProblemCollectorFactoryTest.java new file mode 100644 index 00000000..44c7906c --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/ProblemCollectorFactoryTest.java @@ -0,0 +1,45 @@ +package org.apache.maven.building; + +/* + * 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. + */ + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotSame; + +import java.util.Collections; + +import org.junit.Test; + +public class ProblemCollectorFactoryTest +{ + + @Test + public void testNewInstance() + { + ProblemCollector collector1 = ProblemCollectorFactory.newInstance( null ); + + Problem problem = new DefaultProblem( "MESSAGE1", null, null, -1, -1, null ); + ProblemCollector collector2 = ProblemCollectorFactory.newInstance( Collections.singletonList( problem ) ); + + assertNotSame( collector1, collector2 ); + assertEquals( 0, collector1.getProblems().size() ); + assertEquals( 1, collector2.getProblems().size() ); + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/StringSourceTest.java b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/StringSourceTest.java new file mode 100644 index 00000000..013b8a4d --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/StringSourceTest.java @@ -0,0 +1,79 @@ +package org.apache.maven.building; + +/* + * 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. + */ + +import static org.junit.Assert.assertEquals; + +import java.io.InputStream; +import java.util.Scanner; + +import org.junit.Test; + +public class StringSourceTest +{ + @Test + public void testGetInputStream() + throws Exception + { + StringSource source = new StringSource( "Hello World!" ); + + Scanner scanner = null; + InputStream is = null; + try + { + is = source.getInputStream(); + + scanner = new Scanner( is ); + assertEquals( "Hello World!", scanner.nextLine() ); + } + finally + { + if ( scanner != null ) + { + scanner.close(); + } + if ( is != null ) + { + is.close(); + } + } + } + + @Test + public void testGetLocation() + { + StringSource source = new StringSource( "Hello World!" ); + assertEquals( "(memory)", source.getLocation() ); + + source = new StringSource( "Hello World!", "LOCATION" ); + assertEquals( "LOCATION", source.getLocation() ); + } + + @Test + public void testGetContent() + { + StringSource source = new StringSource( null ); + assertEquals( "", source.getContent() ); + + source = new StringSource( "Hello World!", "LOCATION" ); + assertEquals( "Hello World!", source.getContent() ); + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/UrlSourceTest.java b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/UrlSourceTest.java new file mode 100644 index 00000000..5524c9b3 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/UrlSourceTest.java @@ -0,0 +1,87 @@ +package org.apache.maven.building; + +/* + * 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. + */ + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import java.io.File; +import java.io.InputStream; +import java.net.URL; +import java.util.Scanner; + +import org.junit.Test; + +public class UrlSourceTest +{ + + @Test + public void testUrlSource() + { + try + { + new UrlSource( null ); + fail( "Should fail, since you must specify a url" ); + } + catch ( IllegalArgumentException e ) + { + assertEquals( "no url specified", e.getMessage() ); + } + } + + @Test + public void testGetInputStream() + throws Exception + { + URL txtFile = new File( "target/test-classes/source.txt" ).toURI().toURL(); + UrlSource source = new UrlSource( txtFile ); + + Scanner scanner = null; + InputStream is = null; + try + { + is = source.getInputStream(); + + scanner = new Scanner( is ); + assertEquals( "Hello World!", scanner.nextLine() ); + } + finally + { + if ( scanner != null ) + { + scanner.close(); + } + if ( is != null ) + { + is.close(); + } + } + } + + @Test + public void testGetLocation() + throws Exception + { + URL txtFile = new File( "target/test-classes/source.txt" ).toURI().toURL(); + UrlSource source = new UrlSource( txtFile ); + assertEquals( txtFile.toExternalForm(), source.getLocation() ); + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/resources/source.txt b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/resources/source.txt new file mode 100644 index 00000000..c57eff55 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/resources/source.txt @@ -0,0 +1 @@ +Hello World!
\ No newline at end of file |