-
-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
convert external reference type by value instead of default CONSTANT_…
…NAME fixes #463 Signed-off-by: Hervé Boutemy <[email protected]>
- Loading branch information
Showing
8 changed files
with
55 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/main/java/org/cyclonedx/maven/ExtendedMojoConfigurator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.cyclonedx.maven; | ||
|
||
import org.codehaus.plexus.component.configurator.BasicComponentConfigurator; | ||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; | ||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; | ||
|
||
import javax.inject.Named; | ||
|
||
@Named("cyclonedx-mojo-component-configurator") | ||
public class ExtendedMojoConfigurator extends BasicComponentConfigurator implements Initializable { | ||
|
||
@Override | ||
public void initialize() throws InitializationException { | ||
converterLookup.registerConverter(new ExternalReferenceTypeConverter()); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/org/cyclonedx/maven/ExternalReferenceTypeConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.cyclonedx.maven; | ||
|
||
import org.codehaus.plexus.component.configurator.ComponentConfigurationException; | ||
import org.codehaus.plexus.component.configurator.converters.basic.AbstractBasicConverter; | ||
|
||
import org.cyclonedx.model.ExternalReference; | ||
|
||
/** | ||
* Custom Plexus BasicConverter to instantiate <code>ExternalReference.Type</code> from a String. | ||
* | ||
* @see ExternalReference.Type | ||
*/ | ||
public class ExternalReferenceTypeConverter extends AbstractBasicConverter { | ||
|
||
@Override | ||
public boolean canConvert(Class type) { | ||
return ExternalReference.Type.class.isAssignableFrom(type); | ||
} | ||
|
||
@Override | ||
public Object fromString(String string) throws ComponentConfigurationException { | ||
Object value = ExternalReference.Type.fromString(string); | ||
if (value == null) { | ||
throw new ComponentConfigurationException("Unsupported ExternalReference type: " + string); | ||
} | ||
return value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters