Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,19 @@ public class DefaultReportingConverter implements ReportingConverter {
private final InputLocation location;

{
String modelId = "org.apache.maven:maven-model-builder:"
+ this.getClass().getPackage().getImplementationVersion() + ":reporting-converter";
String modelId =
"org.apache.maven:maven-model-builder:" + getImplementationVersion(getClass()) + ":reporting-converter";
InputSource inputSource = new InputSource();
inputSource.setModelId(modelId);
location = new InputLocation(-1, -1, inputSource);
location.setLocation(0, location);
}

static String getImplementationVersion(Class<?> clazz) {
Package packageInfo = clazz.getPackage();
return packageInfo != null ? packageInfo.getImplementationVersion() : null;
}

@Override
public void convertReporting(Model model, ModelBuildingRequest request, ModelProblemCollector problems) {
Reporting reporting = model.getReporting();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ public Model getSuperModel(String version) {
Map<String, Object> options = new HashMap<>();
options.put("xml:4.0.0", "xml:4.0.0");

String modelId = "org.apache.maven:maven-model-builder:"
+ this.getClass().getPackage().getImplementationVersion() + ":super-pom";
String modelId =
"org.apache.maven:maven-model-builder:" + getImplementationVersion(getClass()) + ":super-pom";
InputSource inputSource = new InputSource();
inputSource.setModelId(modelId);
inputSource.setLocation(getClass().getResource(resource).toExternalForm());
Expand All @@ -88,4 +88,9 @@ public Model getSuperModel(String version) {

return superModel;
}

static String getImplementationVersion(Class<?> clazz) {
Package packageInfo = clazz.getPackage();
return packageInfo != null ? packageInfo.getImplementationVersion() : null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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.
*/
package org.apache.maven.model.plugin;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertNull;

class DefaultReportingConverterTest {

@Test
void returnsNullImplementationVersionWhenClassHasNoPackage() {
assertNull(DefaultReportingConverter.getImplementationVersion(int.class));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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.
*/
package org.apache.maven.model.superpom;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertNull;

class DefaultSuperPomProviderTest {

@Test
void returnsNullImplementationVersionWhenClassHasNoPackage() {
assertNull(DefaultSuperPomProvider.getImplementationVersion(int.class));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public class DefaultLifecycleRegistry implements LifecycleRegistry {
private static final String MAVEN_PLUGINS = "org.apache.maven.plugins:";

public static final String DEFAULT_LIFECYCLE_MODELID = "org.apache.maven:maven-core:"
+ DefaultLifecycleRegistry.class.getPackage().getImplementationVersion()
+ getImplementationVersion(DefaultLifecycleRegistry.class)
+ ":default-lifecycle-bindings";

public static final InputLocation DEFAULT_LIFECYCLE_INPUT_LOCATION =
Expand Down Expand Up @@ -122,6 +122,11 @@ public DefaultLifecycleRegistry(List<LifecycleProvider> providers) {
}
}

static String getImplementationVersion(Class<?> clazz) {
Package packageInfo = clazz.getPackage();
return packageInfo != null ? packageInfo.getImplementationVersion() : null;
}

@Override
public Iterator<Lifecycle> iterator() {
return stream().toList().iterator();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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.
*/
package org.apache.maven.internal.impl;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertNull;

class DefaultLifecycleRegistryTest {

@Test
void returnsNullImplementationVersionWhenClassHasNoPackage() {
assertNull(DefaultLifecycleRegistry.getImplementationVersion(int.class));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ private Model readModel(String version, String v) {
+ ", please verify the integrity of your Maven installation");
}
try (InputStream is = url.openStream()) {
String modelId = "org.apache.maven:maven-api-impl:"
+ this.getClass().getPackage().getImplementationVersion() + ":super-pom-" + version;
String modelId =
"org.apache.maven:maven-api-impl:" + getImplementationVersion(getClass()) + ":super-pom-" + version;
return modelProcessor.read(XmlReaderRequest.builder()
.modelId(modelId)
.location(url.toExternalForm())
Expand All @@ -77,4 +77,9 @@ private Model readModel(String version, String v) {
e);
}
}

static String getImplementationVersion(Class<?> clazz) {
Package packageInfo = clazz.getPackage();
return packageInfo != null ? packageInfo.getImplementationVersion() : null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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.
*/
package org.apache.maven.impl;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertNull;

class DefaultSuperPomProviderTest {

@Test
void returnsNullImplementationVersionWhenClassHasNoPackage() {
assertNull(DefaultSuperPomProvider.getImplementationVersion(int.class));
}
}
Loading