public static ArtifactType newArtifactType( String id, ArtifactHandler handler ) { return new DefaultArtifactType( id, handler.getExtension(), handler.getClassifier(), handler.getLanguage(), handler.isAddedToClasspath(), handler.isIncludesDependencies() ); }
/** * Creates a new artifact type with the specified properties. * * @param id The identifier of the type, must not be {@code null} or empty. * @param extension The usual file extension for artifacts of this type, may be {@code null}. * @param classifier The usual classifier for artifacts of this type, may be {@code null}. * @param properties The properties for artifacts of this type, may be {@code null}. */ public DefaultArtifactType( String id, String extension, String classifier, Map<String, String> properties ) { if ( id == null || id.length() < 0 ) { throw new IllegalArgumentException( "no type id specified" ); } this.id = id; this.extension = emptify( extension ); this.classifier = emptify( classifier ); this.properties = AbstractArtifact.copyProperties( properties ); }
/** * Creates a new artifact type with the specified properties. * * @param id The identifier of the type, must not be {@code null} or empty. * @param extension The usual file extension for artifacts of this type, may be {@code null}. * @param classifier The usual classifier for artifacts of this type, may be {@code null}. * @param properties The properties for artifacts of this type, may be {@code null}. */ public DefaultArtifactType( String id, String extension, String classifier, Map<String, String> properties ) { this.id = requireNonNull( id, "type id cannot be null" ); if ( id.length() == 0 ) { throw new IllegalArgumentException( "type id cannot be empty" ); } this.extension = emptify( extension ); this.classifier = emptify( classifier ); this.properties = AbstractArtifact.copyProperties( properties ); }
private Dependency convert( org.apache.maven.model.Dependency dependency, ArtifactTypeRegistry stereotypes ) { ArtifactType stereotype = stereotypes.get( dependency.getType() ); if ( stereotype == null ) { stereotype = new DefaultArtifactType( dependency.getType() ); } boolean system = dependency.getSystemPath() != null && dependency.getSystemPath().length() > 0; Map<String, String> props = null; if ( system ) { props = Collections.singletonMap( ArtifactProperties.LOCAL_PATH, dependency.getSystemPath() ); } Artifact artifact = new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getClassifier(), null, dependency.getVersion(), props, stereotype ); List<Exclusion> exclusions = new ArrayList<>( dependency.getExclusions().size() ); for ( org.apache.maven.model.Exclusion exclusion : dependency.getExclusions() ) { exclusions.add( convert( exclusion ) ); } Dependency result = new Dependency( artifact, dependency.getScope(), dependency.getOptional() != null ? dependency.isOptional() : null, exclusions ); return result; }
/** * Creates a new artifact type with the specified properties. * * @param id The identifier of the type which will also be used as the value for the {@link ArtifactProperties#TYPE} * property, must not be {@code null} or empty. * @param extension The usual file extension for artifacts of this type, may be {@code null}. * @param classifier The usual classifier for artifacts of this type, may be {@code null}. * @param language The value for the {@link ArtifactProperties#LANGUAGE} property, may be {@code null}. * @param constitutesBuildPath The value for the {@link ArtifactProperties#CONSTITUTES_BUILD_PATH} property. * @param includesDependencies The value for the {@link ArtifactProperties#INCLUDES_DEPENDENCIES} property. */ public DefaultArtifactType( String id, String extension, String classifier, String language, boolean constitutesBuildPath, boolean includesDependencies ) { if ( id == null || id.length() < 0 ) { throw new IllegalArgumentException( "no type id specified" ); } this.id = id; this.extension = emptify( extension ); this.classifier = emptify( classifier ); Map<String, String> props = new HashMap<String, String>(); props.put( ArtifactProperties.TYPE, id ); props.put( ArtifactProperties.LANGUAGE, ( language != null && language.length() > 0 ) ? language : "none" ); props.put( ArtifactProperties.INCLUDES_DEPENDENCIES, Boolean.toString( includesDependencies ) ); props.put( ArtifactProperties.CONSTITUTES_BUILD_PATH, Boolean.toString( constitutesBuildPath ) ); properties = Collections.unmodifiableMap( props ); }
public static Dependency toDependency( org.apache.maven.model.Dependency dependency, ArtifactTypeRegistry stereotypes ) { ArtifactType stereotype = stereotypes.get( dependency.getType() ); if ( stereotype == null ) { stereotype = new DefaultArtifactType( dependency.getType() ); } boolean system = dependency.getSystemPath() != null && dependency.getSystemPath().length() > 0; Map<String, String> props = null; if ( system ) { props = Collections.singletonMap( ArtifactProperties.LOCAL_PATH, dependency.getSystemPath() ); } Artifact artifact = new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getClassifier(), null, dependency.getVersion(), props, stereotype ); List<Exclusion> exclusions = new ArrayList<>( dependency.getExclusions().size() ); for ( org.apache.maven.model.Exclusion exclusion : dependency.getExclusions() ) { exclusions.add( toExclusion( exclusion ) ); } Dependency result = new Dependency( artifact, dependency.getScope(), dependency.getOptional() != null ? dependency.isOptional() : null, exclusions ); return result; }
/** * Creates a new artifact type with the specified properties. * * @param id The identifier of the type which will also be used as the value for the {@link ArtifactProperties#TYPE} * property, must not be {@code null} or empty. * @param extension The usual file extension for artifacts of this type, may be {@code null}. * @param classifier The usual classifier for artifacts of this type, may be {@code null}. * @param language The value for the {@link ArtifactProperties#LANGUAGE} property, may be {@code null}. * @param constitutesBuildPath The value for the {@link ArtifactProperties#CONSTITUTES_BUILD_PATH} property. * @param includesDependencies The value for the {@link ArtifactProperties#INCLUDES_DEPENDENCIES} property. */ public DefaultArtifactType( String id, String extension, String classifier, String language, boolean constitutesBuildPath, boolean includesDependencies ) { this.id = requireNonNull( id, "type id cannot be null" ); if ( id.length() == 0 ) { throw new IllegalArgumentException( "type id cannot be empty" ); } this.extension = emptify( extension ); this.classifier = emptify( classifier ); Map<String, String> props = new HashMap<String, String>(); props.put( ArtifactProperties.TYPE, id ); props.put( ArtifactProperties.LANGUAGE, ( language != null && language.length() > 0 ) ? language : "none" ); props.put( ArtifactProperties.INCLUDES_DEPENDENCIES, Boolean.toString( includesDependencies ) ); props.put( ArtifactProperties.CONSTITUTES_BUILD_PATH, Boolean.toString( constitutesBuildPath ) ); properties = Collections.unmodifiableMap( props ); }
stereotypes.add( new DefaultArtifactType( "pom" ) ); stereotypes.add( new DefaultArtifactType( "maven-plugin", "jar", "", "java" ) ); stereotypes.add( new DefaultArtifactType( "jar", "jar", "", "java" ) ); stereotypes.add( new DefaultArtifactType( "ejb", "jar", "", "java" ) ); stereotypes.add( new DefaultArtifactType( "ejb-client", "jar", "client", "java" ) ); stereotypes.add( new DefaultArtifactType( "test-jar", "jar", "tests", "java" ) ); stereotypes.add( new DefaultArtifactType( "javadoc", "jar", "javadoc", "java" ) ); stereotypes.add( new DefaultArtifactType( "java-source", "jar", "sources", "java", false, false ) ); stereotypes.add( new DefaultArtifactType( "war", "war", "", "java", false, true ) ); stereotypes.add( new DefaultArtifactType( "ear", "ear", "", "java", false, true ) ); stereotypes.add( new DefaultArtifactType( "rar", "rar", "", "java", false, true ) ); stereotypes.add( new DefaultArtifactType( "par", "par", "", "java", false, true ) ); session.setArtifactTypeRegistry( stereotypes );
/** * Returns artifact type registry. Defines standard Maven stereotypes. * * @return */ public ArtifactTypeRegistry artifactTypeRegistry() { DefaultArtifactTypeRegistry stereotypes = new DefaultArtifactTypeRegistry(); stereotypes.add(new DefaultArtifactType("pom")); stereotypes.add(new DefaultArtifactType("maven-plugin", "jar", "", "java")); stereotypes.add(new DefaultArtifactType("jar", "jar", "", "java")); stereotypes.add(new DefaultArtifactType("ejb", "jar", "", "java")); stereotypes.add(new DefaultArtifactType("ejb-client", "jar", "client", "java")); stereotypes.add(new DefaultArtifactType("test-jar", "jar", "tests", "java")); stereotypes.add(new DefaultArtifactType("javadoc", "jar", "javadoc", "java")); stereotypes.add(new DefaultArtifactType("java-source", "jar", "sources", "java", false, false)); stereotypes.add(new DefaultArtifactType("war", "war", "", "java", false, true)); stereotypes.add(new DefaultArtifactType("ear", "ear", "", "java", false, true)); stereotypes.add(new DefaultArtifactType("rar", "rar", "", "java", false, true)); stereotypes.add(new DefaultArtifactType("par", "par", "", "java", false, true)); return stereotypes; }
/** * Returns artifact type registry. Defines standard Maven stereotypes. * * @return */ public ArtifactTypeRegistry artifactTypeRegistry() { DefaultArtifactTypeRegistry stereotypes = new DefaultArtifactTypeRegistry(); stereotypes.add(new DefaultArtifactType("pom")); stereotypes.add(new DefaultArtifactType("maven-plugin", "jar", "", "java")); stereotypes.add(new DefaultArtifactType("jar", "jar", "", "java")); stereotypes.add(new DefaultArtifactType("ejb", "jar", "", "java")); stereotypes.add(new DefaultArtifactType("ejb-client", "jar", "client", "java")); stereotypes.add(new DefaultArtifactType("test-jar", "jar", "tests", "java")); stereotypes.add(new DefaultArtifactType("javadoc", "jar", "javadoc", "java")); stereotypes.add(new DefaultArtifactType("java-source", "jar", "sources", "java", false, false)); stereotypes.add(new DefaultArtifactType("war", "war", "", "java", false, true)); stereotypes.add(new DefaultArtifactType("ear", "ear", "", "java", false, true)); stereotypes.add(new DefaultArtifactType("rar", "rar", "", "java", false, true)); stereotypes.add(new DefaultArtifactType("par", "par", "", "java", false, true)); return stereotypes; }
public static Dependency toDependency(org.apache.maven.model.Dependency dependency, ArtifactTypeRegistry stereotypes) { ArtifactType stereotype = stereotypes.get(dependency.getType()); if (stereotype == null) { stereotype = new DefaultArtifactType(dependency.getType()); } boolean system = dependency.getSystemPath() != null && dependency.getSystemPath().length() > 0; Map<String, String> props = null; if (system) { props = Collections.singletonMap(ArtifactProperties.LOCAL_PATH, dependency.getSystemPath()); } Artifact artifact = new DefaultArtifact(dependency.getGroupId(), dependency.getArtifactId(), dependency.getClassifier(), null, dependency.getVersion(), props, stereotype); List<Exclusion> exclusions = new ArrayList<Exclusion>(dependency.getExclusions().size()); for (org.apache.maven.model.Exclusion exclusion : dependency.getExclusions()) { exclusions.add(toExclusion(exclusion)); } Dependency result = new Dependency(artifact, dependency.getScope(), dependency.isOptional(), exclusions); return result; }
public static Dependency toDependency(org.apache.maven.model.Dependency dependency, ArtifactTypeRegistry stereotypes) { ArtifactType stereotype = stereotypes.get(dependency.getType()); if (stereotype == null) { stereotype = new DefaultArtifactType(dependency.getType()); } boolean system = dependency.getSystemPath() != null && dependency.getSystemPath().length() > 0; Map<String, String> props = null; if (system) { props = Collections.singletonMap(ArtifactProperties.LOCAL_PATH, dependency.getSystemPath()); } Artifact artifact = new DefaultArtifact(dependency.getGroupId(), dependency.getArtifactId(), dependency.getClassifier(), null, dependency.getVersion(), props, stereotype); List<Exclusion> exclusions = new ArrayList<Exclusion>(dependency.getExclusions().size()); for (org.apache.maven.model.Exclusion exclusion : dependency.getExclusions()) { exclusions.add(toExclusion(exclusion)); } Dependency result = new Dependency(artifact, dependency.getScope(), dependency.isOptional(), exclusions); return result; }
private Dependency convertToAether(org.apache.maven.model.Dependency dependency, ArtifactTypeRegistry stereotypes) { ArtifactType stereotype = stereotypes.get(dependency.getType()); if (stereotype == null) { stereotype = new DefaultArtifactType(dependency.getType()); } boolean system = dependency.getSystemPath() != null && dependency.getSystemPath().length() > 0; Map<String, String> props = null; if (system) { props = Collections.singletonMap(ArtifactProperties.LOCAL_PATH, dependency.getSystemPath()); } Artifact artifact = new DefaultArtifact(dependency.getGroupId(), dependency.getArtifactId(), dependency.getClassifier(), null, dependency.getVersion(), props, stereotype); List<Exclusion> exclusions = new ArrayList<Exclusion>(dependency.getExclusions().size()); for (org.apache.maven.model.Exclusion exclusion : dependency.getExclusions()) { exclusions.add(convert(exclusion)); } Dependency result = new Dependency(artifact, dependency.getScope(), dependency.isOptional(), exclusions); return result; }
private Dependency convert( org.apache.maven.model.Dependency dependency, ArtifactTypeRegistry stereotypes ) { ArtifactType stereotype = stereotypes.get( dependency.getType() ); if ( stereotype == null ) { stereotype = new DefaultArtifactType( dependency.getType() ); } boolean system = dependency.getSystemPath() != null && dependency.getSystemPath().length() > 0; Map<String, String> props = null; if ( system ) { props = Collections.singletonMap( ArtifactProperties.LOCAL_PATH, dependency.getSystemPath() ); } Artifact artifact = new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getClassifier(), null, dependency.getVersion(), props, stereotype ); List<Exclusion> exclusions = new ArrayList<Exclusion>( dependency.getExclusions().size() ); for ( org.apache.maven.model.Exclusion exclusion : dependency.getExclusions() ) { exclusions.add( convert( exclusion ) ); } Dependency result = new Dependency( artifact, dependency.getScope(), dependency.isOptional(), exclusions ); return result; }
private org.eclipse.aether.graph.Dependency convert( org.apache.maven.model.Dependency dependency, ArtifactTypeRegistry stereotypes ) { ArtifactType stereotype = stereotypes.get( dependency.getType() ); if ( stereotype == null ) { stereotype = new DefaultArtifactType( dependency.getType() ); } boolean system = dependency.getSystemPath() != null && dependency.getSystemPath().length() > 0; Map<String, String> props = null; if ( system ) { props = Collections.singletonMap( ArtifactProperties.LOCAL_PATH, dependency.getSystemPath() ); } Artifact artifact = new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getClassifier(), null, dependency.getVersion(), props, stereotype ); List<org.eclipse.aether.graph.Exclusion> exclusions = new ArrayList<org.eclipse.aether.graph.Exclusion>( dependency.getExclusions().size() ); for ( org.apache.maven.model.Exclusion exclusion : dependency.getExclusions() ) { exclusions.add( convert( exclusion ) ); } org.eclipse.aether.graph.Dependency result = new org.eclipse.aether.graph.Dependency( artifact, dependency.getScope(), dependency.isOptional(), exclusions ); return result; }
private Dependency convert( org.apache.maven.model.Dependency dependency, ArtifactTypeRegistry stereotypes ) { ArtifactType stereotype = stereotypes.get( dependency.getType() ); if ( stereotype == null ) { stereotype = new DefaultArtifactType( dependency.getType() ); } boolean system = dependency.getSystemPath() != null && dependency.getSystemPath().length() > 0; Map<String, String> props = null; if ( system ) { props = Collections.singletonMap( ArtifactProperties.LOCAL_PATH, dependency.getSystemPath() ); } Artifact artifact = new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getClassifier(), null, dependency.getVersion(), props, stereotype ); List<Exclusion> exclusions = new ArrayList<>( dependency.getExclusions().size() ); for ( org.apache.maven.model.Exclusion exclusion : dependency.getExclusions() ) { exclusions.add( convert( exclusion ) ); } Dependency result = new Dependency( artifact, dependency.getScope(), dependency.isOptional(), exclusions ); return result; }
stereotypes.add( new DefaultArtifactType( "pom" ) ); stereotypes.add( new DefaultArtifactType( "maven-plugin", "jar", "", "java" ) ); stereotypes.add( new DefaultArtifactType( "jar", "jar", "", "java" ) ); stereotypes.add( new DefaultArtifactType( "ejb", "jar", "", "java" ) ); stereotypes.add( new DefaultArtifactType( "ejb-client", "jar", "client", "java" ) ); stereotypes.add( new DefaultArtifactType( "test-jar", "jar", "tests", "java" ) ); stereotypes.add( new DefaultArtifactType( "javadoc", "jar", "javadoc", "java" ) ); stereotypes.add( new DefaultArtifactType( "java-source", "jar", "sources", "java", false, false ) ); stereotypes.add( new DefaultArtifactType( "war", "war", "", "java", false, true ) ); stereotypes.add( new DefaultArtifactType( "ear", "ear", "", "java", false, true ) ); stereotypes.add( new DefaultArtifactType( "rar", "rar", "", "java", false, true ) ); stereotypes.add( new DefaultArtifactType( "par", "par", "", "java", false, true ) ); session.setArtifactTypeRegistry( stereotypes );
(DefaultArtifactTypeRegistry) artifactTypeRegistry; defaultArtifactTypeRegistry .add(new DefaultArtifactType("bundle", MavenUtils.JAR_EXTENSION, "", MavenUtils.JAVA_LANGUAGE)); defaultArtifactTypeRegistry .add(new DefaultArtifactType("eclipse-plugin", MavenUtils.JAR_EXTENSION, "", MavenUtils.JAVA_LANGUAGE));
public static ArtifactType newArtifactType(String id, ArtifactHandler handler) { return new DefaultArtifactType(id, handler.getExtension(), handler.getClassifier(), handler.getLanguage(), handler.isAddedToClasspath(), handler.isIncludesDependencies()); }
stereotypes.add( new DefaultArtifactType( "pom" ) ); stereotypes.add( new DefaultArtifactType( "maven-plugin", "jar", "", "java" ) ); stereotypes.add( new DefaultArtifactType( "jar", "jar", "", "java" ) ); stereotypes.add( new DefaultArtifactType( "ejb", "jar", "", "java" ) ); stereotypes.add( new DefaultArtifactType( "ejb-client", "jar", "client", "java" ) ); stereotypes.add( new DefaultArtifactType( "test-jar", "jar", "tests", "java" ) ); stereotypes.add( new DefaultArtifactType( "javadoc", "jar", "javadoc", "java" ) ); stereotypes.add( new DefaultArtifactType( "java-source", "jar", "sources", "java", false, false ) ); stereotypes.add( new DefaultArtifactType( "war", "war", "", "java", false, true ) ); stereotypes.add( new DefaultArtifactType( "ear", "ear", "", "java", false, true ) ); stereotypes.add( new DefaultArtifactType( "rar", "rar", "", "java", false, true ) ); stereotypes.add( new DefaultArtifactType( "par", "par", "", "java", false, true ) ); session.setArtifactTypeRegistry( stereotypes );